background preloader

Cheatsheets - RStudio

Cheatsheets - RStudio
Advanced R Environments, data structures, functions, subsetting and more, by Arianne Colton and Sean Chen. Updated February 2016. Download Base R Vectors, matrices, lists, data frames, functions and more in base R, by Mhairi McNeill. Download bayesplot Plotting for Bayesian Models in R, by Edward A. Download Bayesian cost effective analysis in R, by Gianluca Baio. Download caret Modeling and machine learning in R with the caret package, by Max Kuhn. Download cartography Thematic maps with spatial objects, by Timothée Giraud. Download collapse Advanced and fast data transformation with R, by Sebastian Krantz. Download data.table Data manipulation with data.table, by Erik Petrovski. Download DeclareDesign Tools to test research designs that use a MIDA framework. Download distr6 An object-oriented interface for probability distributions, by Raphael Sonabend. Download estimatr Fast, robust estimators for common models. Download eurostat R tools to access the eurostat database, by rOpenGov. Download gganimate golem

Related:  Learning R1. ImportantOutils cartographiques

An Intro to formatR You can install formatR from CRAN, or XRAN if you want to test the latest development version: install.packages("formatR", repos = " Or check out the Github repository and install from source if you know what this means. This page is always based on the development version. library(formatR) sessionInfo() Random Data Sets Quickly Random Data Sets Quickly This post will discuss a recent GitHub package I’m working on, wakefield to generate random data sets. The post is broken into the following sections: 21 R navigation tools Navigation gets you from where you are to where you want to be. Speaking of navigation, you can jump to selected sections of this post: Navigation; R-bloggers; Task views;; sos package; ??; apropos; ls; methods; getAnywhere; :::; find; args; grep; %in%; str; getwd; file.choose; Spyglass summary; browser; See also. Overview Figure 1: A map of the R world. Each R session has a workspace specific to it.

Minimal reproducible examples Minimal reproducible examples I occa­sion­ally get emails from peo­ple think­ing they have found a bug in one of my R pack­ages, and I usu­ally have to reply ask­ing them to pro­vide a min­i­mal repro­ducible exam­ple (MRE). This post is to pro­vide instruc­tions on how to cre­ate a MRE. Bug reports on github, not email Robin Lovelace - Consistent naming conventions in R Naming conventions in R are famously anarchic, with no clear winner and multiple conventions in use simultaneously in the same package. This has been written about before, in a lucid article in the R Journal, a detailed exploration of names in R source code hosted on CRAN and general discussion on stackoverflow. Basically, there are 5 naming conventions to choose from: alllowercase: e.g. adjustcolor period.separated: e.g. underscore_separated: e.g. numeric_version lowerCamelCase: e.g. addTaskCallback UpperCamelCase: e.g.

Useful tutorials There are some tools that I use reg­u­larly, and I would like my research stu­dents and post-​​docs to learn them too. Here are some great online tuto­ri­als that might help. ggplot tuto­r­ial from Win­ston ChangWrit­ing an R pack­age from Karl BromanRmark­down from RStudioShiny from RStudiogit/​github guide from Karl Bromanmin­i­mal make tuto­r­ial from Karl Broman Related Posts:

Vectorization in R: Why? Here are my notes from a recent talk I gave on vectorization at a Davis R Users’ Group meeting. Thanks to Vince Buffalo, John Myles White, and Hadley Wickham for their input as I was preparing this. Feedback welcome! How to ask for R help by Stephen Weller, Senior Support Engineer at Revolution Analytics, and Joseph Rickert For someone trying to learn any new technology getting help with a problem on a public forum can be stressful. Knowing where to go, deciding how to pose a question and figuring out how to deal with a response can be challenging. Moreover, an unpleasant interaction could be ego bruising and a real set-back to learning. Before posting a question on an internet forum do everything you can to make it a positive experience for everyone involved. Here are some recommendations Steve and I have for getting help with R questions.

Memory usage · Advanced R. A solid understanding of R’s memory management will help you predict how much memory you’ll need for a given task and help you to make the most of the memory you have. It can even help you write faster code because accidental copies are a major cause of slow code. The goal of this chapter is to help you understand the basics of memory management in R, moving from individual objects to functions to larger blocks of code. Along the way, you’ll learn about some common myths, such as that you need to call gc() to free up memory, or that for loops are always slow. Outline Prerequisites

Learning R Complete beginner: read the 12-page A (very) short introduction to R by Torfs & Brauer. Beginner / intermediate: read R for Data Science, by Hadley Wickham. It teaches both fundamental data science concepts and the most modern way of using R (with the tidyr, dplyr, purr and ggplot2 packages). The book should be published in late 2016, but most of the first chapters are already freely available online in draft form.

Style - Hadley Good coding style is like using correct punctuation. You can manage without it, but it sure makes things easier to read. As with styles of punctuation, there are many possible variations. The following guide describes the style that I use (in this book and elsewhere).

Creating your personal, portable R code library with GitHub As I discussed in a previous post, I have a few helper functions I’ve created that I commonly use in my work. Until recently, I manually included these functions at the start of my R scripts by either the tried and true copy-and-paste method, or by extracting them from a local file with the <code>source()</code> function. The former approach has the benefit of keeping the helper code inextricably attached to the main script, but it adds a good bit of code to wade through.

Google Dev R Video Lectures I got this Google Developers R Programming Video Lectures from Stephen's blog - Getting Genetics Done. Very useful R tutorial for beginner! Short and efficient. Here is what I learned after watching the lectures: stop() and warning() function I was asked this question during a job interview. stop('message') will print out the error message and stop the function. warning('message') will print out the error message but continue the function. To return index of an array/dataframe, use which(df, arr.ind=T), e.g. which(, arr.ind=T) will return the column/row index of NA elements.

The Guerilla Guide to R Update: Okay. I’ve uploaded a new template and things seem to be fine now. Update: I am aware the table of contents is not being displayed in bullet form as I intended. The web template I’m using seems to be buggy. It also seems to think this page is in Indonesian…Working on it!