## ----style, echo = FALSE, results = 'asis'--------------------------------- knitr::opts_chunk$set( eval=as.logical(Sys.getenv("KNITR_EVAL", "TRUE")), cache=as.logical(Sys.getenv("KNITR_CACHE", "TRUE"))) ## -------------------------------------------------------------------------- 1 + 2 x = c(1, 2, 3) 1:3 # sequence of integers from 1 to 3 x + c(4, 5, 6) # vectorized x + 4 # recycling ## -------------------------------------------------------------------------- x = rnorm(100) y = x + rnorm(100) plot(x, y) ## -------------------------------------------------------------------------- df <- data.frame(Independent = x, Dependent = y) head(df) df[1:5, 1:2] df[1:5, ] plot(Dependent ~ Independent, df) # 'formula' interface ## -------------------------------------------------------------------------- ridx <- (df$Dependent > 0) & (df$Independent > 0) ## -------------------------------------------------------------------------- plot(Dependent ~ Independent, df[ridx, ]) ## -------------------------------------------------------------------------- plot( Dependent ~ Independent, df, subset = (Dependent > 0) & (Independent > 0) ) ## -------------------------------------------------------------------------- fit <- lm(Dependent ~ Independent, df) # linear model -- regression anova(fit) # summary table plot(Dependent ~ Independent, df) abline(fit) ## -------------------------------------------------------------------------- class(fit) methods(class="lm") ## ---- eval=FALSE----------------------------------------------------------- # ?"plot" # plain-old-function or generic # ?"plot.formula" # method # ?"plot.lm" # method for object of class 'lm', plot(fit) ## -------------------------------------------------------------------------- library(ggplot2) ggplot(df, aes(x = Independent, y = Dependent)) + geom_point() + geom_smooth(method = "lm") ## ---- message = FALSE------------------------------------------------------ library(Biostrings) dna <- DNAStringSet(c("AACTCC", "CTGCA")) dna reverseComplement(dna) ## -------------------------------------------------------------------------- sessionInfo()