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

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)
主站蜘蛛池模板: 铜山县| 河北区| 桃园市| 上高县| 枣庄市| 钟祥市| 西乌| 富蕴县| 颍上县| 新乡县| 七台河市| 石景山区| 琼结县| 烟台市| 繁昌县| 富平县| 桐城市| 山丹县| 甘泉县| 乃东县| 新巴尔虎左旗| 北辰区| 鲜城| 烟台市| 莒南县| 叶城县| 抚松县| 台山市| 乌恰县| 邢台县| 闻喜县| 淮北市| 深州市| 新巴尔虎左旗| 盐池县| 崇信县| 赤壁市| 长岛县| 双城市| 五台县| 台中县|