Learn R Programming

qdap (version 0.2.5)

mcsv_r: Read/Write Multiple csv Files at a Time

Description

mcsv_w - Read and assign multiple csv files at the same time. mcsv_w - Write multiple csv files into a file at the same time.

Usage

mcsv_r(files, a.names = NULL, l.name = NULL, list = TRUE,
    pos = 1, envir = as.environment(pos))

  mcsv_w(..., dir = NULL, open = FALSE)

Arguments

files
csv file(s) to read.
a.names
object names to assign the csv file(s) to. If NULL assigns the csv to the name(s) of the csv file(s) in the global environment.
l.name
A character vector of names to assign to the csv files (dataframes) being read in. Default (NULL) uses the names of the files in the directory without the file extension.
list
A character vector of length one to name the list being read in. Default is "L1".
pos
where to do the removal. By default, uses the current environment.
envir
the environment to use.
...
data.frame object(s) to write to a file or a list of data.frame objects. If the objects in a list are unnamed V + digit will be assigned.
dir
optional directory names. If NULL a directory will be created in the working directory with the data and time stamp as the folder name.
open
logical. If TRUE opens the directory upon completion.

Value

  • mcsv_r - reads in multiple csv files at once. mcsv_w - creates a directory with multiple csv files. Silently returns the path of the directory.

Details

mcsv is short for "multiple csv" and the suffix c(_r, _w) stands for "read" (r) or "write" (w).

See Also

cm_range2long, cm_df.temp, assign

Examples

Run this code
#mcsv_r EXAMPLE:
mtcarsb <- mtcars[1:5, ]; CO2b <- CO2[1:5, ]
(a <- mcsv_w(mtcarsb, CO2b, dir="foo"))
rm("mtcarsb", "CO2b")  # gone from .GlobalEnv
(nms <- dir(a))
mcsv_r(paste(a, nms, sep="/"))
mtcarsb; CO2b
rm("mtcarsb", "CO2b")  # gone from .GlobalEnv
mcsv_r(paste(a, nms, sep="/"), paste0("foo.dat", 1:2))
foo.dat1; foo.dat2
rm("foo.dat1", "foo.dat2")  # gone from .GlobalEnv
delete("foo")

#mcsv_w EXAMPLE:
(a <- mcsv_w(mtcars, CO2, dir="foo"))
delete("foo")

Run the code above in your browser using DataLab