我有类似这样的很多tibbles的:R:应用功能dataframes的列表,并保存到工作区
dftest_tw <- structure(list(text = c("RT @BitMEXdotcom: A new high: US$500M turnover in the last 24 hours, over 80% of it on $XBTUSD. Congrats to the team and thank you to our u…",
"RT @Crowd_indicator: Thank you for this nice video, @Nicholas_Merten",
"RT @Crowd_indicator: Review of #Cindicator by DataDash: t.co/D0da3u5y3V"
), Tweet.id = c("896858423521837057", "896858275689398272", "896858135314538497"
), created.date = structure(c(17391, 17391, 17391), class = "Date"),
created.week = c(33, 33, 33)), .Names = c("text", "Tweet.id",
"created.date", "created.week"), row.names = c(NA, -3L), class = c("tbl_df",
"tbl", "data.frame"))
这里是我要适用于所有tibbles功能
编辑以下评论,我在函数中添加x作为最后一行
MyCount <- function(x){
x$retweet <- NA
x$custom <- NA
x$retweet <- grepl(retw, x$text) * 1
x$custom <- (grepl(cust, x$text) & !grepl(retw, x$text)) * 1
x
}
我的存取权限tibbles这样:
myUser_tw <- ls(,pattern = "_tw")
因为它们都是我环境中唯一以结尾的_tw。
现在,这里是我做的如何应用功能:
for (i in 1:length(myUserList_tw)){
lapply(mget(myUserList_tw), MyCount)
}
但实际上它不会改变任何东西。通过一次运行以下一个df将按照我的想法更改它们。打印结果为OK。
lapply(mget(myUser_tw[x]), MyCount)
现在我无法找到一种方法将结果分配给工作区中的df。我已经尝试了很多这样的事情:
myUser_tw[x] <- lapply(mget(myUser_tw[x]), MyCount)
或包括x <<- x
我的函数结束,但没有成功。
任何人都可以帮助我将修改后的df保存在我的工作区中?谢谢
mycount的没有返回'x',它返回'X $'定制和 –
你lapply没有分配到任何东西,所以没有变量发生变化 –
@Moody_Mudskipper感谢这个。我知道这是行不通的。你能帮我吗? – gabx