write.gerbil | R Documentation |
Using a gerbil
object as an input, this function writes imputed datasets to an output file.
write.gerbil(gerb, file = NULL, imp = NULL, tall = FALSE, row.names = FALSE)
gerb |
A |
file |
The name of the file to which the imputed datasets are to be written.
Which type of file (.xlsx or .csv) is created depends upon the extension of the parameter |
imp |
The imputed datasets which are to be written. Can be a scalar or, if multiple imputed datasets are to be written, a vector.
All elements of |
tall |
A logical expression indicating whether the datasets are to be written in a tall (stacked) format
or written separately. When writing to an XLSX file with |
row.names |
A logical value indicating whether the row names of the datasets are to be written. |
The function writes imputed datasets to either an Excel (.xlsx) or a CSV (.csv) file, depending upon the extension of the parameter file
.
No other file types are supported.
To write multiple imputed datasets simultaneously, specify imp
as a vector with length greater than 1.
Multiple imputed datasets are either written in a stacked format (if tall = TRUE
) or written separately (if tall = FALSE
).
No returned value, but instead a data file is written to a specified directory.
#Load the India Human Development Survey-II dataset data(ihd_mcar) # Create a gerbil object imps.gerbil <- gerbil(ihd_mcar, m = 5, ords = "education_level", semi = "farm_labour_days", bincat = "job_field", n.cores = 1) # Write all imputed datasets to separate CSV files write.gerbil(imps.gerbil, file.path(tempdir(), "gerbil_example.csv"), imp = 1:5, tall = FALSE) # Write all imputed datasets to a single CSV files write.gerbil(imps.gerbil, file.path(tempdir(), "gerbil_example.csv"), imp = 1:5, tall = TRUE) # Write all imputed datasets to an XLSX file write.gerbil(imps.gerbil, file.path(tempdir(), "gerbil_example.xlsx"), imp = 1:5, tall = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.