write.svystat | R Documentation |
Prints survey statistics to a file or connection.
write.svystat(x, ...)
x |
An object containing survey statistics. |
... |
Arguments to |
This function is just a convenience wrapper to write.table
, designed to export objects which have been returned by survey statistics functions (e.g. svystatTM
, svystatR
, svystatS
, svystatSR
, svystatB
, svystatQ
, svystatL
, svySigma
, svySigma2
).
Diego Zardetto
write.table
and the 'R Data Import/Export' manual.
# Creation of a design object:
data(sbs)
des<-e.svydesign(data=sbs,ids=~id,strata=~strata,weights=~weight,
fpc=~fpc)
# Estimation of the average value added per employee
# for economic activity region and macro-sectors,
# with SE, CV% and standard confidence intervals:
stat <- svystatR(des,~va.imp2,~emp.num,by=~region:nace.macro,
vartype=c("se","cvpct"),conf.int=TRUE)
stat
# In order to export the summary statistics above
# into a CSV file for input to Excel one can use:
## Not run:
write.svystat(stat,file="stat.csv",sep=";")
## End(Not run)
# ...and to read this file back into R one needs
## Not run:
stat.back <- read.table("stat.csv",header=TRUE,sep=";",
check.names=FALSE)
stat.back
## End(Not run)
# Notice, however, that the latter object has
# lost a lot of meta-data as compared to the
# original one, so that e.g.:
## Not run:
confint(stat.back)
## End(Not run)
# ...while, on the contrary:
confint(stat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.