1.在此R代码中为什么使用stringsAsFactors = FALSE?
# Create the data frame.
emp.data <- data.frame(
emp_id = c (1:5),
emp_name = c("Rick","Dan","Michelle","Ryan","Gary"),
salary = c(623.3,515.2,611.0,729.0,843.25),
start_date = as.Date(c("2012-01-01", "2013-09-23", "2014-11-15", "2014-05- 11","2015-03-27")),
stringsAsFactors = FALSE
)
# Print the data frame.
print(emp.data)
所以员工的名字emp.date$emp_name
将是一个字符向量,而不是一个因子。
我建议您阅读更多有关factors https://stat.ethz.ch/R-manual/R-devel/library/base/html/factor.html了解为什么这很重要。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)