Currently I am working with a dataset in r that I imported from a SPSS file converted to a csv. The data includes multiple factors such as gender, ethnicity, and test group, along with a set of weights I want to sum. I want to sum these weights based on multiple conditions (i.e. female + white + group1) so I tried subsetting the data.
small.set<-subset(df, df[,"gender"]==1 & df[,"ethnicity"] ==1 &
df[,"group"==1])
However, I get the following error:
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr,
: 'data' must be of a vector type, was 'NULL'
I found that when trying to select group 1 in any case, R returned strange results:
df["group"==1]
> data frame with 0 columns and 619 rows
The structure of "group" is as follows:
str(df["group")
>Factor w/ 3 levels "1", "2", "3": 1 3 1 1 2...
Does anyone know what is causing this to happen?