1
I am trying to create a table based on the Chapter-Book-Feeling-n leaving the Chapter always in original order:"The Boy Who Lived", "The Vanishing Glass," "The Letters from No One", "The Keeper of Keys," "Diagon Alley," "The Journey from Platform Nine and Three Quarters", "The Sorting Hat," "The Potions Master," "The Midnight Duel," "Halloween," "Quidditch," "The Mirror of Erised", "Nicholas Flamel", "Norbert the Norwegian Ridgeback", "The Forbidden Forest," "Through the Trapdoor," "The Man with Two Faces"
Only when doing this table the chapter is ordered in alphabetical order. I have tried to give Sort=FALSE in Count but nothing works....
I’m doing like this:
cap=c("The Boy Who Lived",
"The Vanishing Glass",
"The Letters from No One",
"The Keeper of Keys",
"Diagon Alley",
"The Journey from Platform Nine and Three Quarters",
"The Sorting Hat",
"The Potions Master",
"The Midnight Duel",
"Halloween",
"Quidditch",
"The Mirror of Erised",
"Nicholas Flamel",
"Norbert the Norwegian Ridgeback",
"The Forbidden Forest",
"Through the Trapdoor",
"The Man with Two Faces")
PedraFilosofal = tibble(Capitulo = cap,
Texto = philosophers_stone,
Livro = "PedraFilosofal")
LetraPF = PedraFilosofal %>%
group_by(Capitulo,Livro) %>%
unnest_tokens(Letra,Texto)
SemSWPF = LetraPF %>%
anti_join(stop_words,by=c("Letra"="word"))
TabelaSentimentosCap = SemSWPF %>%
inner_join(get_sentiments("bing"),by = c("Letra" = "word")) %>%
count(Livro,sentiment) %>%
spread(sentiment,n,fill=0) %>%
mutate(Sentimento = positive-negative)
Try using the "factor" to keep the light in the order you want.
– Thiago Fernandes