I'm not quite sure I understood the second queston but does this work?
subset(temp, xx$v2==-9)
subset(temp, xx$v2!= -9)
--- On Sun, 11/8/09, Ashta wrote:
> From: Ashta
> Subject: [R] look up and Missing
> To: r-h...@stat.math.ethz.ch
> Received: Sunday, November 8, 2009,
On Nov 8, 2009, at 11:08 AM, David Winsemius wrote:
On Nov 8, 2009, at 10:23 AM, Ashta wrote:
HI R-Users
Assume that I have a data frame 'temp' with several variables
(v1,v2,v3,v4,v5.).
v1 v2 v3 v4 v5
1 2 3 36
5 2 420
2 -9 5 43
6 2 1 34
1, I wa
Dear Ashta,
Is this what you want?
x <- read.table(textConnection("v1 v2 v3 v4 v5
1 2 3 36
5 2 420
2 -9 5 43
6 2 1 34"), header = TRUE)
closeAllConnections()
x
# Option 1
x1 <- x # copy of x just for this example
x1$v2[which(x1$v2 == -9)] <- NA
x
try this:
temp.new <- temp[temp$v2 != -9, ]
temp.new
I hope it helps.
Best,
Dimitris
Ashta wrote:
HI R-Users
Assume that I have a data frame 'temp' with several variables (v1,v2,v3,v4,v5.).
v1 v2 v3 v4 v5
1 2 3 36
5 2 420
2 -9 5 43
6 2 1 3
On Nov 8, 2009, at 10:23 AM, Ashta wrote:
HI R-Users
Assume that I have a data frame 'temp' with several variables
(v1,v2,v3,v4,v5.).
v1 v2 v3 v4 v5
1 2 3 36
5 2 420
2 -9 5 43
6 2 1 34
1, I want to look at the entire row values of when v2 =-9
Here is how to find out which rows contain -9 and then you can do with
it as you please:
> x
v1 v2 v3 v4 v5
1 1 2 3 3 6
2 5 2 4 2 0
3 2 -9 5 4 3
4 6 2 1 3 4
> which(apply(x, 1, function(.row) any(.row == -9)))
[1] 3
>
>
On Sun, Nov 8, 2009 at 10:23 AM, Ashta wrote:
> HI R-
HI R-Users
Assume that I have a data frame 'temp' with several variables (v1,v2,v3,v4,v5.).
v1 v2 v3 v4 v5
1 2 3 36
5 2 420
2 -9 5 43
6 2 1 34
1, I want to look at the entire row values of when v2 =-9
like
2 -9 5 43
I wrote
7 matches
Mail list logo