t <- seq(0, 1, length.out = 50)
X <- matrix(0, 30, 50)
for (i in 1:30) X[i, ] <- sin(2*pi*t + runif(1, 0, pi)) + rnorm(50, sd = 0.1)
fd <- fdata(X, argvals = t)
pc <- fdata2pc(fd, ncomp = 3)
# Plot PC components (mean +/- perturbations)
plot(pc, type = "components")
# Scree plot
plot(pc, type = "variance")
# Score plot
plot(pc, type = "scores")
Run the code above in your browser using DataLab