I have two large data.frames and want to rbind them together. When I do... I get the following error message:
1: In `[<-.factor`(`*tmp*`, ri, value = c(10, 5, 5, 8, 9, 3, 5, 2, : invalid factor level, NA generated 2: In `[<-.factor`(`*tmp*`, ri, value = c(11420, 10469, 7090, 10009, : invalid factor level, NA generated
So I wanted to create a test to see whether the columns in each data frame have the same factor levels. Column 1 of data.frame 1 should have the same levels as column 1 of data.frame 2... etc.
Here is what I wrote...
for (i in 1:ncol(frame1))
{if(is.factor(frame1[,i])==TRUE|is.ordered(frame1[,i]==TRUE))
{levels(frame[,i])==levels(frame2[,i])}
else {print("not.Factor")}}
When I run this, I see error messages:
15: In levels(ordinalRecipients[, i]) == levels(last.recipients.cohort[, ... : longer object length is not a multiple of shorter object length
These two data.frames are of unequal length, but is there a way I can still identify whether the factor levels for each column are equal? Thank-you for your help.
Aucun commentaire:
Enregistrer un commentaire