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; Rdocumentation.org; 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 occasionally get emails from people thinking they have found a bug in one of my R packages, and I usually have to reply asking them to provide a minimal reproducible example (MRE). This post is to provide instructions on how to create 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. plot.new underscore_separated: e.g. numeric_version lowerCamelCase: e.g. addTaskCallback UpperCamelCase: e.g.
Useful tutorials
There are some tools that I use regularly, and I would like my research students and post-docs to learn them too. Here are some great online tutorials that might help. ggplot tutorial from Winston ChangWriting an R package from Karl BromanRmarkdown from RStudioShiny from RStudiogit/github guide from Karl Bromanminimal make tutorial 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(is.na(df), 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!