1

In this:

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

date4a is a column name.

I want to replace date4a 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?

4
  • 3
    In my opinion, don't. Youre only making your work harder to understand by breaking mental models of how R works. Commented Nov 22, 2016 at 1:48
  • @MatthewDrury Interesting. Thanks. Commented Nov 22, 2016 at 2:04
  • 2
    This is an R coding question, not a question about statistics. It is off topic here, but should be on topic on Stack Overflow. If you wait, we will migrate it for you. Commented Nov 22, 2016 at 2:12
  • 1
    @gung please migrate it, thanks. Commented Nov 22, 2016 at 3:08

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.