The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
While eg_read() and eg_write() handle raw
file transfers, you probably spend most of your time working with data
files that you want to load directly into R as data frames. egnyte
provides a set of functions that handle the download-read or
write-upload workflow in a single step.
Before you can read or write files, you need to authenticate. See
vignette("configuration") or
vignette("authorization") if you haven’t set that up
yet.
egnyte provides read functions for common data formats. Each function:
This uses readr::read_csv() under the hood. You can pass
any additional arguments that read_csv() accepts:
For files with delimiters other than commas:
# Read an Excel file (first sheet by default)
dat <- eg_read_excel("/Shared/Data/workbook.xlsx")
# Read a specific sheet by name
dat <- eg_read_excel("/Shared/Data/workbook.xlsx", sheet = "Summary")
# Read a specific sheet by position
dat <- eg_read_excel("/Shared/Data/workbook.xlsx", sheet = 3)Additional readxl::read_excel() arguments work here
too:
The write functions work in reverse - they take an R object, write it to a temporary file, and upload it to Egnyte.
By default, this will fail if the file already exists:
You can pass additional arguments to
readr::write_csv():
Note: egnyte can write XPT files but not native SAS7BDAT files. If you need SAS7BDAT, you’ll need to use SAS itself or another tool.
The format-specific functions require additional packages that aren’t installed by default with egnyte:
| Function | Required Package |
|---|---|
eg_read_csv(), eg_write_csv() |
readr |
eg_read_delim(), eg_write_delim() |
readr |
eg_read_excel() |
readxl |
eg_write_excel() |
writexl |
eg_read_sas(), eg_read_xpt(),
eg_write_xpt() |
haven |
eg_read_stata(), eg_write_stata() |
haven |
eg_read_spss(), eg_write_spss() |
haven |
eg_read_rds(), eg_write_rds() |
(base R - no extra package) |
If you try to use a function without the required package installed, egnyte will prompt you to install it:
The readr package is required for this function.
Would you like to install it? (yes/no)
The read functions download the entire file before reading it. For large files, this can take a while and use significant memory. A few suggestions:
col_select
argument (for CSV/delim files) to avoid loading unnecessary dataeg_read() to download the file once, then work with it
locallyAll the format-specific functions accept ... arguments
that get passed to the underlying read/write function. If you’re
familiar with readr::read_csv() or
haven::read_sas(), you can use all the same options:
egnyte uses the file extension to determine the format when downloading. Make sure your files have the correct extension:
.csv for CSV files.xlsx or .xls for Excel files.sas7bdat for SAS data files.xpt for SAS transport files.dta for Stata files.sav for SPSS files.rds for R objectsHere’s the difference between using the format-specific functions
vs. the base eg_read()/eg_write():
Using eg_read_csv() (recommended for data files):
Using eg_read() (manual approach):
# Two steps - download, then read
temp_file <- eg_read("/Shared/Data/data.csv")
dat <- readr::read_csv(temp_file)
unlink(temp_file) # Clean upThe format-specific functions handle all this for you and clean up temporary files automatically.
vignette("authorization")vignette("file-transfer")These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.