[英]use variable name instead of column name in R function
In this: 在此:
y <- svytable(~date4a, design = Pew.w)
date4a
is a column name. date4a
是列名。
I want to replace date4a
with a variable. 我想用一个变量替换
date4a
。 The variable of course, will refer to a column name. 当然,该变量将引用列名。
Eg something like: 例如:
col <- "date4a"
y <- svytable(~col, design = Pew.w) #This doesnt' work
How may I do that? 我该怎么办?
Under the assumption that this is something that is really worth doing, you could try: 假设这确实是值得做的,则可以尝试:
col <- my.data.frame$date4a
y <- svytable(~col, design=Pew.w)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.