动态使用atter功能
考虑到以下数据框架,
df<-data.frame(a=c(1,2,3))
我可以通过这样做来显示它:
df
或者
get("df")
,我可以通过执行此操作给予属性:
attr(df,"anyAttribute")<-"df attribute"
attributes(df)
$names
[1] "a"
$class
[1] "data.frame"
$row.names
[1] 1 2 3
$anyAttribute
[1] "df attribute"
有什么方法可以动态地赋予数据帧吗?我想要的就是这样:
> attr(get("df"),"anyAttribute")<-"df attribute"
Error in attr(get("df"), "anyAttribute") <- "df attribute" :
destino de la asignación se expande a un objeto fuera del lenguaje
Considering the following data frame
df<-data.frame(a=c(1,2,3))
I can show it by doing:
df
or
get("df")
Also, I can give an attribute to it by doing this:
attr(df,"anyAttribute")<-"df attribute"
attributes(df)
$names
[1] "a"
$class
[1] "data.frame"
$row.names
[1] 1 2 3
$anyAttribute
[1] "df attribute"
Is there any way to give attributes to dataframes dynamically?. What I want is something like this:
> attr(get("df"),"anyAttribute")<-"df attribute"
Error in attr(get("df"), "anyAttribute") <- "df attribute" :
destino de la asignación se expande a un objeto fuera del lenguaje
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的意思是吗?
Do you mean this?
我们可以使用
分配
更新原始对象-Output
We can use
assign
to update the original object-output