R: Multible line in a plot using curveid -


i'm researcher , not programmer.

i have used drc package, analyze data. there can define curveid , plot multiple lines in 1 plot.

i need same thing normal plot, knowledge little :(

my data looks this:

  time        type   material      value1      value2 1    1                   x          34        123 1    3                   x          44        164 1    1          b          x          56        234 1    2          b          x          23        145 1    3          b          x          45        343 1    1                   y          45        243  ... 

now want e.g first plot value1 ~ time, , every material own line. maybe value2 ~ time , every type own line.

may intention scrip @ beginning declare column contain x, y , curveid. , plot drc package.

i try use split() , subset , cbind , matplot, had problems because there time values missing.

i wanted try reshape2, couldn't install package.

is there simpler solution (similar drc) package?

thanks

you have duplicated (material, types) cases, lines not appear appropriated. try this, using points.

tms=range(df[,"time"]) ylims=range(df[,c("value1","value2")]) plot(na,type="n",xlim=tms,ylim=ylims,xlab="time",ylab="val") df=df[with(df,order(material,time)),] mats=unique(df$material) sapply(1:length(mats),function(ma){points(df[df$material==mats[ma],"time"],                         df[df$material==mats[ma],"value1"],                          col=ma,pch=15  ) }) df=df[with(df,order(type,time)),] library(rcolorbrewer) coly<-brewer.pal(8,"accent")[8:1] typs=unique(df$type) sapply(1:length(typs),function(ma){points(df[df$type==typs[ma],"time"],                                            df[df$type==typs[ma],"value2"],                                          col=coly[ma],pch=15+ma  ) }) legend("top",c(mats,typs),pch=c(rep(15,length(mats)),15+1:length(typs)),        col=c(palette()[1:length(mats)],coly[1:length(typs)]),horiz=t) 

you have

enter image description here


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -