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

Bert Gunter gunter.berton at gene.com
Thu Aug 14 18:26:55 CEST 2014


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://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.



More information about the R-help mailing list