Hi all, I seem to be getting these messages a lot where I don't expect them. First I was just calculating a mean of columns for each row, something like:
va <- final_summative %>%
+ select(tid, va_read, va_math, iva_orig_score, va_mathse, va_readse) %>%
+ group_by(tid) %>%
+ mutate(my_iva=mean(va_read, va_math, na.rm=TRUE))
Error in if (trim > 0 && n) { : missing value where TRUE/FALSE needed
But then I did this and it worked OK:
> va <- final_summative %>%
+ select(tid, va_read, va_math, iva_orig_score, va_mathse, va_readse, va_math_n, va_read_n) %>%
+ filter(!is.na(tid)) %>% + group_by(tid) %>%
+ mutate(my_va_se=weighted.mean(x=c(va_read, va_math), w=c(va_read_n, va_math_n), na.rm=TRUE))
But then when I tried to look at a few cases to check that it was doing what I wanted to do, I got the same error:
> va[1:10, 5:10]
Error in if (any(names2(x) == "")) { :
missing value where TRUE/FALSE needed
This does not make sense to me. Here is my session info:
R version 3.1.3 (2015-03-09)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.6 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.4.1 scales_0.2.4 ggplot2_1.0.1 gmodels_2.15.4.1
[5] dplyr_0.4.1
loaded via a namespace (and not attached):
[1] assertthat_0.1 colorspace_1.2-6 compiler_3.1.3 DBI_0.3.1
[5] digest_0.6.8 gdata_2.16.1 grid_3.1.3 gtable_0.1.2
[9] gtools_3.4.2 labeling_0.3 lazyeval_0.1.10 magrittr_1.5
[13] MASS_7.3-40 munsell_0.4.2 parallel_3.1.3 plyr_1.8.2
[17] proto_0.3-10 Rcpp_0.11.6 stringi_0.4-1 stringr_1.0.0
[21] tools_3.1.3
TIA.
--