Hi
try to make your example easier and reproducible.
I get
> CONCF <-matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
Error in CONC1 + CONC2 : non-conformable arrays
so I cannot understand what shall the final plot look like.
Regards
Petr
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Andras Farkas
> Sent: Friday, November 30, 2012 12:51 PM
> To: r-help at r-project.org
> Subject: [R] help on "stacking" matrices up
>
> Dear All,
>
> #I have the following code
>
> Dose<-1000
> Tinf <-0.5
> INTERVAL <-8
> TIME8 <-matrix(c((0*INTERVAL):(1*INTERVAL)))
> TIME7 <-matrix(c((0*INTERVAL):(2*INTERVAL)))
> TIME6 <-matrix(c((0*INTERVAL):(3*INTERVAL)))
> TIME5 <-matrix(c((0*INTERVAL):(4*INTERVAL)))
> TIME4 <-matrix(c((0*INTERVAL):(5*INTERVAL)))
> TIME3 <-matrix(c((0*INTERVAL):(6*INTERVAL)))
> TIME2 <-matrix(c((0*INTERVAL):(7*INTERVAL)))
> TIME1 <-matrix(c((0*INTERVAL):(8*INTERVAL)))
> CDURINF1 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME1))
> CAFTINF1 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME1)))
> CONC1 <-ifelse(TIME1<=Tinf,CDURINF1,CAFTINF1)
> CDURINF2 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME2))
> CAFTINF2 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME2)))
> CONC2 <-ifelse(TIME2<=Tinf,CDURINF2,CAFTINF2)
> CDURINF3 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME3))
> CAFTINF3 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME3)))
> CONC3 <-ifelse(TIME3<=Tinf,CDURINF3,CAFTINF3)
> CDURINF4 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME4))
> CAFTINF4 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME4)))
> CONC4 <-ifelse(TIME4<=Tinf,CDURINF4,CAFTINF4)
> CDURINF5 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME5))
> CAFTINF5 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME5)))
> CONC5 <-ifelse(TIME5<=Tinf,CDURINF5,CAFTINF5)
> CDURINF6 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME6))
> CAFTINF6 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME6)))
> CONC6 <-ifelse(TIME6<=Tinf,CDURINF6,CAFTINF6)
> CDURINF7 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
> CAFTINF7 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME7)))
> CONC7 <-ifelse(TIME7<=Tinf,CDURINF7,CAFTINF7)
> CDURINF8 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*TIME7))
> CAFTINF8 <-((Dose/Tinf)*(1/(0.088*76.9)))*(1-exp(-0.088*Tinf))*(exp(-
> 0.088*(TIME8)))
> CONC8 <-ifelse(TIME8<=Tinf,CDURINF8,CAFTINF8)
> CONCF <-matrix(c(CONC1+CONC2+CONC3+CONC4+CONC5+CONC6+CONC7+CONC8))
> plot(CONCF,type="l")
>
> I am trying to plot CONCF in a specific way. Let me try to explain: I
> would like to plot it so that the x axis goes from 0 to 8*INTERVAL
> (here the INTERVAL represents time in hours), and then each
"segments"
> of the matrix? would? be added to the sum of the previous ones at a
> specific moment in time. Assuming a much shorter example this is what
> it should be like where according to the same equations above each
> value of CONCi was calculated at 1 h intervals:
> INTERVAL <=3
> time points here where the values are calculated is 0:(3*INTERVAL) for
> CONC1, 0:(2*INTERVAL) for CONC2, and 0:(1*INTERVAL) for CONC3, all
> calculated at 1 hour intervals
>
> and lets assume calculated values are:
>
> CONC1 <-c(0,1,2,3,4,5,6,7,8,9)
> CONC2?<-c(?11,12,13,14,15,16,17)
> CONC3 <-(21,22,23,24)
> .
> .
> .
>
> so I would like to get CONCF that would have the following values:
> CONCF <-c(0,1,2,3+11,4+12,5+13,6+14,7+15,8+16,9+17,
> 6+14+21,7+15+22,8+16+23,9+17+23) please note that CONC2 was started to
> be added to CONC1 at 1*INTERVAL value estimated for CONC1, ie CONC1 has
> the value of 3 at hour 3, and I need to add the value of CONC2 at hour
> zero to it, and so on...
> hope I made it clear enough and thanks for the help,
>
> Andras
> [[alternative HTML version deleted]]