Skip to content
Prev 386703 / 398502 Next

Passing variable name

Hello,

Or maybe V1 and V2 are variables that hold column names?
If so see thess StackOverflow posts [1], [2]. The trick is to use [[, 
not $ to extractthe columns.


V1 <- "Gender"
V2 <- "Hand"

MyT2 <- table(MyData[[V1]], MyData[[V2]])


[1]: 
https://stackoverflow.com/questions/18222286/dynamically-select-data-frame-columns-using-and-a-vector-of-column-names

[2]: 
https://stackoverflow.com/questions/1169456/the-difference-between-bracket-and-double-bracket-for-accessing-the-el


Hope this helps,

Rui Barradas


?s 21:48 de 27/12/20, Jim Lemon escreveu: