Skip to content

Instantly share code, notes, and snippets.

@wch
Created November 30, 2012 16:23
Show Gist options
  • Select an option

  • Save wch/4176777 to your computer and use it in GitHub Desktop.

Select an option

Save wch/4176777 to your computer and use it in GitHub Desktop.
Code for testing plyr dll loading
# Initial setup ================================
# Start new R session
install.packages('plyr')
library(plyr)
packageVersion('plyr') # Should be 1.7.1
# Should throw error because function isn't exported in 1.7.1
split_indices(c(1L, 1L, 2L), 2L)
# Restart R session
library(devtools)
# Install updated version of plyr
setwd('Z:/Dropbox/Projects/plyr')
install()
# or install_github("plyr", ref = "plyr-1.8-rc")
# Will print a warning installing DLL
# Crashing with DLL mismatch ================================
# Restart R session
library(plyr)
packageVersion('plyr') # Should be 1.8
split_indices(c(1L, 1L, 2L), 2L) # Should crash
# Now you can modify the C code, and re-install
setwd('Z:/Dropbox/Projects/plyr')
install()
# To test any changes, restart R and run split_indices() code from above
# Overwriting the DLL ================================
# Restart R
library(devtools)
setwd('Z:/Dropbox/Projects/plyr')
unload() # This will unload the plyr DLL
install() # Now install will not have a problem overwriting the DLL
# Restart R session
library(plyr)
split_indices(c(1L, 1L, 2L), 2L) # Should not crash
# At this point, you can try different versions of the C code and see if it
# crashes. Any time you make a change, you must use unload(), then install().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment