Re: [R] setting a number of values to NA over a data.frame.

2007-02-12 Thread Gregor Gorjanc
Jim Lemon jim at bitwrit.com.au writes: Hi John, You might have a look at toNA in the prettyR package. Wait for version 1.0-4, just uploaded, as I have fixed a bug in that function. There is also a set of generic functions exactly for such cases: unknownToNA(), NAToUnknown() and isUnknown()

Re: [R] setting a number of values to NA over a data.frame.

2007-02-12 Thread John Kane
--- Gregor Gorjanc [EMAIL PROTECTED] wrote: Jim Lemon jim at bitwrit.com.au writes: Hi John, You might have a look at toNA in the prettyR package. Wait for version 1.0-4, just uploaded, as I have fixed a bug in that function. There is also a set of generic functions exactly for

Re: [R] setting a number of values to NA over a data.frame.

2007-02-09 Thread John Kane
--- Petr Pikal [EMAIL PROTECTED] wrote: Hi Strange. It works for me without any problem. The problem is that my dataframe has 1,s in about 50% of the columns and I only want it to apply to a few specified columns. My explanation may not have been clear enough. Using your example,I want all

Re: [R] setting a number of values to NA over a data.frame.

2007-02-09 Thread Charilaos Skiadas
Once again I forgot to reply to the whole list On Feb 9, 2007, at 8:39 AM, Charilaos Skiadas wrote: On Feb 9, 2007, at 8:13 AM, John Kane wrote: The problem is that my dataframe has 1,s in about 50% of the columns and I only want it to apply to a few specified columns. My explanation may

Re: [R] setting a number of values to NA over a data.frame.

2007-02-09 Thread Petr Pikal
Hi but you can easily extend it to only several columns data[, col.selection] [data[, col.selection]==1]-NA so in my case zeta[,2] [zeta[,2] == 1] - NA shall change only 1 in column 2 to NA (not tested) HTH Petr On 9 Feb 2007 at 8:13, John Kane wrote: Date sent: Fri, 9 Feb

Re: [R] setting a number of values to NA over a data.frame.

2007-02-09 Thread John Kane
--- Jim Lemon [EMAIL PROTECTED] wrote: John Kane wrote: This is probably a simple problem but I don't see a solution. I have a data.frame with a number of columns where I would like 0 - NA Hi John, You might have a look at toNA in the prettyR package. Wait for version

Re: [R] setting a number of values to NA over a data.frame.

2007-02-08 Thread Jim Lemon
John Kane wrote: This is probably a simple problem but I don't see a solution. I have a data.frame with a number of columns where I would like 0 - NA Hi John, You might have a look at toNA in the prettyR package. Wait for version 1.0-4, just uploaded, as I have fixed a bug in that

Re: [R] setting a number of values to NA over a data.frame.

2007-02-08 Thread Petr Pikal
Hi Strange. It works for me without any problem. zeta tepl tio2 al2o3 iep 1 601 3.5 5.65 2 601 2.0 5.00 3 601 1.0 5.30 4 600 2.0 4.65 5 401 3.5 5.20 6 401 2.0 4.85 7 400 3.5 5.70 8 400 2.0 5.25 zeta[zeta==1]-NA zeta tepl

[R] setting a number of values to NA over a data.frame.

2007-02-07 Thread John Kane
This is probably a simple problem but I don't see a solution. I have a data.frame with a number of columns where I would like 0 - NA thus I have df1[,144:157] - NA if df1[, 144: 157] ==0 and df1[, 190:198] - NA if df1[, 190:198] ==0 but I cannot figure out a way do this. cata - c(

Re: [R] setting a number of values to NA over a data.frame.

2007-02-07 Thread Erik Iverson
John - Your initial problem uses 0, but the example uses 1 for the value that gets an NA. My solution uses 1 to fit with your example. There may be a better way, but try something like data1[3:5] - data.frame(lapply(data1[3:5], function(x) ifelse(x==1, NA, x))) The data1[3:5] is just a

Re: [R] setting a number of values to NA over a data.frame.

2007-02-07 Thread John Kane
Works beautifully. I modified it a bit to handle the discontinous ranges to: a - c(3:4, 8) data1[a] - data.frame(lapply(data1[a], function(x) ifelse(x==1, NA, x))) There may be a prettier way to handle the disconituity but this works so it looks like I'm in good shape. I had looked at