\documentclass[a4paper]{article} %\VignetteIndexEntry{m61r} %\VignettePackage{m61r} \setlength{\parindent}{0in} \setlength{\parskip}{.1in} \setlength{\textwidth}{140mm} \setlength{\oddsidemargin}{10mm} \title{object m61r} \author{pv71u98h1} \begin{document} \maketitle \section{Introduction} \label{sec:intro} Object m61r is an object that enables all the function present in m61r, and in addition, allows a sort of pipe.\newline The purpose of this package is informative.\newline \section{Example 1: pipeline with 1 step cache} \label{sec:ex-1} <>= library(m61r) @ <>= co2 <- m61r(CO2) co2$filter(~Plant %in% c("Qn1","Qc3")) co2$mutate(z1=~uptake/conc,y=~conc/100) co2$group_by(~c(Type,Treatment)) co2$summarise(foo=~mean(z1),bar=~sd(y)) co2 # print results head(co2) # back to normal @ \section{Example 2: get only a data.frame as result} \label{sec:ex-2} <>= co2 <- m61r(CO2) co2$filter(~Plant %in% c("Qn1","Qc3")) co2$transmutate(z1=~uptake/conc,y=~conc/100) tmp <- co2[] # get only the data.frame and not the whole m61r object head(tmp) class(tmp) @ \section{Example 3: manipulation of a m61r object} \label{sec:manipulation} <>= co2 <- m61r(CO2) head(co2) names(co2) dim(co2) co2[1,] head(co2[,2:3]) co2[1:10,1:3] co2[1,"Plant"] str(co2) co2[1,"conc"] <- 100 co2[1,] # w/temporary change co2[1,] # back to normal # WARNING: Keep the brackets to manipulate the intern data.frame co2[] <- co2[-1,] co2[1:3,] # temporary result co2[1:3,] # back to normal # ... OR you will destroy co2, and only keep the data.frame # co2 <- co2[-1,] # class(co2) # data.frame # cloning foo <- co2 # This will only create # a second variable that points # on the same object (i.e not cloning) str(co2) str(foo) # Instead, cloning into a new environment foo <- co2$clone() str(co2) str(foo) @ \end{document}