Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get an error of can't make a table of more 2^31 elements in R

Tags:

r

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 to tabulate the dataframe like this feeds<-table(record) I get an error saying :

Error in table(record) : attempt to make a table with >= 2^31 elements

Some sample elements/structure of my dataframe are

INC - CORP Application Issue    INC - CORP Issue    INC - PC Software Issue
Affected User                   Affected User       Affected User
Attachment                      Attachment          Attachment
Description / Priority          Business Critica..  Configuration Item
Knowledge Search                Client ID           Contact Info
NA                              Description / Pr..  NA                      

I don't understand the error as the elements in the dataframe are clearly not even close to 2^31.

Thanks for your time.

like image 351
Snedden27 Avatar asked Feb 25 '15 13:02

Snedden27


2 Answers

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)))
like image 167
samet gok Avatar answered Nov 14 '22 16:11

samet gok


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?

like image 40
Sam Firke Avatar answered Nov 14 '22 15:11

Sam Firke