Way to make a data frame
data fame is mostly used data structure which consists of columns(Variables) and rows(Cases)
1st way to make a data frame
> student<-c("Jane","Dora","Beth","Park")
> class<-c(1,3,2,2)
> height<-c(153,172,165,180)
> height_of_students<-data.frame(student,class,height)
> height_of_students
student class height
1 Jane 1 153
2 Dora 3 172
3 Beth 2 165
4 Park 2 180
'height_of_students' become the data frame which consists of 3 variables ('students,' 'class,' 'height') and 4 cases.
2nd way to make a data frame ( ※ stringsAsFactor=F)
> final_score<-data.frame(student=c("Jane","Dora","Beth","Park"),math=c(70,90,50,100), science=c(90,30,80,100),stringsAsFactors = F)
> final_score
student math science
1 Jane 70 90
2 Dora 90 30
3 Beth 50 80
4 Park 100 100
'final_score' becomes the data frame which consists of 3 variables('student,' 'math,' 'science,') and 4 cases('Jane,' 'Dora,' 'Beth,' 'Park')
'R' 카테고리의 다른 글
(R) ifelse() (0) | 2020.07.23 |
---|---|
(R) make a summary - group_by(),summarise() (0) | 2020.07.22 |
R reorder() -reorder columns in ascending order, descending order when setting aes() (0) | 2020.07.21 |
(R) geom_col() VS geom_bar() (0) | 2020.07.20 |
Interpret data frame/ summary(), typeof(), str(), class(),View(),names(),ncol(),length(),nrow(),dim() (0) | 2020.07.16 |