If you have a variable x
with a column name in tmp
, tmp[,x]
or tmp[[x]]
are the correct ways to extract it. You cannot get R to treat tmp$x
as tmp$"Q5.3"
. tmp$x
will always refer to the item named “x” in “tmp”.
More Related Contents:
- Dynamically select data frame columns using $ and a character value
- Simultaneously merge multiple data.frames in a list
- Count number of rows within each group
- Drop unused factor levels in a subsetted data frame
- Why is it not advisable to use attach() in R, and what should I use instead?
- Create an empty data.frame
- Merging a lot of data.frames [duplicate]
- Create a group number for each consecutive sequence
- Subset data frame based on multiple conditions [duplicate]
- dplyr: nonstandard column names (white space, punctuation, starts with numbers)
- R – Concatenate two dataframes?
- Calculating statistics on subsets of data [duplicate]
- Identifying duplicate columns in a dataframe
- R pass variable column indices to ggplot2 [duplicate]
- Get last row of each group in R [duplicate]
- Same function over multiple data frames in R
- Create empty data frame with column names by assigning a string vector? [duplicate]
- Dataframe create new column based on other columns
- What is about the first column in R’s dataset mtcars?
- Last Observation Carried Forward In a data frame? [duplicate]
- finding close match from data frame 1 in data fame 2
- What is difference between dataframe and list in R?
- Define dimensions of an empty dataframe
- Merge overlapping ranges into unique groups, in dataframe
- Reshape a dataframe to long format with multiple sets of measure columns [duplicate]
- Count unique values for every column
- Numbers as column names of data frames
- Divide each value by the sum of values by group
- Convert all data frame character columns to factors
- Override column types when importing data using readr::read_csv() when there are many columns