This our re-do of the dependent sample assignment from 2/10 Driving Reaction Time Under Distractive Conditions.docx
Monday 2/7/2011
Function |
Action |
length(object) |
number of elements/components |
dim(object) |
dimensions of an object |
str(object) |
structure of an object |
class(object) |
class or type of an object |
mode(object) |
how an object is stored |
names(object) |
names of components in an object |
c(object, object,...) |
combines objects into a vector |
cbind(object, object, ...) |
combines objects as columns |
rbind(object, object, ...) |
combines objects as rows |
object |
prints the object |
head(object) |
list the first part of the object |
tail(object) |
list the last part of the object |
ls() |
list current objects |
rm(object) |
delete an object |
newobject <- edit(object) |
edit object and save as newobject |
fix(object) |
edit in place |
To import data from an EXCEL file - RODBC package to access the files
install.packages ("RODBC")
Webscraping - the user extracts info imbedded in a web page using:
readlines ( ) grep ( ) gsub ( ) functions
Sunday 2/6/2011
Example for Linear Least Squares Regression:
http://www.cyclismo.org/tutorial/R/linearLeastSquares.html
When we type varialbename<-lm(what ever values we pass), we should issue summary(variablename) to get Residuals, Coefficients, Residual standard error, ...etc. issuing variablename will only show the coefficients! plot(myvariable) will give multiple plots (should discuss how to read them!!)
runif(n, min=0, max=1): It let us generate random deviates; however, unlike mvrnorm we can't specify the mean and the covariance matrix. We forgot to ask how we can specify min and max limit so we don't give unwanted values!
useful commands:
help.search("a topic")
example("a topic")
data() shows all datasets in the loaded packages
sink(file = "filename", append = FALSE, type = c("output", "message"), split = FALSE) to write the output to the file filename :) "split = TRUE write to both the file and the screen. Not quite sure what type is?
sink(): return the output back to the screen.
source("myfile") will submit the code from myfile to the current R session.
png("myfile.png") to redirect graphic output to myfile. We have to issue the drawing command (plot() for example) and then dev.off(). we can also use jpeg(), bmp() or pdf().
help(package="packagename"): to list the functions and datasets included in packagename
Shoe Wear Graphics
library(MASS)
data(shoes)
granova.ds(data.frame(shoes),revc=TRUE, main="Shoe Wear",xlab="Sole material B",ylab="Sole material A")
"More about comparing Two independent samples." Assignment:
To create the dataframe: Check http://msenux.redwoods.edu/math/R/dataframe.php for more information.
musicTypeA=c(26,21,22,26,19,22,26,25,24,21,23,23,18,29,22)
musicTypeB=c(18, 23, 21, 20, 20, 29, 20, 16, 20, 26, 21, 25, 17, 18, 19)
Lowry.A.B.dt=data.frame(A=musicTypeA,B=musicTypeB)
The updated function "es.twogps" that includes calculating the CI:
Questions: