I am trying to run this line of code from a Kaggle script:
df1 <- combined %>%
count(name = character, drilldown = character) %>%
arrange(desc(n)) %>%
head(9) %>%
rename(y = n)
However, when I run this code, I receive this error message:
Error: `name` must be a single string.
"Combined" is a dataframe containing 2 variables (character and dialogue, both of which are "character" variables.
ep4 <- data.frame(character = c("Luke", "Leia"),
dialogue = c("Hello", "world")
)
ep5 <- data.frame (character = c("Darth vader", "Sidious"),
dialogue = c("My", "name")
)
ep6 <- data.frame (character = c("R2D2", "ObiWan"),
dialogue = c("is", "Essan")
)
combined <- bind_rows(ep4, ep5, ep6)
str(combined):
'data.frame': 6 obs. of 2 variables:
$ character: chr "Luke" "Leia" "Darth vader" "Sidious" ...
$ dialogue : chr "Hello" "world" "My" "name" ...
I am not sure what I am doing wrong here. I am using the count()
function from the dpylr
package, not plyr
. There is an issue with the "name" argument from the count function. If I remove the "name" argument, the code runs, but the Pie Chart that is created later on (using df1
as its data) does not contain the names of the characters per slice.
Here is the Kaggle script: https://www.kaggle.com/couyang/star-wars-interac-drilldown-sentiment-analysis/execution