2

So I am trying to compute a phase plane plot of some functional data, its is measured against time so I want the labels on the plot to mark every 12 hours.

attach(alldata)

#identify the time measure form the data, and make a vector
tdata<-data.matrix(alldata[,1:1])

timev<-as.vector(tdata)

#identify the control group
control<-data.matrix(alldata[,2:25])

#create basis and smooth and create functional object
basis17<-create.fourier.basis(rangeval=c(0,5.24677083333333), nbasis=17)

csbasis17<-smooth.basis(argvals=tdata,control,basis17)

controlfd<-fd(coef(csbasis17),basis17) 

#creaste list of points whre i was labels to go and name them 

th<-list("12 hours"=timev[1:1],"24 hours"=timev[15:15],"36 hours"=timev[29:29],"48 hours"=timev[43:43],
         "60 hours"=timev[50:50], "72 hours"=timev[57:57], "84 hours"=timev[71:71],
         "96 hours"=timev[85:85] ,"108 hours"=timev[100:100],"120 hours"=timev[114:114], "136 hours"=timev[128:128])
#crerate list of 2 containing the points i want plotted and the names
ws<- list(th,labels(th))

#phase plane plot command 
phaseplanePlot(timev,controlfd,Lfdobj1=1, Lfdobj2=2,
               lty=c("longdash", "solid"),
               labels=ws)

This produces the following plot, with no labels?

enter image description here

and this is what comes up in the error bar

Error in text.default(D1., D2., labels$labels) : 
  no coordinates were supplied

I cant figure out how to fix it??

digEmAll
  • 56,430
  • 9
  • 115
  • 140
Sarah
  • 21
  • 1
  • Not related to your problem, but I don't think you need to call `attach(alldata)` (actually noboby needs `attach` most of the time...). To quickly explain what `attach(obj)` function does in layman's terms: it just takes all the variables inside `obj` (that can be a list or data.frame or environment) and copy them into the global environment. So if `obj` contains a variable (or column) named `foo`, besides calling `obj$foo`, after `attach(obj)`, you can also use directly `foo` – digEmAll Mar 25 '16 at 14:01
  • Regarding your problem, we need a reprodubible example: see [this post](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for some tricks to make your problem reproducible. – digEmAll Mar 25 '16 at 14:04

1 Answers1

0

There is no need to put the th into a list. As your example is not reproducible, assume e.g. that the length is 1:100, the first 100 evaluated points of the curve and we want to plot a label in the origen "O", middle "M" and the end "E" of our data. Then, you should fill the label argument as follows:

arg <- 1:100

phaseplanePlot(timev,controlfd, Lfdobj1 = 1, Lfdobj2 = 2,
               lty = c("longdash", "solid"),
               label = list(evalarg = seq(arg[1], max(arg), length=3), 
                            labels = c("O","M","E"))

Here,

seq(arg[1], max(arg), length=3) 
[1]   1.0  50.5 100.0

Then, enter image description here

fina
  • 429
  • 4
  • 12