##for a 100x10 data matrix X,
## lying (mostly) in the subspace defined by the first 2 unit vectors,
## projects data into 1 dimension.
X <- matrix(c(runif(100*2, -10, 10), rep(0,100*8)),nrow=100) +
matrix(c(rep(0,100*2),rnorm(100*8,0,0.1)),ncol=10)
mysparsel1pca <- sparsel1pca(X, lambda=0.5)
##projects data into 2 dimensions.
mysparsel1pca <- sparsel1pca(X, projDim=2, center=FALSE, projections="l1", lambda=0.5)
## plot first two scores
plot(mysparsel1pca$scores)
Run the code above in your browser using DataLab