Opening and saving data

Data files contain one or many variables (as in Matlab). Open file with variables

load("filename")

Note that existing variables in the global environment will be overwritten by the ones saved in the file.

Save file

save(vars, file = "filename)

Data import

Import Stata

library(foreign)

mydata <- read.dta("filename")

Export via Excel

Import Excel

library(readxl)

data <- read_excel("", sheet = "sheetname", col_names = TRUE, skip = 0)

Export

library(xlsx)
write.xlsx(mydata100, file = "test", sheetName = "sheet", 
  col.names=TRUE, row.names=TRUE, append=FALSE, showNA=TRUE)  

Import Textfile

CSV files with semicolon are read with read_csv2()

library(readr)
read_csv2(file, col_names = TRUE, col_types = NULL, skip = 0, n_max = -1)

How does skip work if col_names = TRUE?

Delimeted files can be read with a similar set of options as read_csv:

library(readr)
read_delim(file, delim , ...)


bjornerstedt/assist documentation built on May 12, 2019, 9:26 p.m.