R - Error in rename(., word = value) : unused argument (word = value)

Viewed 33

I have the following dataset

dput(model$top_terms)
structure(c("occupations", "professionals", "isco", "ict", "education", 
"demand", "sector", "shortages", "shortage", "number", "labour", 
"www", "health", "workers", "accessed", "supply", "market", "skills", 
"thousand", "graduates", "skills", "workers", "professionals", 
"employment", "demand", "sector", "services", "eu", "jobs", "sectors", 
"health", "occupations", "expected", "occupation", "key", "service", 
"group", "business", "ict", "future", "www", "http", "de", "http_www", 
"training", "pdf", "labour", "social", "es", "amp", "employment", 
"pl", "en", "skills", "national", "system", "https", "czech", 
"romania", "la", "nbsp", "amp", "type", "type_nbsp", "indicator", 
"percentage", "year", "rate", "unemployment", "area", "indicator_nbsp", 
"euro", "euro_area", "eu", "quarter", "preffix", "preffix_nbsp", 
"point", "percentage_point", "nbsp_year", "education", "training", 
"learning", "skills", "education_training", "vocational", "young", 
"people", "european", "vet", "young_people", "youth", "cedefop", 
"support", "digital", "information", "vocational_education", 
"school", "apprenticeships", "work", "european", "commission", 
"social", "policy", "eu", "cedefop", "nbsp", "vet", "labour", 
"europe", "work", "european_commission", "skills", "conference", 
"national", "policies", "ilo", "employment", "future", "development", 
"employment", "labour", "social", "market", "eu", "labour_market", 
"people", "work", "economic", "workers", "growth", "unemployment", 
"low", "report", "oecd", "countries", "high", "women", "working", 
"million", "skills", "skill", "cedefop", "jobs", "eu", "data", 
"labour", "panorama", "european", "skills_panorama", "market", 
"job", "labour_market", "mismatch", "survey", "work", "information", 
"demand", "future", "employers", "skills", "anticipation", "labour", 
"skills_anticipation", "education", "labour_market", "market", 
"national", "http", "employment", "www", "regional", "ministry", 
"data", "information", "demand", "forecasts", "lt", "training", 
"gt", "de", "en", "des", "www", "la", "les", "studies", "training", 
"van", "http_www", "ams", "emploi", "portugal", "und", "employment", 
"luxembourg", "pdf", "du", "france", "het"), dim = c(20L, 10L
), dimnames = list(NULL, c("t_1", "t_2", "t_3", "t_4", "t_5", 
"t_6", "t_7", "t_8", "t_9", "t_10")))

and I am trying to run the following code:

library(reshape)
#visualising topics of words based on the max value of phi
set.seed(1234)
final_summary_words <- data.frame(top_terms = t(model$top_terms))
final_summary_words$topic <- rownames(final_summary_words)
rownames(final_summary_words) <- 1:nrow(final_summary_words)
final_summary_words <- final_summary_words %>% melt(id.vars = c("topic"))
final_summary_words <- final_summary_words %>% rename(word = value) %>% select(-variable)
final_summary_words <- left_join(final_summary_words,allterms)
final_summary_words <- final_summary_words %>% group_by(topic,word) %>%
  arrange(desc(value))
final_summary_words <- final_summary_words %>% group_by(topic, word) %>% filter(row_number() == 1) %>% 
  ungroup() %>% tidyr::separate(topic, into =c("t","topic")) %>% select(-t)
word_topic_freq <- left_join(final_summary_words, original_tf, by = c("word" = "term"))
pdf("cluster.pdf")
for(i in 1:length(unique(final_summary_words$topic)))
{  wordcloud(words = subset(final_summary_words ,topic == i)$word, freq = subset(final_summary_words ,topic == i)$value, min.freq = 1,
             max.words=200, random.order=FALSE, rot.per=0.35, 
             colors=brewer.pal(8, "Dark2"))}
dev.off()

but I get the following error:

Error in rename(., word = value) : unused argument (word = value)

why do I get this error? How can I fix that?

1 Answers

Try add dplyr:: before your rename function to make sure it uses the right function like this:

x <- structure(c("occupations", "professionals", "isco", "ict", "education", 
                 "demand", "sector", "shortages", "shortage", "number", "labour", 
                 "www", "health", "workers", "accessed", "supply", "market", "skills", 
                 "thousand", "graduates", "skills", "workers", "professionals", 
                 "employment", "demand", "sector", "services", "eu", "jobs", "sectors", 
                 "health", "occupations", "expected", "occupation", "key", "service", 
                 "group", "business", "ict", "future", "www", "http", "de", "http_www", 
                 "training", "pdf", "labour", "social", "es", "amp", "employment", 
                 "pl", "en", "skills", "national", "system", "https", "czech", 
                 "romania", "la", "nbsp", "amp", "type", "type_nbsp", "indicator", 
                 "percentage", "year", "rate", "unemployment", "area", "indicator_nbsp", 
                 "euro", "euro_area", "eu", "quarter", "preffix", "preffix_nbsp", 
                 "point", "percentage_point", "nbsp_year", "education", "training", 
                 "learning", "skills", "education_training", "vocational", "young", 
                 "people", "european", "vet", "young_people", "youth", "cedefop", 
                 "support", "digital", "information", "vocational_education", 
                 "school", "apprenticeships", "work", "european", "commission", 
                 "social", "policy", "eu", "cedefop", "nbsp", "vet", "labour", 
                 "europe", "work", "european_commission", "skills", "conference", 
                 "national", "policies", "ilo", "employment", "future", "development", 
                 "employment", "labour", "social", "market", "eu", "labour_market", 
                 "people", "work", "economic", "workers", "growth", "unemployment", 
                 "low", "report", "oecd", "countries", "high", "women", "working", 
                 "million", "skills", "skill", "cedefop", "jobs", "eu", "data", 
                 "labour", "panorama", "european", "skills_panorama", "market", 
                 "job", "labour_market", "mismatch", "survey", "work", "information", 
                 "demand", "future", "employers", "skills", "anticipation", "labour", 
                 "skills_anticipation", "education", "labour_market", "market", 
                 "national", "http", "employment", "www", "regional", "ministry", 
                 "data", "information", "demand", "forecasts", "lt", "training", 
                 "gt", "de", "en", "des", "www", "la", "les", "studies", "training", 
                 "van", "http_www", "ams", "emploi", "portugal", "und", "employment", 
                 "luxembourg", "pdf", "du", "france", "het"), dim = c(20L, 10L
                 ), dimnames = list(NULL, c("t_1", "t_2", "t_3", "t_4", "t_5", 
                                            "t_6", "t_7", "t_8", "t_9", "t_10")))


library(reshape)
library(dplyr)
#visualising topics of words based on the max value of phi
set.seed(1234)
final_summary_words <- data.frame(top_terms = t(x))
final_summary_words$topic <- rownames(final_summary_words)
rownames(final_summary_words) <- 1:nrow(final_summary_words)
final_summary_words <- final_summary_words %>% melt(id.vars = c("topic"))
final_summary_words <- final_summary_words %>% dplyr::rename(word = value) %>% select(-variable)
head(final_summary_words)
#>   topic        word
#> 1   t_1 occupations
#> 2   t_2      skills
#> 3   t_3         www
#> 4   t_4        nbsp
#> 5   t_5   education
#> 6   t_6    european

Created on 2022-09-10 with reprex v2.0.2

Please note: I called your dataset x!

Related