【发布时间】:2016-07-13 05:07:44
【问题描述】:
所以我试图计算一些功能数据的相平面图,它是根据时间测量的,所以我希望图上的标签每 12 小时标记一次。
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)
这会产生以下情节,没有标签?
这就是错误栏中出现的内容
Error in text.default(D1., D2., labels$labels) :
no coordinates were supplied
我不知道如何解决它??
【问题讨论】:
-
与您的问题无关,但我认为您不需要致电
attach(alldata)(实际上大部分时间没有人需要attach...)。用外行的术语快速解释attach(obj)函数的作用:它只获取obj中的所有变量(可以是列表或data.frame 或环境)并将它们复制到全局环境中。所以如果obj包含一个名为foo的变量(或列),除了调用obj$foo,attach(obj)之后,也可以直接使用foo -
关于您的问题,我们需要一个可重现的示例:请参阅 this post 了解一些技巧以使您的问题可重现。
标签: r plot functional-programming labels