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.
CodePudding user response:
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)