1
我有一個推文數據框,我想添加一個不存在的「retweetCount」列。我使用了以下內容:將retweetCount列添加到R中的數據框中
tweets$retweetCount <- tweets %>%
group_by(text) %>%
summarize(count = n())
這引發以下錯誤:
Error in `$<-.data.frame`(`*tmp*`, retweetCount, value = list(text = c("-
#WetterOnline Pro by @WetterOnline #Wetter #Berlin, :
replacement has 48780 rows, data has 137659
看來,我無法計算在沒有轉推的情況下「retweetCount」的值。
head(data):
id_str <chr>, from_user <chr>, text <chr>, created_at <chr>, time <chr>,
geo_coordinates <chr>,user_lang <chr>, in_reply_to_user_id_str <chr>,
in_reply_to_screen_name <chr>,from_user_id_str <chr>,
in_reply_to_status_id_str <chr>, source <chr>,profile_image_url <chr>,
user_followers_count <int>, user_friends_count <int>,user_location <chr>,
status_url <chr>, entities_str <chr>, date <date>
dput(data)
.Names = c("id_str", "from_user", "text",
"created_at", "time", "geo_coordinates", "user_lang",
"in_reply_to_user_id_str",
"in_reply_to_screen_name", "from_user_id_str", "in_reply_to_status_id_str",
"source", "profile_image_url", "user_followers_count", "user_friends_count",
"user_location", "status_url", "entities_str", "date", "ehe",
"eggheads"), row.names = c(NA, -137659L), class = c("tbl_df",
"tbl", "data.frame"))
難道您發佈的數據或它的一個樣本,以便W¯¯可以幫助你嗎? –