x <- runif(10)
mydata <- data.frame(x,x)
plot(mydata, asp=1)

# Perform principal components analysis 
mydata.pca <- prcomp(mydata) 
# Extract first component of rotated data
# Recall pca rigidly rotates the data by
# choosing a basis where 
# first component has greatest variance
# second component has next greatest variance, etc.
mydata.pca1 <- (as.matrix(mydata) %*% mydata.pca$rotation)[,1]
# Extract 2nd component of rotated data
mydata.pca2 <- (as.matrix(mydata) %*% mydata.pca$rotation)[,2]
# combine first 2 components of rotated data
# Note this is the projection of my data
# onto the first two principle components.
mydata.pca12 <- cbind(mydata.pca1,mydata.pca2)

# compare the plots of the original mydata and 
# mydata.pca12 = projecting mydata onto 
# the first 2 principle components 
plot(mydata, asp=1)
plot(mydata.pca12, asp=1)

## Note you can use pca1 and pca2 as filter functions
filter_values <- mydata.pca1
filter_values <- mydata.pca2