简体   繁体   中英

Data Frame Initialization - Character Initialization read as Factors?

I am trying to initialize a data frame like this as I would like to have an empty data frame with two character vectors as columns

out_frame<-data.frame(Hospital = character(), State = character()

However, when I look at class of each column for this data frame, it shows a factor? What am I doing wrong here?

The data.frame function takes the following argument "stringsAsFactors". By default it is set to TRUE. Set it to FALSE to keep character from being cast to factors.

out_frame <- data.frame(Hospital = character(), State = character(), stringsAsFactors = FALSE)
str(out_frame)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM