csv | R Documentation |
Functions to read and write CSV files. The objects returned by these
functions are data.frames
with the following attributes:
The path to the file on disk.
The type of CSV: either standard
or german
.
The hash value computed with digest's digest function, if digest is installed.
read_csv
is a wrapper to determine whether to use
utils:read.csv2
or
utils:read.csv
.
It sets the above three arguments.
write_csv
compares the hash
value stored in the object's
attribute
with the objects current hash value. If they differ, it writes the object to
the file
argument or, if not given, to the path
stored in the object's attribute. If no csv_type
is given, it uses
the csv
type stored in object's attribute.
If digest is not installed, the object will (unconditionally) be
written to disk.
read_csv(file, ...)
write_csv(x, file = NULL, csv_type = c(NA, "standard", "german"))
file |
The path to the file to be read or written. |
... |
Arguments passed to |
x |
The object to write to disk. |
csv_type |
Which |
For read_csv
: An object read from the file.
For write_csv
: The object with updated hash
(and possibly path
and csv
)
attribute.
Other CSV functions:
bulk_read_csv()
,
bulk_write_csv()
,
check_ascii_file()
,
csv2csv()
# read from standard CSV
f <- tempfile()
write.csv(mtcars, file = f)
str(read_csv(f))
f <- tempfile()
write.csv2(mtcars, file = f)
str(read_csv(f))
# write to standard CSV
f <- tempfile()
d <- mtcars
str(d <- write_csv(d, file = f))
file.mtime(f)
Sys.sleep(2) # make sure the mtime would have changed
write_csv(d, file = f)
file.mtime(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.