How to add a new column in the existing Data frame using R language
R Programming Language / Data Frames in R Language
506
In this question we will add a new column to an existing data frame
Here in the existing Data Frame
Student <- data.frame( RollNo = 1:10, Marks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100), PassOrFail = c(F, F, F, F, F, T, T, T, T, T))
In this Data Frame we will add a column StudentName
Program:
> StudentName <- c("Rumman", "Inza", "Jaman", "Azam", "Samser","Kamran","Roman", "Ali", "Ansar", "Sfik") > Student$StudentName <- StudentName
Output:
> str(Student) 'data.frame': 10 obs. of 4 variables: $ RollNo : int 1 2 3 4 5 6 7 8 9 10 $ Marks : num 10 20 30 40 50 60 70 80 90 95 $ PassOrFail : logi FALSE FALSE FALSE FALSE FALSE TRUE ... $ StudentName: chr "Rumman" "Inza" "Jaman" "Azam" ...
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about R Programming Language. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS