I’m going to attempt to explain this without making any mistakes, but I’m betting this will attract a clarification or two in the comments.
A data frame is a list. When you subset a data frame using the name of a column and [, what you’re getting is a sublist (or a sub data frame). If you want the actual atomic column, you could use [[, or somewhat confusingly (to me) you could do aframe[,2] which returns a vector, not a sublist.
So try running this sequence and maybe things will be clearer:
avector <- as.vector(aframe['a2']) class(avector) avector <- aframe[['a2']] class(avector) avector <- aframe[,2] class(avector)
Related Posts:
- Converting from a character to a numeric data frame
- Counting the number of elements with the values of x in a vector
- Create empty data frame with column names by assigning a string vector?
- How to remove outliers from a dataset
- Insert a blank column in dataframe
- pandas dataframe convert column type to string or categorical
- Convert data.frame columns from factors to characters
- dplyr: “Error in n(): function should not be called directly”
- Error in eval(expr, envir, enclos) : object not found
- How do I convert a factor into date format?
- Write lines of text to a file in R
- scale_fill_discrete and scale_fill_manual – legend options confusion
- ‘Incomplete final line’ warning when trying to read a .csv file into R
- Conditional mean statement
- R error: “New Column would leave holes after existing columns”
- Warning in GLM analysis
- What does ‘length of ‘dimnames’ [1] not equal to array extent’ mean?
- How do I flip rows and columns in R
- How to catch integer(0)?
- “no function to return from, jumping to top level”
- r random forest error – type of predictors in new data do not match
- env=baseenv() in R
- Sample random rows in dataframe
- Removing punctuations from text using R
- How to find out which package version is loaded in R?
- How to solve it. error:Error in data[[rowvar]] : attempt to select less than one element
- Gradient of n colors ranging from color 1 and color 2
- How to prevent scientific notation in R?
- What is the difference between require() and library()?
- How to declare a vector of zeros in R
- R Sweave: NO TeX installation detected
- ERROR: [on_request_read] connection reset by peer in R shiny
- Error in as.vector(x, mode) : cannot coerce type ‘closure’ to vector of type ‘any’
- Suppress output of a function
- Error in G * t(hat) : non-conformable arrays
- Error: isTRUE(gpclibPermitStatus()) is not TRUE
- How to counter the ‘non-numeric matrix extent’ error in R?
- What does is.na() applied to non-(list or vector) of type ‘NULL’ mean?
- error r: invalid subscript type “closure” in a simple regression
- Merge two rows in data.frame
- r function unzip error 1 in extracting from zip file
- Get the list of installed packages by user in R
- Colour points in a plot differently depending on a vector of values
- How to access the last value in a vector?
- increase legend font size ggplot2
- Mask output of `The following objects are masked from….:` after calling attach() function
- How To Create Vector of Vector In R
- Use of ~ (tilde) in R programming Language
- Construct a manual legend for a complicated plot
- Code to clear all plots in RStudio
- Error: x must be atomic for ‘sort.list’
- How can I change the name of a data frame
- Installing R on Android
- Transposing in dplyr
- Does the c command create a row vector or a column vector by default in R
- Error in summary.connection(connection) : invalid connection
- How to create lag variables
- When trying to replace values, “missing values are not allowed in subscripted assignments of data frames”
- How do I convert a String to an int in Java?
- R Hex to RGB converter
- how to sort pandas dataframe from one column
- Renaming column names in Pandas
- How to reset index in a pandas dataframe? [duplicate]
- How to implement 2D vector array?
- how to reset index pandas dataframe after dropna() pandas dataframe
- Delete a column from a Pandas DataFrame
- How to deal with SettingWithCopyWarning in Pandas
- How to deal with SettingWithCopyWarning in Pandas
- Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”
- How to iterate over rows in a DataFrame in Pandas
- How to iterate over rows in a DataFrame in Pandas
- How to convert string to char array in C++?
- Easiest way to convert int to string in C++
- Writing a pandas DataFrame to CSV file
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Error: ‘int’ object is not subscriptable – Python
- Selecting multiple columns in a Pandas dataframe
- Vector of Vectors to create matrix
- How can I convert String to Int?
- How to convert string to char array in C++?
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Get statistics for each group (such as count, mean, etc) using pandas GroupBy?
- How to convert a char to a String?
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Writing a pandas DataFrame to CSV file
- Convert String to double in Java
- How to find out if an item is present in a std::vector?
- Adding new column to existing DataFrame in Python pandas
- How to change the order of DataFrame columns?
- How do I print out the contents of a vector?
- How can I convert a char to int in Java? [duplicate]
- SQL error “ORA-01722: invalid number”
- How to change the order of DataFrame columns?
- Pandas DataFrame Groupby two columns and get counts
- How can I use the apply() function for a single column?
- How to show all columns’ names on a large pandas dataframe?
- How to groupby based on two columns in pandas?
- How to deal with SettingWithCopyWarning in Pandas
- numpy matrix vector multiplication
- How do I parse a string to a float or int?