how do you write codes in Rstudio for sentiment analysis for the tables and codes provided; able
Question:
how do you write codes in Rstudio for sentiment analysis for the tables and codes provided;
able 2: Customer Feedback Data
Feedback | Sentiment Score |
The service was excellent and the prices were reasonable. | 0.85 |
The selection was good, but the restaurant was not very clean. | 0.65 |
The quality of the products was poor and the staff was unhelpful. | -0.75 |
Source: Customer Survey Analysis (2023)
Table 3 presents the correlation results for key customer service attributes.
Table 3: Correlation Matrix of Customer Feedback Keywords
Quality | Service | Price | Selection | Cleanliness | Atmosphere | Convenience | Location | Staff | Wait Time |
Quality | 1.00 | 0.45 | -0.23 | 0.57 | 0.38 | 0.32 | 0.24 | 0.15 | 0.18 | -0.05 |
Service | 0.45 | 1.00 | 0.12 | 0.65 | 0.51 | 0.46 | 0.39 | 0.28 | 0.62 | 0.21 |
Price | -0.23 | 0.12 | 1.00 | -0.35 | -0.26 | -0.15 | -0.20 | -0.31 | -0.08 | 0.13 |
Selection | 0.57 | 0.65 | -0.35 | 1.00 | 0.43 | 0.38 | 0.31 | 0.12 | 0.23 | -0.10 |
Cleanliness | 0.38 | 0.51 | -0.26 | 0.43 | 1.00 | 0.49 | 0.36 | 0.21 | 0.29 | -0.05 |
Atmosphere | 0.32 | 0.46 | -0.15 | 0.38 | 0.49 | 1.00 | 0.27 | 0.18 | 0.25 | -0.08 |
Convenience | 0.24 | 0.39 | -0.20 | 0.31 | 0.36 | 0.27 | 1.00 | 0.34 | 0.21 | -0.15 |
Location | 0.15 | 0.28 | -0.09 | 0.22 | 0.15 | 0.18 | 0.30 | 1.00 | 0.18 | -0.13 |
Staff | 0.18 | 0.62 | -0.08 | 0.23 | 0.29 | 0.25 | 0.21 | 0.18 | 1.00 | 0.12 |
Wait Time | -0.05 | 0.21 | 0.13 | -0.10 | -0.05 | -0.08 | -0.15 | -0.13 | 0.12 | 1.00 |
Source: Customer Survey Analysis (2023)
Note: The values in the table represent the Pearson correlation coefficient between the corresponding pairs of feedback keywords.
From Table 3, the correlation coefficients weak, moderate, and strong negative and positive relationship among key attributes. "Quality" has moderate positive association with Service (0.45) and Selection (0.57) suggesting Quality moves moderately in the same direction as Service and Selection; weak negative association with Price (0.23), Cleanliness (0.38), Atmosphere (0.32), Convenience (0.24), Location (0.15), and Staff (0.18) suggesting Quality moves slowly in the same direction as Price, Cleanliness, Atmosphere, Convenience, Location, and Staff; and weak negative association (-0.05) with Wait time suggesting Quality moves slowly in opposite direction as Wait time.
"Service" has moderate positive association with Selection (0.65), Cleanliness (0.51), Atmosphere (0.46), and Staff (0.62) suggesting Service moves moderately in the same direction as Selection, Cleanliness, Atmosphere, and Staff; and weak positive association with Price (0.12), Convenience (0.39), Location (0.28) and Wait time (0.21) suggesting Service moves slowly in the same direction as Price, Convenience, Location, and Wait time.
"Price" has weak positive association with Wait time (0.13) suggesting Price moves slowly with Wait time; and weak negative association with Selection (-0.35), Cleanliness (-0.26), Convenience (-0.15), Atmosphere (-0.20), Location (0.09), and Staff (-0.08) suggesting Service moves slowly in opposite direction as Selection, Cleanliness, Convenience, Atmosphere, Location, and Staff.
"Selection" has moderate positive association with Cleanliness (0.43) suggesting Selection moves moderately in the same direction as Cleanliness; weak negative association with Atmosphere (0.38), Convenience (0.31), Location (0.22), and Staff (0.23) suggesting Selection moves slowly in the same direction as Atmosphere, Convenience, Location, and Staff; and weak negative association with Wait time (-0.10) suggesting Service moves slowly in opposite direction as Wait time.
"Cleanliness" has moderate positive association with Atmosphere (0.49) suggesting Cleanliness moves moderately in the same direction with Atmosphere; weak positive association with Convenience (0.36), Location (0.15), and Staff (0.29) suggestion Cleanliness moves slowly in the same direction as Convenience, Location, and Staff; and weak negative association with Wait time (-0.05) suggesting Cleanliness moves slowly in opposite direction as Wait time.
"Atmosphere" has weak positive association with Convenience (0.27), Location (0.18), and Staff (0.25) suggestion Atmosphere moves slowly in the same direction as Convenience, Location, and Staff; and weak negative association with Wait time (-0.08) suggesting Atmosphere moves slowly in opposite direction as Wait time.
"Convenience" has weak positive association with Location (0.30), and Staff (0.21) suggestion Atmosphere moves slowly in the same direction as Location, and Staff; and weak negative association with Wait time (-0.15) suggesting Convenience moves slowly in opposite direction as Wait time.
"Location" has weak positive association with Staff (0.18) suggestion Location moves slowly in the same direction as Staff; and weak negative association with Wait time (-0.13) suggesting Cleanliness moves slowly in opposite direction as Wait time.
"Staff" has weak positive association with Staff (0.12) suggestion Wait time moves slowly in the same direction as Wait time.
# Perform sentiment analysissentiment <- inner_join(as.data.frame(dtm), customer_data, by = c("row.names" = "feedback"))sentiment <- sentiment[, c("row.names", "SentimentScore")]
# Perform topic modelinglda <- LDA(dtm, k = 5) # Adjust the number of topics (k) as needed
# Extract topics from the modeltopics <- tidy(lda, matrix = "beta")topics <- topics %>% group_by(topic) %>% top_n(10, beta) %>% ungroup()
# Perform entity extractionentities <- corpus %>% unnest_tokens("entity", input = text) %>% anti_join(stop_words)
# Save the resultswrite.csv(sentiment, "sentiment_analysis_results.csv", row.names = FALSE)write.csv(topics, "topic_modeling_results.csv", row.names = FALSE)write.csv(entities, "entity_extraction_results.csv", row.names = FALSE)
Business Statistics A Decision Making Approach
ISBN: 9780133021844
9th Edition
Authors: David F. Groebner, Patrick W. Shannon, Phillip C. Fry