Re: [R] substitute variable

2007-03-26 Thread Benilton Carvalho
condition1 | condition2 (or)
condition1 & condition2 (and)

tmp$PRODUCTS[tmp$PRODUCTS > 70 | tmp$PRODUCTS  < 20] <- NA

b

On Mar 26, 2007, at 12:47 PM, Sergio Della Franca wrote:

> Ok, this run correctly.
>
> Now i want to perform much more conditions, i.e.:
>
> tmp$PRODUCTS[tmp$PRODUCTS > 70] <- NA
>
> and
>
> tmp$PRODUCTS[tmp$PRODUCTS < 20] <- NA.
>
> How can i perform this double condition in the same code?
>
>
> 2007/3/26, Benilton Carvalho <[EMAIL PROTECTED]>: say your data  
> frame is called "tmp"
>
> tmp$PRODUCTS[tmp$PRODUCTS > 70] <- NA
>
> b
>
> On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote:
>
> > Dear R-Helpers,
> >
> > I want to substitute the contents of a variable under some  
> contitions.
> >
> > I.e., I have this data set:
> >
> > YEAR   PRODUCTS
> > 1  80
> > 2  90
> > 3  50
> > 4  60
> > 5  30
> >
> > I want to perform this condition:
> > if products> 70 then products=NA else products=products.
> >
> > I'd like to achive the seguent result:
> >
> >  YEAR   PRODUCTS
> > 1  NA
> > 2  NA
> > 3  50
> > 4  60
> > 5  30
> > How can i develop this?
> >
> >
> > Thank you in advance.
> >
> >
> > Sergio Della Franca
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute variable

2007-03-26 Thread Sergio Della Franca
Ok, this run correctly.

Now i want to perform much more conditions, i.e.:

tmp$PRODUCTS[tmp$PRODUCTS > 70] <- NA

and

tmp$PRODUCTS[tmp$PRODUCTS < 20] <- NA.

How can i perform this double condition in the same code?


2007/3/26, Benilton Carvalho <[EMAIL PROTECTED]>:
>
> say your data frame is called "tmp"
>
> tmp$PRODUCTS[tmp$PRODUCTS > 70] <- NA
>
> b
>
> On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote:
>
> > Dear R-Helpers,
> >
> > I want to substitute the contents of a variable under some contitions.
> >
> > I.e., I have this data set:
> >
> > YEAR   PRODUCTS
> > 1  80
> > 2  90
> > 3  50
> > 4  60
> > 5  30
> >
> > I want to perform this condition:
> > if products> 70 then products=NA else products=products.
> >
> > I'd like to achive the seguent result:
> >
> >  YEAR   PRODUCTS
> > 1  NA
> > 2  NA
> > 3  50
> > 4  60
> > 5  30
> > How can i develop this?
> >
> >
> > Thank you in advance.
> >
> >
> > Sergio Della Franca
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute variable

2007-03-26 Thread Benilton Carvalho
say your data frame is called "tmp"

tmp$PRODUCTS[tmp$PRODUCTS > 70] <- NA

b

On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote:

> Dear R-Helpers,
>
> I want to substitute the contents of a variable under some contitions.
>
> I.e., I have this data set:
>
> YEAR   PRODUCTS
> 1  80
> 2  90
> 3  50
> 4  60
> 5  30
>
> I want to perform this condition:
> if products> 70 then products=NA else products=products.
>
> I'd like to achive the seguent result:
>
>  YEAR   PRODUCTS
> 1  NA
> 2  NA
> 3  50
> 4  60
> 5  30
> How can i develop this?
>
>
> Thank you in advance.
>
>
> Sergio Della Franca
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute variable

2007-03-26 Thread Henrique Dallazuanna
If you data frame is called 'df'

df$PRODUCTS[df$PRODUCTS > 70] <- NA

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22"
O

On 26/03/07, Sergio Della Franca <[EMAIL PROTECTED]> wrote:
>
> Dear R-Helpers,
>
> I want to substitute the contents of a variable under some contitions.
>
> I.e., I have this data set:
>
> YEAR   PRODUCTS
> 1  80
> 2  90
> 3  50
> 4  60
> 5  30
>
> I want to perform this condition:
> if products> 70 then products=NA else products=products.
>
> I'd like to achive the seguent result:
>
> YEAR   PRODUCTS
> 1  NA
> 2  NA
> 3  50
> 4  60
> 5  30
> How can i develop this?
>
>
> Thank you in advance.
>
>
> Sergio Della Franca
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] substitute variable

2007-03-26 Thread Sergio Della Franca
Dear R-Helpers,

I want to substitute the contents of a variable under some contitions.

I.e., I have this data set:

YEAR   PRODUCTS
1  80
2  90
3  50
4  60
5  30

I want to perform this condition:
if products> 70 then products=NA else products=products.

I'd like to achive the seguent result:

 YEAR   PRODUCTS
1  NA
2  NA
3  50
4  60
5  30
How can i develop this?


Thank you in advance.


Sergio Della Franca

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.