Skip to content

Instantly share code, notes, and snippets.

@rrodrigueznt
Last active May 26, 2017 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrodrigueznt/2e9b032c7d6f214caf60 to your computer and use it in GitHub Desktop.
Save rrodrigueznt/2e9b032c7d6f214caf60 to your computer and use it in GitHub Desktop.
## Load any library able to read Excel files
library(XLConnect)
## Load any library able to select a substring
library(stringr)
## Read file contents by naming file and sheet
IDIS.USC <- file.path("~/Dropbox/IDIS-devel/IDIS.activities.USC.20130415.xls")
Actividades <- readWorksheetFromFile(IDIS.USC, sheet="Actividades")
## Subset, transform and order the data frame
codes <- Actividades[,c("Rexistro","TipoAxuda")]
codes <- unique(codes)
codes <- transform(codes, Rexistro = str_sub(Rexistro,6,7))
codes <- unique(codes)
codes <- codes[order(codes[,1],codes[,2]), ]
## Write out a CSV file complient with Excel 2011 for Mac OS X
write.csv(codes, file = "~/Dropbox/IDIS-devel/USC.projects.codes.lat1.csv", row.names = FALSE, fileEncoding = "latin1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment