[datatable-help] Table function deletes non NA values in R

Frank Erickson fperickson at wisc.edu
Tue Jun 14 21:16:15 CEST 2016


Hi Emil,

This mailing list is only for the data.table package. Find out about other
lists here: https://www.r-project.org/mail.html

For reference, you probably want to link your SO post
http://stackoverflow.com/q/37819796/1191259

--Frank

On Tue, Jun 14, 2016 at 2:34 PM, phdmonster <emillfilipov at gmail.com> wrote:

> This here bugger worked perfectly until i changed the data set:
>
>     for (k in m) {
>     mos_sub <- subset(work_table_ansfreq, !is.na(work_table_ansfreq[,r]) &
> work_table_ansfreq$MOS_GROUP==k & !is.na(work_table_ansfreq$MOS_GROUP))
>     freq_mos<- table(mos_sub[,r])
>     qa[,k] <- freq_mos
>     }
> For some reason it removes both NA values (which is normal) and one column
> that actually has values. I will demonstrate. Output of the above code is:
>
>     I provide care for someone who suffers from
> Not applicable                        Prefer not to answer
>                                           4
> 631                                          14
>        Someone in my household suffers from
>                                           1
> And when i include **exclude = NULL** in the table brackets i get this:
>
>     I provide care for someone who suffers from
> I suffer from                              Not applicable
>                                              22
> 6                                        5258
>                            Prefer not to answer        Someone in my
> household suffers from                                        <NA>
>                                              94
> 13                                           0
>
> How do i fix this? Meaning how do i exclude only the NA which should be the
> only one excluded from the table anyway.
> Thanks!
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Table-function-deletes-non-NA-values-in-R-tp4721792.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20160614/c4f68f6a/attachment.html>


More information about the datatable-help mailing list