- Modern R Programming Cookbook
- Jaynal Abedin
- 113字
- 2021-07-08 09:48:32
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)
推薦閱讀
- C++案例趣學(xué)
- AngularJS Testing Cookbook
- arc42 by Example
- Oracle Database In-Memory(架構(gòu)與實(shí)踐)
- Software Testing using Visual Studio 2012
- Python Game Programming By Example
- 從0到1:Python數(shù)據(jù)分析
- 程序設(shè)計(jì)基礎(chǔ)教程:C語(yǔ)言
- Hands-On Full Stack Development with Go
- PLC應(yīng)用技術(shù)(三菱FX2N系列)
- 西門(mén)子S7-200 SMART PLC編程從入門(mén)到實(shí)踐
- Mastering Git
- Android Development Tools for Eclipse
- 嵌入式Linux C語(yǔ)言程序設(shè)計(jì)基礎(chǔ)教程
- Learning D