19 3:33 PM
To: Steinmann, Kimberly@CDPR ; r-help mailing
list
Subject: Re: [R] help with if statement with two conditions
EXTERNAL:
Hi Kimberley,
Since you are using a loop and therefore testing one value of v_trends_lbs at a
time, the "&" in the "if" statement should be "&a
Hi Kimberley,
Given the number of posts that read "I have a problem, please advise",
your concern for our mental welfare is a great Xmas present.
Jim
On Tue, Dec 24, 2019 at 10:38 AM Steinmann, Kimberly@CDPR
wrote:
>
> I am not sure how to close the thread - I hate to waste anyone's time on a
>
Hi Kimberley,
Since you are using a loop and therefore testing one value of
v_trends_lbs at a time, the "&" in the "if" statement should be "&&".
Pinching Bert's example but using a for loop instead of ifelse:
x <- seq(-2,2,.25)
v_lbs<-rep("",length(x))
for(i in 1:length(x)) {
if(is.na(x[i])) v_l
WITHOUT going through your code carefully (but where is v_lbs first
defined?), maybe something like this is what you want:
> x <- seq(-2,2,.25)
> x
[1] -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50
0.75 1.00
[14] 1.25 1.50 1.75 2.00
> x <- ifelse(x>0 & x<1, '<1', format(
What does the error message say?
On Mon, Dec 23, 2019, 3:33 PM Steinmann, Kimberly@CDPR <
kimberly.steinm...@cdpr.ca.gov> wrote:
> Hi - i am not super familiar with R, but need to modify my predecessor's R
> code so that if a variable is >0 and < 0.5, it will be replaced with <1. I
> have looked
Hi - i am not super familiar with R, but need to modify my predecessor's R code
so that if a variable is >0 and < 0.5, it will be replaced with <1. I have
looked at a bunch of forum threads on the subject, but cannot seem to get
anything to work Any help at what i might be doing wrong much appre
DT<-data.frame(time=c(0,1,5,24,36,48,72),DV=seq(0,60,10))
time DV
10 0
21 10
35 20
4 48 30
5 84 40
6 96 50
7 120 60
You want to add 24 to values that are >=24 in 'time'
DT[DT$time>=24,'time']<-DT[DT$time>=24,'time']+24
time DV
10 0
21 10
35 20
4 48 30
5 60
On Nov 21, 2012, at 9:05 AM, york8866 wrote:
Hi all,
I had a dataset A like:
TIME DV
0 0
1 10
520
24 30
36 80
48 60
72 15
I would like to add 24 to those values higher than 24 in the TIME
column.
I did the following:
If (A$TIME>=24) {
A$TIME <- A$TIME+24}
It did not work.
Does
A$TIME <- ifelse( A$TIME >= 24, A$TIME + 24, A$TIME )
what you want?
Rgds,
Rainer
On Wednesday 21 November 2012 09:05:39 york8866 wrote:
> Hi all,
>
> I had a dataset A like:
>
> TIME DV
> 0 0
> 1 10
> 520
> 24 30
> 36 80
> 48 60
> 72 15
>
> I would like to add 24 to those
Use ifelse().
ifelse(A$TIME >= 24, A$TIME + 24, A$TIME)
Please in the future use dput() to provide your data, and explain what
"did not work" means.
Sarah
On Wed, Nov 21, 2012 at 12:05 PM, york8866 wrote:
> Hi all,
>
> I had a dataset A like:
>
> TIME DV
> 0 0
> 1 10
> 520
> 24 30
> 3
Hi all,
I had a dataset A like:
TIME DV
0 0
1 10
520
24 30
36 80
48 60
72 15
I would like to add 24 to those values higher than 24 in the TIME column.
I did the following:
If (A$TIME>=24) {
A$TIME <- A$TIME+24}
It did not work. How should I do it?
Thanks,
--
View this messag
11 matches
Mail list logo