write.excel {povmap} | R Documentation |
Exports an emdiObject to an Excel File or OpenDocument Spreadsheet
Description
Function write.excel
enables the user to export point and MSE
estimates as well as diagnostics from the summary
to an Excel file.
The user can choose if the results should be reported in one or several Excel
sheets. Furthermore, a selection of indicators can be specified.
Respectively the function write.ods
enables the export to OpenDocument
Spreadsheets. Note that while write.exel
will create a single document
write.ods
will create a group of files.
Usage
write.excel(
object,
file = NULL,
indicator = "all",
MSE = FALSE,
CV = FALSE,
split = FALSE,
model = FALSE
)
write.ods(
object,
file = NULL,
indicator = "all",
MSE = FALSE,
CV = FALSE,
split = FALSE
)
Arguments
object |
an object of type "emdi", representing point and MSE estimates. |
file |
path and filename of the spreadsheet to create. It should end on .xlsx or .ods respectively. |
indicator |
optional character vector that selects which indicators
shall be returned: (i) all calculated indicators ("all");
(ii) each indicator name: "Mean", "Quantile_10", "Quantile_25", "Median",
"Quantile_75", "Quantile_90", "Head_Count",
"Poverty_Gap", "Gini", "Quintile_Share" or the function name/s of
"custom_indicator/s"; (iii) groups of indicators: "Quantiles", "Poverty" or
"Inequality". Note, additional custom indicators can be
defined as argument for model-based approaches (see also |
MSE |
logical. If |
CV |
logical. If |
split |
logical. If |
model |
logical if |
Details
These functions create an Excel file via the package openxlsx and ODS files via the package readODS. Both packages require a zip application to be available to R. If this is not the case the authors of openxlsx suggest the first of the following two ways.
Install Rtools from: http://cran.r-project.org/bin/windows/Rtools/ and modify the system PATH during installation.
If Rtools is installed, but no system path variable is set. One can set such a variable temporarily to R by a command like:
Sys.setenv("R_ZIPCMD" = "PathToTheRToolsFolder/bin/zip.exe")
.
To check if a zip application is available they recommend the command
shell("zip")
.
Value
An Excel file is created in your working directory, or at the given path. Alternatively multiple ODS files are created at the given path.
See Also
direct
, emdiObject
, ebp
,
fh
Examples
# Loading data - population and sample data
data("eusilcA_pop")
data("eusilcA_smp")
# Generate emdi object with two additional indicators; here via function
# ebp()
emdi_model <- ebp(
fixed = eqIncome ~ gender + eqsize + cash +
self_empl + unempl_ben + age_ben + surv_ben + sick_ben + dis_ben + rent +
fam_allow + house_allow + cap_inv + tax_adj, pop_data = eusilcA_pop,
pop_domains = "district", smp_data = eusilcA_smp, smp_domains = "district",
threshold = function(y) {
0.6 * median(y)
}, L = 50, MSE = TRUE, B = 50,
custom_indicator = list(
my_max = function(y) {
max(y)
},
my_min = function(y) {
min(y)
}
), na.rm = TRUE, cpus = 1
)
# Example 1: Export estimates for all indicators and uncertainty measures
# and diagnostics to Excel
write.excel(emdi_model, indicator = "all", MSE = TRUE, CV = TRUE)
# Example 2: Single Excel sheets for point, MSE and CV estimates
write.excel(emdi_model, indicator = "all", MSE = TRUE, CV = TRUE,
split = TRUE)
# Example 3: Same as example 1 but for an ODS output, skipped due to lack of zip app
# write.ods(emdi_model, indicator = "all", MSE = TRUE, CV = TRUE)