r - Rainfall data, can't get value of table? -
i tried analyse rainfall data. problem have data in format:
head(dati) x x.1 x.2 x.3 1. stat 2. stat 3.stat 4. stat 5. stat 2 2013 1 val01 00:00 0 0.7 0.2 3 2013 1 val01 01:00 0 0.5 0.2 4 2013 1 val01 02:00 0 0 0.2 5 2013 1 val01 03:00 0 0 0 6 2013 1 val01 04:00 0 0 0.1 7 2013 1 val01 05:00 0 0 0
as see there spaces in columns, , when try dati[1,5]
[1] 0.7 53 levels: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 ... hprab
i understand need 1 number: 0.7. how can , why there information levels?
my code was:
dati<-read.csv2("precipitation.csv", header = true,row.names=null, sep = ";", quote = "", dec = "," , fill = true, comment.char = "") attach(dati) dati[1,1] [1] 2013 > dati[1,6] [1] 0.7 53 levels: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 ... hprab > dati[1,3] [1] val01 32 levels: val01 val02 val03 val04 val05 val06 val07 val08 val09 val10 val11 val12 ... val31 > dati[1,4] [1] 00:00 25 levels: 00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 ... 23:00 >
resolved! next code works correctly!
dati<-read.csv2("precipitation.csv", header = true,row.names=null, sep = ";", quote = "", dec = "," , fill = true, comment.char = "") attach(dati) as.numeric(as.character(dati[1,i]))
you information levels because columns stored factor
s (see ?factor
). can use as.numeric(as.character(df$yourcolumn))
convert factor numeric (where df
data.frame , yourcolumn
column want convert).
check see if have characters (other na) in columns, because r interpret data numbers (and na) numeric.
Comments
Post a Comment