I want to do some character processing
the raw data frame just like
raw <- data.frame(id = c(1,2,1), column = "APP School. APP2 School. May 5 Scholl, type2.",
column2 = " abc school, type2, type3. aaa university, type3.",
column3 =" abc school, type2, type3. aaa university, type3.")
i want to "group_by(id)" to know the frequncy about "APP School", "APP2 School", "abc school" and so on,
i want to transform the raw data with annother format.
one is
format1 <- data.frame(id = c(1,2,1), name_1 = c("APP School","abc school", "abc school"),
class_1 = c(NA, "type2", "type2"), class_2 = c(NA, "type3", "type3"),
name_2 = c("PP2 School", "aaa university", "aaa university"),
class_3 = c(NA, "type3","type3"),
name_3 = c("May 5 Scholl", NA, NA), class_4 = c("type2", NA, NA))
format2 <- data.frame(id = c(1,2,1) , APP_School = c(1,0,0), APP2_School = c(1,0,0), May_5_Scholl = c(1,0,0),
type2 = c(1,1,1), type3 = c(0,2,2), abc_school = c(0,1,1), aaa_university = c(0,1,1))
format3 <- data.frame(id = c(1,2), APP_School = c(1,0), APP2_School = c(1,0), May_5_Scholl = c(1,0),
type2 = c(2,1), type3 = c(2,2), abc_school = c(1,1), aaa_university = c(1,1))
How can i get it.
Thanks a lot.