- 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程序設計簡明教程(第二版)
- Building a RESTful Web Service with Spring
- Magento 2 Theme Design(Second Edition)
- R語言游戲數據分析與挖掘
- Internet of Things with the Arduino Yún
- Hands-On C++ Game Animation Programming
- Cocos2d-x學習筆記:完全掌握Lua API與游戲項目開發 (未來書庫)
- Kotlin編程實戰:創建優雅、富于表現力和高性能的JVM與Android應用程序
- OpenResty完全開發指南:構建百萬級別并發的Web應用
- Learning Continuous Integration with TeamCity
- AMP:Building Accelerated Mobile Pages
- Xamarin Cross-Platform Development Cookbook
- Using Yocto Project with BeagleBone Black
- 精益軟件開發管理之道
- Java Web 從入門到項目實踐(超值版)