Solution error use lengths not length

Screen Link:

My Code:

split_interest <- fcc %>% select(JobRoleInterest) %>% drop_na() %>% rowwise %>% mutate(job_options = lengths(str_split(JobRoleInterest, ",")))
split_interest <- unnest(split_interest, job_options)

n_job_options <- split_interest %>% ungroup() %>% group_by(job_options) %>% summarise(freq = n()*100/nrow(split_interest)) %>% arrange(desc(freq))

The solution notebook uses the length function which will return one for all strings. However, from this stackoverflow found from the following google search: counting words in r lead me to the lengths function which does produce the correct frequency table (was struggling with this until trying without the length function realized that was the error).

Please update the solution notebook to reflect this

1 Like