R Housekeeping

July 14, 2017
R tutorial howto

R Housekeeping

Updating packages

# do any packages have an update available?
old.packages()

# update ALL of your old packages
update.packages()

# only update a specific package
install.packages("tidyverse")

Backing up packages (esp. before updating R)

This was documented well in a recent R-bloggers post. Below is merely the process as outlined in that tutorial with some slight touchups I got from another blog post I read.

1. Save a list of your current R packages

## Backup location
list_dir <- '/Users/Sami/Documents/Research/R/'

## Get the list of installed packages
installed <- dir(.libPaths())

## Save the list for later use
save(installed, file = file.path(list_dir, paste0(Sys.Date(), '-installed.Rdata')))

## Explore the list
head(installed) # make sure list of packages returns

length(installed) # gives number of packages

2. Update R

Nothing special here

3. Restore your packages to the new R install

## Call your backup location
list_dir <- '/Users/Sami/Documents/Research/R/'

## Call up the Rdata files w/ all your R packages
previous <- dir(path = list_dir, pattern = 'installed.Rdata')

## Load the latest Rdata file w/ your packages
load(file.path(list_dir, previous[length(previous)]))

## Install each package
for (count in 1:length(installedpackages)) install.packages(installedpackages[count])

## Check which packages are missing
current_post_installation <- dir(.libPaths())
installed[!installed %in% current_post_installation]

Importing Data into R

January 21, 2018
howto notes R tutorial

Python Basics: From Zero to Full Monty

September 27, 2017
notes study tutorial python

Tables: Converting Markdown to Huxtable

September 21, 2017
blog howto markdown R