This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to Ask for Help using R | |
======================================================== | |
The key to getting good help with an R problem is to provide a minimally working | |
reproducible example (MWRE). Making an MWRE is really easy with R, and it will | |
help ensure that those helping you can identify the source of the error, and | |
ideally submit to you back the corrected code to fix the error instead of sending | |
you hunting for code that works. To have an MWRE you need the following items: | |
- a minimal dataset that produces the error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see blog post here: | |
# http://gettinggeneticsdone.blogspot.com/2015/01/microbenchmark-package-r-compare-runtime-r-expressions.html | |
library(dplyr) | |
library(nycflights13) | |
flights | |
# base | |
aggregate(flights$arr_delay, by=list(flights$carrier), mean, na.rm=TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_contracts = {} | |
class Contract: | |
@classmethod | |
def __init_subclass__(cls): | |
_contracts[cls.__name__] = cls | |
def __set__(self, instance, value): | |
self.check(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solve <- function(n) { | |
result <- largeSubtract(largeAdd(sumMultiple(n, 3), sumMultiple(n, 5)), sumMultiple(n, 15)) | |
} | |
right <- function (string, char){ | |
substr(string,nchar(string)-(char-1),nchar(string)) | |
} | |
left <- function (string,char){ | |
substr(string,1,char) |
NewerOlder