Arguments imply differing number of rows

1.8k Views Asked by At

I used cases function under package memisc to combine several values under 1 column. For example,

library(memisc)
age=cases(
   "10-20"=(data$your_age=="10-15"|data$your_age=="16-20"),
   "21-30"=(data$your_age=="21-25"|data$your_age=="26-30")
    )

And for the other variable (income), because there are some blank cells, I got rid of these no-responses and created a subset using, subset_income=subset(data, !data$your_income=="")

If the row number of age is 400, then after taking away blank cells of the income column, the row number becomes 300,

Then I grouped income as

income=cases("1k-2k"=(subset_income$your_income=="1k-0.5k"|subset_income$your_income=="0.5k-2k")
       "2.1k-3k"=(subset_income$your_income=="2.1k-2.5k"|subset_income$your_income=="2.6k-3k")
     )

Finally, I used tally under package mosaic to show a crosstab of these two variables, tally(~age|income,format="percent",data=data) and R warning showed "Arguments imply differing number of rows"

Is there any way to fix that? Thanks a lot!

0

There are 0 best solutions below