我已设置textInput以输入需要考虑操作的列名。我想将它与数据框中具有相同名称的现有列进行比较,以处理列下的元素。
答案 0 :(得分:0)
这是你想要做的吗?
#make some data
x <- c(1,2,3)
y <- c("a","b","c")
#put it in a dataframe
df <- data.frame(x,y)
#put the name of a column in a variable and access the column
textInput <- "x"
df[textInput]
x
1 1
2 2
3 3
#put the name of a column in a variable and access the column
textInput <- "y"
df[textInput]
y
1 a
2 b
3 c