Reads a data file and returns it as a list of dataset objects.
Usage
readDatasets(
file,
...,
header = TRUE,
sep = ",",
quote = "\"",
dec = ".",
fill = TRUE,
comment.char = "",
fileEncoding = "UTF-8"
)
Arguments
- file
A CSV file (see
read.table
).- ...
Further arguments to be passed to
read.table
.- header
A logical value indicating whether the file contains the names of the variables as its first line.
- sep
The field separator character. Values on each line of the file are separated by this character. If sep = "," (the default for
readDatasets
) the separator is a comma.- quote
The set of quoting characters. To disable quoting altogether, use quote = "". See scan for the behavior on quotes embedded in quotes. Quoting is only considered for columns read as character, which is all of them unless
colClasses
is specified.- dec
The character used in the file for decimal points.
- fill
logical. If
TRUE
then in case the rows have unequal length, blank fields are implicitly added.- comment.char
character: a character vector of length one containing a single character or an empty string. Use "" to turn off the interpretation of comments altogether.
- fileEncoding
character string: if non-empty declares the encoding used on a file (not a connection) so the character data can be re-encoded. See the 'Encoding' section of the help for file, the 'R Data Import/Export Manual' and 'Note'.
Details
Reads a file that was written by writeDatasets()
before.
See also
readDataset()
for reading a single dataset,writeDatasets()
for writing multiple datasets,writeDataset()
for writing a single dataset.
Examples
dataFile <- system.file("extdata", "datasets_rates.csv", package = "rpact")
if (dataFile != "") {
datasets <- readDatasets(dataFile)
datasets
}
#> [[1]]
#> Dataset of rates:
#> Stages : 1, 1, 2, 2, 3, 3, 4, 4
#> Treatment groups : 1, 2, 1, 2, 1, 2, 1, 2
#> Sample sizes : 11, 8, 13, 10, 12, 9, 13, 11
#> Number of events : 10, 3, 10, 5, 12, 5, 12, 6
#>
#> Calculated data:
#> Cumulative sample sizes : 11, 8, 24, 18, 36, 27, 49, 38
#> Cumulative events : 10, 3, 20, 8, 32, 13, 44, 19
#>
#>
#> [[2]]
#> Dataset of rates:
#> Stages : 1, 1, 2, 2, 3, 3, 4, 4
#> Treatment groups : 1, 2, 1, 2, 1, 2, 1, 2
#> Sample sizes : 9, 6, 13, 10, 12, 9, 13, 11
#> Number of events : 10, 4, 10, 5, 12, 5, 12, 6
#>
#> Calculated data:
#> Cumulative sample sizes : 9, 6, 22, 16, 34, 25, 47, 36
#> Cumulative events : 10, 4, 20, 9, 32, 14, 44, 20
#>
#>