Statistics and Statistical Programming (Winter 2017)/R lecture outline: Week 3: Difference between revisions
From CommunityData
(Created page with "* problems folks ran into: ** loading data: *** load() versus read.csv() *** when things don't coopreate... *** library(foreign) * other things that have come up ** dates wit...") |
No edit summary |
||
Line 10: | Line 10: | ||
** defining functions | ** defining functions | ||
** merge() | ** merge() | ||
* looping | |||
** apply(), lapply(), sapply() | |||
** for looping | |||
* stuff related to distributions | * stuff related to distributions | ||
** | ** rep() | ||
** seq() | |||
** sample() | |||
** distribution functions: lets focus on *unif(): the key is on page 222 of Verzani | |||
*** The “d” functions return the p.d.f. of the distribution | |||
**** dunif(x=1, min=0, max=3) # 1/3 of the area is the to the left 1 | |||
*** The “p” functions return the c.d.f. of the distribution. | |||
**** dunif(q=2, min=0, max=3) #1/(b-a) is 2/3 | |||
*** The “q” functions return the quantiles. | |||
**** qunif(p=0.5, min=0, max=3) # half way between 0 and 3 | |||
*** The “r” functions return random samples from a distribution. | |||
**** runif(n=1, min=0, max=3) # a random value in [0,3] |
Revision as of 21:20, 17 January 2017
- problems folks ran into:
- loading data:
- load() versus read.csv()
- when things don't coopreate...
- library(foreign)
- loading data:
- other things that have come up
- dates with POSIXct(). dates will almost always be given to you as characters, and you need to parse them
- ordered() — really just a type of factor for ordinal data
- new things that are going to be very useful
- defining functions
- merge()
- looping
- apply(), lapply(), sapply()
- for looping
- stuff related to distributions
- rep()
- seq()
- sample()
- distribution functions: lets focus on *unif(): the key is on page 222 of Verzani
- The “d” functions return the p.d.f. of the distribution
- dunif(x=1, min=0, max=3) # 1/3 of the area is the to the left 1
- The “p” functions return the c.d.f. of the distribution.
- dunif(q=2, min=0, max=3) #1/(b-a) is 2/3
- The “q” functions return the quantiles.
- qunif(p=0.5, min=0, max=3) # half way between 0 and 3
- The “r” functions return random samples from a distribution.
- runif(n=1, min=0, max=3) # a random value in [0,3]
- The “d” functions return the p.d.f. of the distribution