r - CSV Data frame column show incorrect class name
问题描述
Date;Hours;Turnover
01/01/2015;00 - 01;37403.9
01/01/2015;00 - 01;37403.10
01/01/2015;00 - 01;37403.11
01/01/2015;00 - 01;37403.12
01/01/2015;00 - 01;37403.13
01/01/2015;00 - 01;37403.14
01/01/2015;00 - 01;37403.15
01/01/2015;00 - 01;37403.16
01/01/2015;00 - 01;37403.17
01/01/2015;00 - 01;37403.18
01/01/2015;00 - 01;37403.19
01/01/2015;00 - 01;37403.20
01/01/2015;00 - 01;37403.21
01/01/2015;00 - 01;37403.22
01/01/2015;00 - 01;37403.23
01/01/2015;00 - 01;37403.24
01/01/2015;00 - 01;37403.25
01/01/2015;00 - 01;37403.26
01/01/2015;00 - 01;37403.27
01/01/2015;00 - 01;37403.28
01/01/2015;00 - 01;37403.29
01/01/2015;00 - 01;37403.30
01/01/2015;00 - 01;37403.31
01/01/2015;00 - 01;37403.32
I have a CSV data frame
having three different columns one column consists of date(dd\mm\year) and second column consists of hours (24hours) and the third column consists of the demand value of electricity in each hour. I want to extract the third columns which include the numerical value only. But when I check the class of the selected column is shows me that it's a factor
so please help me why this happen and suggest the possible solution that's the class is numeric not a factor.
I save this CSV file as dem<- read.csv2("~/dem.data2.csv")
then I extract column three as dem1<- dem$Turnover
but when I check the class of the dem1
it gives factor.
解决方案
The problem is with decimal separator make think your number is a string. Use this line
dem<- read.csv("~/dem.data2.csv",sep=";",dec=".",stringsAsFactors = FALSE)
推荐阅读
- oracle - 创建表并看到此错误 - ORA-00907: 缺少右括号
- r - 使用“中介”库的因果中介
- javascript - setDrawRange 有什么作用?在 Three.js 中
- c - 为什么下面的代码打印垃圾值?
- python - 用于将字符串(字母数字)与python中的所有唯一字符匹配的正则表达式
- c++ - 需要帮助理解数组中最长连续项的算法
- c++ - QPainter 在指定矩形下方绘制文本
- node.js - NodeJS MVC - NoSQL 最佳实践
- reactjs - 子组件的反应路由设置
- webpack - 自定义 Ant Design 的主题:less-loader 的 'modifyVars' 选项中的那个 'hack' 键到底是什么?