[R] Question about levels/as.numeric
Petr Savicky
savicky at praha1.ff.cuni.cz
Mon Apr 11 08:18:36 CEST 2011
On Sun, Apr 10, 2011 at 05:47:59PM +0200, Thibault Vatter wrote:
> Hi,
>
> I am still new to R and this is my first post on this mailing-list.
>
> I have two .csv (each one being a column of real numbers) coming from the
> same database (the first one is just longer than the second) and I read them
> in R the following way:
>
> returns <- read.csv("test.csv", header = FALSE)
> returns2 <- read.csv("test2.csv", header = FALSE)
>
> However, the two objects clearly don't seem to be equivalent:
>
> > returns[2528:2537,1]
> [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453
> 0.002676 0.001334 -0.011326
> 7470 Levels: -0.000078 -0.000085 -0.000086 -0.0001 -0.000112 -0.000115
> -0.000152 -0.000154 -0.000157 -0.00016 -0.000171 -0.000185 -0.000212
> -0.000238 -0.000256 -0.000259 -0.000263 -0.000273 ... C
There is probably a non-numeric row in the data. In order to locate this
row, try the following
which(is.na(as.numeric(as.character(returns[, 1]))))
This will show the indices of the rows, which cannot be converted
to numeric type.
Petr Savicky.
More information about the R-help
mailing list