Description Usage Arguments Value Examples
read.data allows to read a file and create a data frame from it. Wrapper for
different data input functions available, namely data.table::fread, readxl::read_excel,
haven::read_sas, haven::read_sav, haven::read_dta and readODS::read_ods. The file
extensions supported are: csv, dat, data, dta, ods, RDa, RData, sas7bdat, sav, txt, xls and xlsx.
1 |
name |
a character string with the name of the file including the file extension from which the data are to be read from. |
dec |
a character string indicating the decimal separator for txt, csv, dat and data files. If not "." (default) then usually ",". |
header |
a character string indicating if the first data line contains column names, as
in |
sheet |
the sheet to read for xls, xlsx and ods files. Either a string (the name of a sheet) or an integer (the position of the sheet). If not specified, defaults to the first sheet. |
... |
Further arguments to be passed to |
A data.frame containing the data in the specified file or, if Rdata or Rda,
an object of class "ls_str".
1 2 3 4 5 6 7 8 9 10 11 | data <- data.frame(V1 = 1:5*0.1, V2 = 6:10)
tf <- tempfile("tp", fileext = c(".csv", ".txt", ".RData"))
write.csv(data, tf[1], row.names = FALSE)
read.data(tf[1]) # csv
write.csv2(data, tf[1], row.names = FALSE)
read.data(tf[1], dec = ",") # csv2
write.table(data, tf[2], row.names = FALSE)
read.data(tf[2]) # txt
save(data, file = tf[3])
read.data(tf[3]) # RData
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.