From 6e3e27345103147c37954fe7b9e3976709548456 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 29 Jun 2013 08:52:41 -0700 Subject: A few fixes --- r.html.markdown | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'r.html.markdown') diff --git a/r.html.markdown b/r.html.markdown index ad2a4559..1ace3ed5 100644 --- a/r.html.markdown +++ b/r.html.markdown @@ -7,7 +7,7 @@ author_url: http://github.com/e99n09 R is a statistical computing language. -```r +```python # Comments start with hashtags. @@ -16,9 +16,9 @@ R is a statistical computing language. # Protip: hit COMMAND-ENTER to execute a line -################################################################################### +######################### # The absolute basics -################################################################################### +######################### # NUMERICS @@ -119,9 +119,9 @@ myFunc <- function(x) { # Called like any other R function: myFunc(5) # => [1] 19 -################################################################################### +######################### # Fun with data: vectors, matrices, data frames, and arrays -################################################################################### +######################### # ONE-DIMENSIONAL @@ -243,7 +243,7 @@ array(c(c(c(2,300,4),c(8,9,0)),c(c(5,60,0),c(66,7,847))), dim=c(3,2,2)) # LISTS (MULTI-DIMENSIONAL, POSSIBLY RAGGED, OF DIFFERENT TYPES) # Finally, R has lists (of vectors) -list1 <- list(time = 1:40, price = c(rnorm(40,.5*list1$time,4))) # generate random +list1 <- list(time = 1:40, price = c(rnorm(40,.5*list1$time,4))) # random list1 # You can get items in the list like so @@ -251,9 +251,9 @@ list1$time # You can subset list items like vectors list1$price[4] -################################################################################### +######################### # The apply() family of functions -################################################################################### +######################### # Remember mat? mat @@ -281,9 +281,9 @@ install.packages("plyr") require(plyr) ?plyr -################################################################################### +######################### # Loading data -################################################################################### +######################### # "pets.csv" is a file on the internet pets <- read.csv("http://learnxinyminutes.com/docs/pets.csv") @@ -292,14 +292,14 @@ head(pets, 2) # first two rows tail(pets, 1) # last row # To save a data frame or matrix as a .csv file -write.csv(pets, "pets2.csv") # to make a new .csv file in the working directory +write.csv(pets, "pets2.csv") # to make a new .csv file # set working directory with setwd(), look it up with getwd() # Try ?read.csv and ?write.csv for more information -################################################################################### +######################### # Plots -################################################################################### +######################### # Scatterplots! plot(list1$time, list1$price, main = "fake data") -- cgit v1.2.3