New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See all packages #23

Closed
RobertMyles opened this Issue Nov 18, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@RobertMyles

RobertMyles commented Nov 18, 2016

Would it be possible to include a simple function that shows the user all the packages in the tidyverse package? There's no quick way to see it in the docs, and as I assume the package will be evolving, I think it would be handy to have a function like this for users to see what packages they can load.

@RobertMyles

This comment has been minimized.

RobertMyles commented Dec 22, 2016

Maybe something like this? (I'm not too good at regex, I'm sure there must be a more elegant way to do this)

capture.output(
  cat(readLines(paste0(.libPaths(), "/tidyverse/DESCRIPTION")))) %>% 
  stringr::str_extract_all(., pattern = "Imports[[:print:]]*", 
                           simplify = T) %>% 
  stringr::str_extract_all(., "[[:print:]]*License",
                           simplify = T) %>% 
  gsub("License", "", .) %>% 
  gsub("Imports: ", "", .) %>% 
  gsub("\\s", "", .) %>% 
  cat()

broom,DBI,dplyr,forcats,ggplot2,haven,httr,hms,jsonlite,lubridate,magrittr,modelr,purrr,readr,readxl,stringr,tibble,rvest,tidyr,xml2

@hadley

This comment has been minimized.

Member

hadley commented Dec 22, 2016

packageDescription() would be a better starting place, and would be even easier to use the desc package.

@RobertMyles

This comment has been minimized.

RobertMyles commented Dec 22, 2016

What about this?

tidyverse_packages <- function(){
  x <- packageDescription("tidyverse", fields = "Imports")
  x <- gsub("\n", " ", x)
  message(paste0("tidyverse contains: ", x, collapse = "\n"))
}

> tidyverse_packages()
tidyverse contains: broom, DBI, dplyr, forcats, ggplot2, haven, httr, hms, jsonlite, lubridate, magrittr, modelr, purrr, readr, readxl, stringr, tibble, rvest, tidyr, xml2

@hadley hadley closed this in 9769ee9 Dec 29, 2016

@hadley

This comment has been minimized.

Member

hadley commented Dec 29, 2016

Ooops, I guess it was there already, I just needed to export it.

@RobertMyles

This comment has been minimized.

RobertMyles commented Dec 29, 2016

Ah ok! Good to have this function, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment