How to Create a data frame in R Programming Language

R Programming Language / Data Frames in R Language

492

Program:

# first Method
 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)
)

# Second Method 
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)
Student <- data.frame(RollNo, Marks, PassOrFail)

Output:

 > str(Student)
'data.frame':	10 obs. of  3 variables:
 $ RollNo    : int  1 2 3 4 5 6 7 8 9 10
 $ Marks     : num  10 20 30 40 50 60 70 80 90 100
 $ PassOrFail: logi  FALSE FALSE FALSE FALSE FALSE TRUE ...
 

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.