How to extract column from data frame as vector in R ? Last Updated : 07 Apr, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we are going to convert dataframe column into a vector in R Programming Language. Steps -Create vectorsCreate a dataframe by passing these vectorsConvert dataframe column using"[[]]" operator (indexing). [[]] is used to access the dataframe column.It is used to index the dataframe. Syntax: dataframe_name[['column_name']] Display vectors Example 1: R # creating a vector for names names=c('siva nagulu','bhavanarayana','sireesha', 'priyank chowdary','sridevi','ravi kumar') # creating a vector for ages ages=c(40,49,38,42,36,39) #create a dataframe using these vectors dataframe=data.frame(names,ages) print(dataframe) # converting ages dataframe column into vector # by passing as index my_data = dataframe[['names']] print("--------convert into vector of names column-------") print(my_data) my_data = dataframe[['ages']] print("--------convert into vector of ages column-------") print(my_data) Output: Example 2: R # creating a vector for city city=c('kakumanu','hyd','noida') # create a dataframe using this vector dataframe=data.frame(city) print(dataframe) # converting city dataframe column into vector # by passing as index my_data = dataframe[['city']] print("--------convert into vector of city column-------") print(my_data) Output: Comment More infoAdvertise with us Next Article How to extract column from data frame as vector in R ? G gottumukkalabobby Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads How to Extract a Column from R DataFrame to a List ? In this article, we will discuss how to extract a column from a DataFrame to a List in R Programming Language. Method 1: Converting all columns to list In this method, we are going to create a vector with character (names) and integer(marks) type data and passing to the student dataframe. Similarly, 2 min read How to add column to dataframe in R ? In this article, we are going to see how to add columns to dataframe in R. First, let's create a sample dataframe. Adding Column to the DataFrame We can add a column to a data frame using $ symbol. syntax: dataframe_name $ column_name = c( value 1,value 2 . . . , value n)Â Here c() function is a vec 2 min read How to create a DataFrame from given vectors in R ? In this article we will see how to create a Dataframe from four given vectors in R. To create a data frame in R using the vector, we must first have a series of vectors containing data. The data.frame() function is used to create a data frame from vector in R. Syntax: data.frame(vectors) Example 1. 2 min read How to convert Excel column to vector in R ? In this article, we will be looking at the different approaches to convert the Excel columns to vector in R Programming language. The approaches to convert Excel column to vector in the R language are listed as follows: Using $-Operator with the column name.Using the method of Subsetting column.Usin 3 min read Extract vector from dataframe in R In this article, we will see how to extract vectors from DataFrame in R Programming Language. The approach is simple, by using $ operator, we can convert dataframe column to a vector. Syntax: dataframe_name$columnname Given below are various examples to implement the same Example 1: R # create vecto 1 min read Like