background preloader

R Tricks

Facebook Twitter

Efficiently compute the row sums of a 3d array in R. R FAQ: How does R handle missing values? R FAQ How does R handle missing values? Version info: Code for this page was tested in R Under development (unstable) (2012-02-22 r58461) On: 2012-03-28 With: knitr 0.4 Like other statistical software packages, R is capable of handling missing values. However, to those accustomed to working with missing values in other packages, the way in which R handles missing values may require a shift in thinking. On this page, we will present first the basics of how missing values are represented in R. Next, for those coming from SAS, SPSS, and/or Stata, we will outline some of the differences between missing values in R and missing values elsewhere. Finally, we will introduce some of the tools for working with missing values in R, both in data management and analysis. Very basics Missing data in R appears as NA. x1 <- c(1, 4, 3, NA, 7)x2 <- c("a", "B", NA, "NA") is.na(x1) is.na(x2) We can see that R distinguishes between the NA and "NA" in x2--NA is seen as a missing value, "NA" is not. x1 < 0 x1 == NA.

"R" you ready? | My advances in R – a learner’s diary. Google Developers R Programming Video Lectures. Built-in Functions. Almost everything in R is done through functions. Here I'm only refering to numeric and character functions that are commonly used in creating or recoding variables. Numeric Functions Character Functions Statistical Probability Functions The following table describes functions related to probaility distributions. For random number generators below, you can use set.seed(1234) or some other integer to create reproducible pseudo-random numbers. Other Statistical Functions Other useful statistical functions are provided in the following table. Other Useful Functions Note that while the examples on this page apply functions to individual variables, many can be applied to vectors and matrices as well.

Inside-R | A Community Site for R | A Community Site for R – Sponsored by Revolution Analytics.