# R Programming - Manuals

R Basics The R & BioConductor manual provides a general introduction to the usage of the R environment and its basic command syntax. Code Editors for R Several excellent code editors are available that provide functionalities like R syntax highlighting, auto code indenting and utilities to send code/functions to the R console. Programming in R using Vim or Emacs Programming in R using RStudio Integrating R with Vim and Tmux Users interested in integrating R with vim and tmux may want to consult the Vim-R-Tmux configuration page. Finding Help Reference list on R programming (selection)R Programming for Bioinformatics, by Robert GentlemanAdvanced R, by Hadley WickhamS Programming, by W. Control Structures Conditional Executions Comparison Operators equal: ==not equal: ! Logical Operators If Statements If statements operate on length-one logical vectors. Syntax if(cond1=true) { cmd1 } else { cmd2 } Example if(1==0) { print(1) } else { print(2) } [1] 2 Avoid inserting newlines between '} else'. Loops Syntax Related:  R

Rtips. Revival 2014! Paul E. Johnson <pauljohn @ ku.edu> The original Rtips started in 1999. It became difficult to update because of limitations in the software with which it was created. Now I know more about R, and have decided to wade in again. In January, 2012, I took the FaqManager HTML output and converted it to LaTeX with the excellent open source program pandoc, and from there I’ve been editing and updating it in LyX. You are reading the New Thing! The first chore is to cut out the old useless stuff that was no good to start with, correct mistakes in translation (the quotation mark translations are particularly dangerous, but also there is trouble with ~, $, and -. (I thought it was cute to call this “StatsRus” but the Toystore’s lawyer called and, well, you know…) If you need a tip sheet for R, here it is. This is not a substitute for R documentation, just a list of things I had trouble remembering when switching from SAS to R. Heed the words of Brian D. 1.1 Bring raw numbers into R (05/22/2012) Step 1. 60+ R resources to improve your data skills This list was originally published as part of the Computerworld Beginner's Guide to R but has since been expanded to also include resources for advanced beginner and intermediate users. If you're just starting out with R, I recommend first heading to the Beginner's Guide. These websites, videos, blogs, social media/communities, software and books/ebooks can help you do more with R; my favorites are listed in bold. Want to see a sortable list of resources by subject and type? Expand the chart below. Books and e-books R Cookbook. R Graphics Cookbook. R in Action: Data analysis and graphics with R. The Art of R Programming. R in a Nutshell. Visualize This. R For Dummies. Introduction to Data Science. R for Everyone. Statistical Analysis With R: Beginner's Guide. Reproducible Research with R and RStudio. Exploring Everyday Things with R and Ruby. Online references 4 data wrangling tasks in R for advanced beginners. Data manipulation tricks: Even better in R. Cookbook for R. Quick-R. Videos Subsetting · Advanced R. R’s subsetting operators are powerful and fast. Mastery of subsetting allows you to succinctly express complex operations in a way that few other languages can match. Subsetting is hard to learn because you need to master a number of interrelated concepts: The three subsetting operators.The six types of subsetting.Important differences in behaviour for different objects (e.g., vectors, lists, factors, matrices, and data frames).The use of subsetting in conjunction with assignment. This chapter helps you master subsetting by starting with the simplest type of subsetting: subsetting an atomic vector with [. It then gradually extends your knowledge, first to more complicated data types (like arrays and lists), and then to the other subsetting operators, [[ and$. Subsetting is a natural complement to str(). str() shows you the structure of any object, and subsetting allows you to pull out the pieces that you’re interested in. Quiz Outline Data types starts by teaching you about [. Data types !

Onepager Now with knitR \documentclass[nohyper,justified]{tufte-handout} %\documentclass{article} %\usepackage[absolute,showboxes]{textpos} \usepackage[absolute]{textpos} \usepackage{sidecap} %\usepackage{color} %\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \begin{document} <<include=FALSE>>= opts_chunk\$set(concordance=TRUE) \begin{wide} \section{\Huge Performance Summary with knitR and R} {\Large Here is a little experiment with R and Sweave to produce a performance report. \hrulefill \end{wide} <<eval=TRUE,echo=FALSE,results='hide',warning=FALSE,message=FALSE,error=FALSE>>= #do requires and set up environment for reporting require(xtable) require(ggplot2) require(directlabels) require(reshape2) require(latticeExtra) require(quantmod) require(PerformanceAnalytics) data(managers) #get xts in df form so that we can melt with the reshape package #will use just manager 1, sp500, and 10y treasury managers <- managers[,c(1,8,9)] #add 0 at beginning so cumulative returns start at 1 managers.melt <- melt(managers.df,id.vars=1)

R tells you where weapons go As an ameturer programmer (one without proper trainings in any mainstream programming language — C and Java) , the more I use R the more I understand the saying — “You are only bounded by your imagination”. The other day I suddenly recalled that someone did a very impressive Facebook map. I then thought it would be nice if I can put these “flows” on the map (or of the same sort) created in my first post. So, I googled around and found this brilliant blog that teaches you how to make flows (Great circles) step by step. Again, thanks to R, its great community and its openness, I created the following map of international weapon export in 2010 (from top 7 exporters). R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...