Difference between revisions of "Getting Started with R"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) |
PeterHarding (talk | contribs) |
||
Line 58: | Line 58: | ||
files <- list.files(pattern="*.csv") | files <- list.files(pattern="*.csv") | ||
files | files | ||
data <- lapply(files, read.table, sep=",", header=T) | data <- lapply(files, read.table, sep=",", header=T) | ||
data | data | ||
stuff <- as.data.frame(do.call(rbind, data)) | stuff <- as.data.frame(do.call(rbind, data)) | ||
stuff | stuff | ||
dim(stuff) | dim(stuff) | ||
Revision as of 12:36, 17 September 2013
Some Commands
Misc
data <- read.table(filename,header=TRUE) # Read tab or space delimited file with a header csv_data <- read.table(filename,header=TRUE,sep=',') # Read csv files with a header v1 <- c(1,2,3,4,5,6,7) # Create a vector from these values v2 <- c(1:10) # Create a vector from 1 to 10 v3 <- c(v1,v2) # Concatenate the vectors matrix1 <- cbind(v1,v2) # Column bind into a 2 x n matrix ls # List objects
Mean, SD, etc.
> sapply(h, length) WList_Len 4599 > sapply(h, mean) WList_Len 15.6845 > sapply(h, sd) WList_Len 15.74873 >
Some Links
- https://www.zoology.ubc.ca/~schluter/R/calculate/
- http://www.r-tutor.com/elementary-statistics/numerical-measures/mean
- http://stat.ethz.ch/R-manual/R-patched/library/stats/html/median.html
- http://www.cyclismo.org/tutorial/R/index.html
- http://answers.oreilly.com/topic/2597-how-to-compute-basic-statistics-with-r/
- http://grokbase.com/g/r/r-help
Personality Project
- http://www.personality-project.org/r/r.commands.html
- http://www.personality-project.org/r/r.guide.html
- http://personality-project.org/r/r.short.html
- http://www.personality-project.org/r/psych/HowTo/
Command History
files <- list.files(pattern="*.csv") files data <- lapply(files, read.table, sep=",", header=T) data stuff <- as.data.frame(do.call(rbind, data)) stuff dim(stuff) print(dframe) print(stuff) mean(stuff) sd(stuff) sapply(stuff, length) sapply(stuff, mean) sapply(stuff, sd) getwd() ls() ls options() history() history(max.show=Inf)