R interpreting variable in data frame as factor; it isn't

前端 未结 2 466
轮回少年
轮回少年 2021-01-22 10:41

I imported a csv into R and it considers my variable FERNH a factor; it isn\'t. I can\'t figure out why or how to fix it. I have reviewed the values in FERNH and they appear t

2条回答
  •  清酒与你
    2021-01-22 11:13

    There is a character value in there somewhere so R is acting as expected. Look at levels(height$FERNH) to see the offending value. You can set stringsAsFactors=FALSE on your read step or via options, but then the column will be a character rather than integer.

    While that may seem annoying at first, it is an excellent data quality check as well as significant memory savings if the character column contains long strings.

提交回复
热议问题