I'm trying to build a data frame consisting of three character variables and one numeric variable. When I run the following code, I get a four-column matrix, but the score variable is no longer numeric, and the scores are treated as factors.
school<-c("NYU", "BYU", "USC", "FIT", "UNH","UCLA","USF","Columbia")
state<-c("NY","UT","CA","NY","NY","CA", "CA","NY")
measure<-c("MSAT","MSAT","GPA","MSAT","MSAT","GPA","GPA","GPA")
score<-c(500, 490, 2.9, 759, 550, 1.2, 3.1, 3.2)
data<-cbind(school,state, measure,score)
If I run
data1<-data.frame(cbind(school,state, measure,score))
I get a data frame where score
is still a factor. How can I build this data frame so that score
is numeric?
data.frame()
directly, withoutcbind
. – Frenulum