if (FALSE) {
# plot data
par(xpd = NA, oma=c(0,0,0,8) )
tsplot(sleep2[[3]][2:3], type='s', col=2:3, spag=TRUE, gg=TRUE)
legend('topright', inset=c(-0.3,0), bty='n', lty=1, col=2:3, legend=c('sleep state',
'number of \nmovements'))
## you may have to change the first value of 'inset' in the legend to get it to fit
# spectral analysis
x = dna2vector(sleep1[[1]]$state[1:115], alphabet=c('1','2','3','4','5')) # never awake
specenv(x, spans=c(3,3))
abline(v=1/60, lty=2, col=8)
}
Run the code above in your browser using DataLab