[R] Operating on the value from row i and row i+1

Jaiprasart, Pharavee (HSC) pharavee-jaiprasart at ouhsc.edu
Thu Aug 14 18:39:34 CEST 2014


Hi Bert,

I should have phrased my question differently.

I actually want to do two things. 

First is to make a step plot. The "s"/"S" is a typo on my part.

The second is to write a script that when I ask the program for Response of time == 4, I want it to return "6", or if I ask for response of time == 12, it will return "4", and so on.

Pharavee


-----Original Message-----
From: Bert Gunter [mailto:gunter.berton at gene.com] 
Sent: Thursday, August 14, 2014 11:27 AM
To: Jaiprasart, Pharavee (HSC)
Cc: r-help at r-project.org
Subject: Re: [R] Operating on the value from row i and row i+1

Your query is a bit unclear, but I suspect

?plot

and a **careful read** about types "s" and "S" therein would address your problem.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge is certainly not wisdom."
Clifford Stoll




On Thu, Aug 14, 2014 at 8:07 AM, Jaiprasart, Pharavee (HSC) <pharavee-jaiprasart at ouhsc.edu> wrote:
> Hi all,
>
>
>
> I'd like to make a step plot of Time vs Response graph.
>
> This is the example of my data frame - the real data frame has more than a thousand rows.
>
>
>
> Time          Duration of infusion           Infusion Rate            Response               Subtype
>
> 0                         3                                                     2                         5                                     0
>
> 3                         6                                                     3                         6                                     0
>
> 9                         6                                                     4                         4                                     0
>
>
>
> I cannot just use type = c("s") for this because I also want to use the value of the in between time for further calculation too (If I ask the program for Response of time == 4, I want it to return "6").
>
>
>
> The way I think the script should work is that:
>
>
>
> For all rows that has subtype ==0, if time is between the value of row 
> /i/ and /i+1/ (e.g. row 1 and 2 which is 0-3), make a new column 
> "Dummy" and return the value of row /i/ from the Response column (e.g. 
> 5 in this
>
> example) , and do these for all rows (e.g. any time between row 2 and 
> 3 which is 3-9, make a new column and return 6). Then I can say if 
> Time>0 (value in column1) and <3 (value from column 1+2), y = value in 
> Dummy
>
>
>
> Is there any way to do this in R?
>
>
>
> Thanks!
>
> Pharavee
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://urldefense.proofpoint.com/v1/url?u=https://stat.ethz.ch/mailma
> n/listinfo/r-help&k=7DHVT22D9IhC0F3WohFMBA%3D%3D%0A&r=s1Xjgqw9bK2MQxns
> spJiRNsjZKIq%2B8%2Fhu084PPVY11o%3D%0A&m=wxyqWjigDlACZVtOk8tgsAt8iaUOs0
> k79BnWO1L%2FRUs%3D%0A&s=8d0ca7ccfe0e7c4bac733aa2e8fe9a7068ffcf501cb181
> e4261e95efc1b0e31a PLEASE do read the posting guide 
> https://urldefense.proofpoint.com/v1/url?u=http://www.r-project.org/po
> sting-guide.html&k=7DHVT22D9IhC0F3WohFMBA%3D%3D%0A&r=s1Xjgqw9bK2MQxnss
> pJiRNsjZKIq%2B8%2Fhu084PPVY11o%3D%0A&m=wxyqWjigDlACZVtOk8tgsAt8iaUOs0k
> 79BnWO1L%2FRUs%3D%0A&s=7ca8e5a21aa512fa8bc5669fb6f4ea587d530d4a20146fd
> 526148d17a3d198bc and provide commented, minimal, self-contained, 
> reproducible code.


More information about the R-help mailing list