DOC PREVIEW
Berkeley STAT 133 - Lecture Notes

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Traffic flow on highways in California• Loop detectors at 22,000 locations,• Transmit data every 30 seconds• Collect 2GB a day, and store 4TBFor each of three lanes,flow (number of cars) andoccupancy (the proportion of time there was a car over the loop)were recorded in successive five minute intervals.We have 1740 such five minute intervals.Lane 1 is the leftmost lane, lane 2 is in the center, and lane 3 is the rightmost.– Typeset by FoilTEX – 1Statistical problem:Occupancy can be viewed as a measure of congestion.• What is the distribution of lane occupancy?• Do you think that the distribution of occupancy is symmetric or skewed? Why?• Are there any unusual features of the distribution?• How does occupancy in different lanes relate to each other?Let’s go to R and see what we can find.– Typeset by FoilTEX – 2Recap Topics• Variables – vectors, data frames• Managing session and variables• Input/Output and Data – data from web, data to files• Graphics – devices for display– Typeset by FoilTEX – 3VariablesVariables have a name and a value.To access the value we use the name. Variables allow us to• Store state on the computer• Store a value without needing to recompute it• Write a general expression, e.g. sqrt(aˆ 2 + bˆ 2)• Reduce redundancy (and mistakes)n = 10x = rnorm(n)sum(x) / n– Typeset by FoilTEX – 4Variable NamesVariable Names must follow some rules:• May not start with a digit or underscore• May contain numbers, characters (upper and lower case), and some punctuation,period . and underscoreare okay,but most other other are not, e.g. commas, quotation marks, and # are not.• Case-sensitive, so x and X are different.• Use meaningful names.• Avoid names that have a meaning in R, e.g. function names such as c, t, s, .C– Typeset by FoilTEX – 5Managing Sessions and VariablesWe can manage our variables with R functions• List all variablesobjects()• Remove one or more variablesrm(x, y)• Save variables for future usesave(x, y, z, file = “myfile.rda”)• Restore variablesload(“myfile.rda”)• Alternatively, an entire workspace may also be saved, and it will be automatically loadedwhen you start R up again.> q()Save workspace image? [y/n/c]:But it keeps EVERYTHING!– Typeset by FoilTEX – 6Managing Sessions and Variables• Keeping track of the code you write:– To see the code that you have executed in the R sessionhistory(max.show = Inf)savehistory(”myCode.R”)– To evaluate code that you have written and saved in a filesource(”myRevisedCode.R”)• To get help with functions, begin your session by starting the help browser:help.start()then when you need specific help on a function you can ask for it as followshelp(plot)or?plot– Typeset by FoilTEX –


View Full Document
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?