Convert dataframe column to vector in R
In this article, we will discuss how to convert a DataFrame column to vector in R Programming Language. To extract a single vector from a data frame in R Programming language, as.vector() function can be used.
Syntax: as.vector( data_frame$column_name )
- data_frame is the name of the data frame
- column_name is the column to be extracted
Given below are some implementations for this.
 “Ram” “Shayam” “Mohan” “Kailash” “Aditya”
We can now examine whether the returned column is a vector or not, by passing it to the function is.vector() which returns a Boolean value i.e. either true or false.
We will extract the Species column from the well-known data frame Iris using as.vector( ) function and print it. We will also check whether the returned column is a vector or not.