官术网_书友最值得收藏!

There's more…

The data.frame() function has an optional argument stringsAsFactors, which prevents the character columns' automatic conversion into factors. A factor is another R data type that is used to represent categorical variables such as 1 for M and 2 for the F category. In the dataset that you have created using the data.frame() function, notice that the column GENDER is a factor type, though you did not explicitly mention it. Intuitively, the GENDER column should be a character column with values M and F. To prevent this automatic conversion, you must use stringsAsFactors=FALSE as follows:

    datB <- data.frame(ID = 1:5, hourSpetOnInternet = c(5,3,4,1,2),  
GENDER = c("M", "F", "F", "M", "F"), stringsAsFactors=FALSE)
主站蜘蛛池模板: 龙川县| 乳源| 望城县| 银川市| 日照市| 来宾市| 武山县| 昌邑市| 贵南县| 博湖县| 博湖县| 绵阳市| 益阳市| 宣汉县| 嘉禾县| 鄂伦春自治旗| 龙陵县| 威海市| 营山县| 自治县| 松滋市| 微山县| 且末县| 高密市| 天峻县| 枞阳县| 共和县| 虎林市| 宜宾市| 宣武区| 濉溪县| 仁布县| 扬州市| 房山区| 沭阳县| 大冶市| 锦屏县| 右玉县| 沂源县| 绥阳县| 板桥市|