You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since I am often working with surveys the memisc library looks very promising. I always work with data.table and there seems to be an issue however.
When I generate a codebook with memisc on a data.table, there is the following issue: when I type the name of the object (say, mtcars) an error is thrown, see code below.
library(memisc)
library(data.table)
data(mtcars)
setDT(mtcars, keep.rownames= T)
mtcars = within(mtcars, {
description(vs) = "whatever"
description(am) = "something unclear"
description(carb) = "something different"
wording(vs) = "this is going to be a long comment"
labels(vs) = c(
"many" = 1,
"not so many" = 0
)
labels(carb) = c(
"one" = 1,
"two" = 2,
"three" = 3
)
missing.values(carb) = c(4,6, 8)
})
codebook(mtcars) %>% show_html
# annotation(mtcars) = "my long story"
# if data.frame = error and annotation(mtcars) = "....text...." then message "Error in if (nzchar(nm.i)) { : argument is of length zero"
# annotation(mtcars)
# if data.table: throws error "Error in format.item(char.trunc(col), justify = justify, ...) :
# unused argument (justify = justify)
mtcars
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 15.04
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=nl_NL.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=nl_NL.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] Hmisc_3.17-0 ggplot2_2.0.0 Formula_1.2-1 survival_2.38-3 magrittr_1.5 DescTools_0.99.15 manipulate_1.0.1 memisc_0.99.3 MASS_7.3-44 lattice_0.20-33 data.table_1.9.7
loaded via a namespace (and not attached):
[1] Rcpp_0.12.3 nloptr_1.0.4 RColorBrewer_1.1-2 plyr_1.8.3 tools_3.2.3 rpart_4.1-10 boot_1.3-17 lme4_1.1-9 nlme_3.1-122 gtable_0.1.2 mgcv_1.8-7 Matrix_1.2-2
[13] parallel_3.2.3 mvtnorm_1.0-3 SparseM_1.7 proto_0.3-10 gridExtra_2.0.0 cluster_2.0.3 MatrixModels_0.4-1 nnet_7.3-11 foreign_0.8-66 latticeExtra_0.6-26 minqa_1.2.4 car_2.0-25
[25] scales_0.3.0 splines_3.2.3 rsconnect_0.4.1.11 pbkrtest_0.4-2 colorspace_1.2-6 quantreg_5.19 acepack_1.3-3.3 munsell_0.4.2 chron_2.3-47
The text was updated successfully, but these errors were encountered:
You are using annotation etc. in a way they are not intended:
annotation etc. are supposed only to work with objects of class "item" which are expected to be in a "data.set" object rather than a "data.frame" or "data.table" object.
There is no support for "data.table" objects yet.
To get what you apparently want, try:
library(memisc)
library(data.table)
data(mtcars)
## This is necessary to get things working ...mtcars<- as.data.set(mtcars)
mtcars<- within(mtcars, {
description(vs) <-"whatever"
description(am) <-"something unclear"
description(carb) <-"something different"
wording(vs) <-"this is going to be a long comment"
labels(vs) <- c(
"many"=1,
"not so many"=0
)
labels(carb) <- c(
"one"=1,
"two"=2,
"three"=3
)
missing.values(carb) <- c(4,6, 8)
})
codebook(mtcars)
annotation(mtcars) <-"my long story"
annotation(mtcars)
mtcars## To get a data frame, use# as.data.frame(mtcars)
Since I am often working with surveys the memisc library looks very promising. I always work with data.table and there seems to be an issue however.
When I generate a codebook with memisc on a data.table, there is the following issue: when I type the name of the object (say, mtcars) an error is thrown, see code below.
The text was updated successfully, but these errors were encountered: