write.svystat.Rd
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
).
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#> region nace.macro va.imp2/emp.num SE.va.imp2/emp.num #> North.Agriculture North Agriculture 60.73814 3.9277681 #> Center.Agriculture Center Agriculture 66.29121 9.3007336 #> South.Agriculture South Agriculture 40.93788 5.4752941 #> North.Industry North Industry 51.58483 0.8132740 #> Center.Industry Center Industry 34.32244 1.2946269 #> South.Industry South Industry 57.80820 2.1040120 #> North.Commerce North Commerce 220.89970 15.2905919 #> Center.Commerce Center Commerce 243.14733 28.7693634 #> South.Commerce South Commerce 245.46210 37.1096192 #> North.Services North Services 35.24294 0.6594013 #> Center.Services Center Services 48.75319 1.6642295 #> South.Services South Services 39.25642 1.5866207 #> CI.l(95%).va.imp2/emp.num CI.u(95%).va.imp2/emp.num #> North.Agriculture 53.03985 68.43642 #> Center.Agriculture 48.06211 84.52032 #> South.Agriculture 30.20650 51.66926 #> North.Industry 49.99085 53.17882 #> Center.Industry 31.78502 36.85987 #> South.Industry 53.68441 61.93199 #> North.Commerce 190.93069 250.86871 #> Center.Commerce 186.76041 299.53424 #> South.Commerce 172.72858 318.19561 #> North.Services 33.95053 36.53534 #> Center.Services 45.49136 52.01502 #> South.Services 36.14670 42.36614 #> CV%.va.imp2/emp.num #> North.Agriculture 6.466725 #> Center.Agriculture 14.030115 #> South.Agriculture 13.374639 #> North.Industry 1.576576 #> Center.Industry 3.771954 #> South.Industry 3.639643 #> North.Commerce 6.921961 #> Center.Commerce 11.832071 #> South.Commerce 15.118269 #> North.Services 1.871017 #> Center.Services 3.413581 #> South.Services 4.041685# In order to export the summary statistics above # into a CSV file for input to Excel one can use: if (FALSE) { write.svystat(stat,file="stat.csv",sep=";") } # ...and to read this file back into R one needs if (FALSE) { stat.back <- read.table("stat.csv",header=TRUE,sep=";", check.names=FALSE) stat.back } # Notice, however, that the latter object has # lost a lot of meta-data as compared to the # original one, so that e.g.: if (FALSE) { confint(stat.back) } # ...while, on the contrary: confint(stat)#> 2.5 % 97.5 % #> North.Agriculture:va.imp2/emp.num 53.03985 68.43642 #> Center.Agriculture:va.imp2/emp.num 48.06211 84.52032 #> South.Agriculture:va.imp2/emp.num 30.20650 51.66926 #> North.Industry:va.imp2/emp.num 49.99085 53.17882 #> Center.Industry:va.imp2/emp.num 31.78502 36.85987 #> South.Industry:va.imp2/emp.num 53.68441 61.93199 #> North.Commerce:va.imp2/emp.num 190.93069 250.86871 #> Center.Commerce:va.imp2/emp.num 186.76041 299.53424 #> South.Commerce:va.imp2/emp.num 172.72858 318.19561 #> North.Services:va.imp2/emp.num 33.95053 36.53534 #> Center.Services:va.imp2/emp.num 45.49136 52.01502 #> South.Services:va.imp2/emp.num 36.14670 42.36614