i have an issue while try to filtering a df and I don´t understand why. The problem is just as simple as this:
view(df)
class(df)
.class2(df[[1]])
df
f <- df[df[,1] == 1,]
f
with the following output:
> class(df)
[1] "data.frame"
> .class2(df[,1])
[1] "double" "numeric"
> df
cod uncod
1 -0.8333333 0.040
2 -0.8333333 0.040
3 -0.8333333 0.040
4 -0.8333333 0.040
5 -1.0000000 0.038
6 -1.0000000 0.038
7 1.0000000 0.062
8 1.0000000 0.062
9 -0.8333333 0.040
10 -0.8333333 0.040
11 -0.8333333 0.040
> f <- df[df[,1] == 1,]
> f
[1] cod uncod
<0 Zeilen> (oder row.names mit Länge 0)
while doing this works fine:
f <- df[df[,1] == -1,]
> f
cod uncod
5 -1 0.038
6 -1 0.038
>
I really don´t understand what´s happening since it is working with a new data.frame:
df2<-data.frame(cod=c(-0.83,-1,0,1),uncod=c(0.040,0.038,0.05,0.062))
> f2 <- df[df[,1] == 1,]
> f2
cod uncod
4 1 0.062
>
What is wrong with my first df? Sorry that I don´t have a representative example but the data.frame is coming out of a bigger code.