-5
我的數據集的頭像是這樣的。如何在R中找到group-wise的意思?
Hotel_name Review_Title Sentiment
1 Accord Metropolitan Excellent comfortableness during stay 3
2 Accord Metropolitan Excellent comfortableness during stay 3
3 Accord Metropolitan Excellent comfortableness during stay 3
4 Accord Metropolitan Excellent comfortableness during stay 3
5 Accord Metropolitan Excellent comfortableness during stay 3
6 Accord Metropolitan Not too comfortable 1
Rating_Percentage X X.1 X.2 X.3 word
1 100 NA NA NA nice
2 100 NA NA NA stay
3 100 NA NA NA business
4 100 NA NA NA tourist
5 100 NA NA NA purpose
6 20 NA NA NA hotel
我想找到每家酒店的平均情緒。像
HOTEL_NAME情緒
X 2.6
Ÿ2.2
我得到Na作爲輸出以及此警告。 –
1:在mean.default(Sentiment)中:參數不是數字或邏輯:返回不適用 –
這可能是因爲Sentiment不是數字變量(嘗試'class(data $ Sentiment)' - 我的猜測是它被讀入作爲一個因素?您可以將上述內容更新爲: 'data%>% mutate(Sentiment = as.numeric(Sentiment))%>% group_by(Hotel_name)%>% summary(mean_sentiment = mean(Sentiment)) ' – Lucy