Some Implementation in R