problems with converting class to factor in dataframe [closed]
1
I am trying to combine dataframes and unify the classes of columns between them. I have a problem with note being about to convert one column to a factor. I've tried converting the dataframe using as.dataframe and converting the column using as.factor. I have dataframes a,b,c and list b$cat2 <-list[match (b$` Description`, list$Var1),"cat2",] b2 <-b[,c("Number", "DOB", "Gender", "cat2"),] colnames (b2) <- c ("Number", "DOB","Gender", "group" ) b2 <- as.data.frame (b2) a$group <- as.factor (a$group) class (b2$group ) [1] "tbl_df" "tbl" "data.frame" b2$group <- as.factor (b2$group) Error: Can't use matrix or array for column indexing Ca...