packrat
and checkpoint
and even a package designed to manage theupgrade for you on windows, but I’m a Mac user and wanted to do thingsmy own way and I don’t need that level of sophistication.R 3.5.3
and,very importantly, as much as I could about where I got the packagee.g. CRAN
or GitHub
or ???R 3.6.0
install and not copy any library directoriesmanually.Stack Overflow
. I wanted to extend the function listed there to doa little more of my work for me. Instead of just being able to generatea listing of what I had installed from GitHub I wanted to be able todetermine most of the places I get packages from, which are CRAN
,GitHub
and R-Forge
.tidyverse
to have access to all it’s various functionsand features and then build a dataframe called allmypackages
with thebasic information about the packages I currently have installed in R3.5.3.tibble
but I chose as.data.frame
filter
select
package~source
function will be applied to thePackage
column for each row of our dataframe. For exampleas.character(packageDescription('ggplot2')$Repository)
will get back“CRAN”, and as.character(packageDescription('CHAID')$Repository)
will yield “R-Forge”. For GitHub packages the result is character(0)
which has a length
of zero. So we’ll test with an if else
clause. Ifwe get an answer like “CRAN” we’ll just return
it. If not, we’ll seeif there is a GitHub repo listed withas.character(packageDescription(pkg)$GithubRepo)
as well as a GitHubusername as.character(packageDescription(pkg)$GithubUsername)
. If theyexist we’ll concatenate and return. If not we’ll return “Other”. Besidesbeing good defensive programming this may catch the package you havebuilt for yourself as is the case for me.package_source
function we can add a column toour data frame and do a little looking.tidyverse
since we need severalparts and because installing it will trigger the installation of quite afew dependencies and bootstrap our work.anti_join
to make adataframe that lists the differences thediff
. We can use filter
andpull
to generate a vector of just the the packages that are on CRAN wewant to install.tidyverse
inthe listing **devtools::install_github()
but instead I choose tohandle these manually as indevtools::install_github('leeper/slopegraph')
.