user1883050 user1883050 - 1 year ago 72
R Question

use variable name instead of column name in R function

In this:

y <- svytable(~date4a, design = Pew.w)

is a column name.

I want to replace
with a variable. The variable of course, will refer to a column name.

E.g. something like:

col <- "date4a"

y <- svytable(~col, design = Pew.w) #This doesnt' work

How may I do that?

Answer Source

Under the assumption that this is something that is really worth doing, you could try:

col <-$date4a
y   <- svytable(~col, design=Pew.w)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download