The “Not In” Operator:
1 2 3 4 5 6 7 8 |
# Define it: '%ni%' <- function(x,y) !('%in%'(x,y)) # Use it: x <- c(1:10); exclude.set <- c(1, 5) y <- x[x %ni% exclude.set] # |
The “Not In” Operator:
1 2 3 4 5 6 7 8 |
# Define it: '%ni%' <- function(x,y) !('%in%'(x,y)) # Use it: x <- c(1:10); exclude.set <- c(1, 5) y <- x[x %ni% exclude.set] # |
mclapply() doesn’t work, as it should, on Windows. Therefore, Nathan VanHoudnos has published a package called parallelsugar which replaces mclapply() with a mclapply() that actually works on Windows. You can read more about it here: r-bloggers.com/parallelsugar-an-implementation-of-mclapply-for-windows/ To avoid masking parallelsugar‘s mclapply with parallel‘s mclapply you can use: parallelsugar::mclapply().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Naming Conventions by Example # Vector Definition names <- c('Alexandre','Jannik','Radim') weights.lb <- c(188, 195, 194) # Data Frame Definition canucks.forwards <- data.frame(Name = names, WeightLb = weights.lb) # Function Definition convertLbToKg <- function(people) { people$WeightKg <- people$WeightLb * 0.45359237 return(people) } canucks.forwards <- convertLbToKg(canucks.forwards) |
I haven’t been able to find a good agreed-upon naming convention for R therefore, I attempt to create one, for myself and anyone who is interested.
Check out the cheat sheet Mirko Krivanek has prepared for data visualization with R, particularly, ggplot2.