3. Previously in this group
n Introduction to R
n Reading Data into R (1)
n Reading Data into R (2)
Group Website: http://rpubs.com/kaz_yos/useR_at_HSPH
4. Menu
n mean and sd
n median, quantiles, IQR, max, min, and range
n skewness and kurtosis
n smarter ways of doing these
5. Ingredients
Statistics Programming
n Summary statistics for n vector and data frame
continuous data
n DATA$VAR extraction
n Normal data
n Indexing by [row,col]
n Non-normal data
n Various functions
n Normality check
n skewness(), kurtosis()
n summary()
n describe(), describeBy()
6. Data loaded
What’s next?
http://echrblog.blogspot.com/2011/04/statistics-on-states-with-systemic-or.html
8. Descriptive statistics is the
describing
discipline of quantitatively the
main features of a collection of data
http://en.wikipedia.org/wiki/Descriptive_statistics
10. Download comma-separated and Excel
Put them in folder
BONEDEN.DAT.txt
http://www.cengage.com/cgi-wadsworth/course_products_wp.pl?
fid=M20bI&product_isbn_issn=9780538733496
15. DATA$VAR is a vector
1 2 3 4 5 6 7 8
OR
“A” “B” “C” “D” “E” “F” “G” “H”
like strings with
values attached
16. Multiple vectors
of same length
tied together
Tied here
DATA is a data frame
1 2 3 4 5 6 7 8
“A” “B” “C” “D” “E” “F” “G” “H
1 2 3 4 5 6 7 8
“A” “B” “C” “D” “E” “F” “G” “H
1 2 3 4 5 6 7 8
“A” “B” “C” “D” “E” “F” “G” “H
17. Indexing: extraction of data from
data frame
Extract 1st to 15th rows Extract 1st to 12th columns
bone[1:15 , 1:12]
Colon in between
Don’t forget comma
45. Your turn adopted from Hadley Wickham
n Try summary on the dataset (data frame).
46. Various summary
measures library(psych)
describe
describe(x, na.rm = TRUE, interp = FALSE, skew =
TRUE, ranges = TRUE,trim = .1, type = 3)
type = 2 SAS
type = 1 Stata
47. Your turn adopted from Hadley Wickham
n describe(bone[,-1], type = 2)
48. Groupwise
summary library(psych)
describeBy
describeBy(x, group=NULL,mat=FALSE,type=3,...)
type = 2 SAS
type = 1 Stata
49. Your turn adopted from Hadley Wickham
bone data frame
without 1st columns zyg vector for grouping
n describeBy(bone[ , c(-1)] , bone$zyg , type = 2)
SAS method for
skewness and kurtosis
50. Ingredients
Statistics Programming
n Summary statistics for n vector and data frame
continuous data
n DATA$VAR extraction
n Normal data
n Indexing by [row,col]
n Non-normal data
n Various functions
n Normality check
n skewness(), kurtosis()
n summary()
n describe(), describeBy()