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

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)
主站蜘蛛池模板: 无为县| 若尔盖县| 杭州市| 姚安县| 拜城县| 祁东县| 沙雅县| 大埔区| 孟州市| 葫芦岛市| 满洲里市| 青冈县| 安义县| 连云港市| 绵阳市| 思南县| 盱眙县| 河北省| 剑川县| 丹棱县| 曲靖市| 沙田区| 银川市| 航空| 洛阳市| 定西市| 樟树市| 平遥县| 蒲城县| 邛崃市| 江华| 容城县| 黄浦区| 江源县| 交口县| 岳池县| 渝北区| 阳信县| 黔西县| 宿松县| 通榆县|