Hello I have a dataframe record in R of dimension 8 obs 60 variables , with the missing values replaced by NA and the other values being words.
When I try
Your current code is trying to make a 60-dimensional table, returning the counts of every unique combination of the 60 variables. Thus the > 2^31 elements error.
Do you want sapply(record, table)
to tabulate each variable individually?
its old topic but it might help someone else that reason I posting it. I had the same problem and I found it online solution from somewhere I don't remember and it worked for me perfectly. hopefully works for someone who needs.
solution<-as.data.frame(table(unlist(record)))
The main issue is the complicating levels in your data frame. There are two ways to get around this problem:
invoke droplevels
after subsetting the data.frame. For example:
feeds <- droplevels(record)
Use apply
family functions, like sapply
someone mentioned earlier. For example:
feeds <- apply(record,1,table) # output stored as an object feeds
Good luck.
I had this same problem. What worked for me was removing the NA's like this
df <- df[!is.na(df)]
I also had this issue. What worked for me was by converting each column in the dataframe into a numeric or character using the following lines:
df$x = as.numeric(as.character(df$x))
df$y = as.numeric(as.character(df$y))
df$z= as.numeric(as.character(df$z))
This will remove the factor levels in each of the variables within the dataframe. If you need the factor levels, I would not recommend doing this, but if you just need the raw values this will work well.