|
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 listIn this method, we are going to create a vector with character (names) and integer(marks) type data and passing to the student dataframe. Similarly, we will pass these two vectors to the list and display them. Syntax:
Example: R
Output: Method 2: Using $$ operator in R is used to extract a specific part of data or access a variable in a dataset. We can pass data frame column to a list by using $ operator. The columns to be selected are to be passed with dataframe name separated by $. Syntax:
Example: R
Output: We can extract more than one column using the same approach and then again pass it to the list() function. Example: R
Output: Example : R
Output : We can extract elements from a specific column in a list. |
Reffered: https://www.geeksforgeeks.org
R Language |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |