# Create functional data with outliers
set.seed(42)
t <- seq(0, 1, length.out = 50)
X <- matrix(0, 30, 50)
for (i in 1:28) X[i, ] <- sin(2*pi*t) + rnorm(50, sd = 0.2)
X[29, ] <- sin(2*pi*t) + 2 # Magnitude outlier
X[30, ] <- sin(4*pi*t) # Shape outlier
fd <- fdata(X, argvals = t)
# Create MS plot
ms <- magnitudeshape(fd)
# With IDs and metadata
fd <- fdata(X, argvals = t, id = paste0("curve_", 1:30))
ms <- magnitudeshape(fd, label = "id")
Run the code above in your browser using DataLab