The lng package is used for observational study. Two new functions are added recently to divide the input data into four chunks and calculate the mean and standard deviation of each variable.

All changes are finished in the new branch: try. The purposes of two new functions are same, while one (chunkSummaryR) is a pure R funcion, and the other (chunkSummaryC) is a R function calls a C++ function.

Follows are the test part, it uses one sample dataset to check whether the two functions give the same resuls.

Install required packages and select one data to test

devtools::install_github("YuweiNi45/lng",ref = "try")
library(devtools)
library(Rcpp)
library(MASS)
library(lng)
data<-birthwt
summ<-head(data,10)
knitr::kable(summ,caption = "The first ten rows of sample data")

The results of pure R function

#chunkSummaryR
result1<-chunkSummaryR(data)
knitr::kable(result1,caption = "The results of pure R function")

The results of R and C++ function

#chunkSummaryC
sourceCpp("/Users/summer/Downloads/package/lng/src/chunkSummaryC.cpp")
result2<-chunkSummaryC(data)
knitr::kable(result2,caption = "The results of R and C++ function")


YuweiNi45/lng documentation built on May 12, 2019, 6:26 p.m.