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

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)
主站蜘蛛池模板: 寿宁县| 来安县| 东乌珠穆沁旗| 磴口县| 河津市| 麟游县| 尉犁县| 牡丹江市| 图片| 宾阳县| 杭州市| 垣曲县| 西峡县| 乌兰浩特市| 南康市| 宣武区| 柳江县| 阿勒泰市| 郁南县| 民丰县| 积石山| 于都县| 昌邑市| 海口市| 香港| 丰都县| 龙井市| 奉节县| 屏山县| 永宁县| 孟村| 朔州市| 华阴市| 吴堡县| 离岛区| 丽水市| 武平县| 文水县| 大兴区| 德江县| 驻马店市|