hi netters,
i have a dataframe TEST like this:
Y1 Y2 Y3
X1 4 7 8
X2 6 2 Z
X3 8 0 1
i would like to change it to a numeric matrix, replacing Z with NA
Y1 Y2 Y3
X1 4 7 8
X2 6 2 NA
X3 8 0 1
i've tried the function data.matrix but it didn't work. is there any easy
way to
A way to do it :
TEST$Y3[TEST$Y3==Z] - NA
TEST$Y3 - as.numeric(TEST$Y3)
2005/12/8, zhihua li [EMAIL PROTECTED]:
hi netters,
i have a dataframe TEST like this:
Y1 Y2 Y3
X1 4 7 8
X2 6 2 Z
X3 8 0 1
i would like to change it to a numeric matrix, replacing Z with NA
Y1 Y2
and then, if you want a matrix and not a data.frame :
TEST - as.matrix(TEST)
2005/12/8, David Hajage [EMAIL PROTECTED]:
A way to do it :
TEST$Y3[TEST$Y3==Z] - NA
TEST$Y3 - as.numeric(TEST$Y3)
2005/12/8, zhihua li [EMAIL PROTECTED]:
hi netters,
i have a dataframe TEST like this:
you probably have a dataframe like this :
z - data.frame(y1=c(1,2,3),y2=c(4,5,6),y3=c(4,z,5))
you can do :
z - as.matrix(z)
mode(z) - numeric
zhihua li a écrit :
hi netters,
i have a dataframe TEST like this:
Y1 Y2 Y3
X1 4 7 8
X2 6 2 Z
X3 8 0 1
i would like to change it to a