Вы находитесь на странице: 1из 3

MYLab1

R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring
HTML, PDF, and MS Word documents. For more details on using R Markdown see
http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as
well as the output of any embedded R code chunks within the document. You can embed an
R code chunk like this:
summary(cars)

## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00

Including Plots
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of
the R code that generated the plot.
##
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':


##
## filter, lag

## The following objects are masked from 'package:base':


##
## intersect, setdiff, setequal, union

## Observations: 574
## Variables: 6
## $ date <date> 1967-07-01, 1967-08-01, 1967-09-01, 1967-10-01, 1967...
## $ pce <dbl> 507.4, 510.5, 516.3, 512.9, 518.1, 525.8, 531.5, 534....
## $ pop <int> 198712, 198911, 199113, 199311, 199498, 199657, 19980...
## $ psavert <dbl> 12.5, 12.5, 11.7, 12.5, 12.5, 12.1, 11.7, 12.2, 11.6,...
## $ uempmed <dbl> 4.5, 4.7, 4.6, 4.9, 4.7, 4.8, 5.1, 4.5, 4.1, 4.6, 4.4...
## $ unemploy <int> 2944, 2945, 2958, 3143, 3066, 3018, 2878, 3001, 2877,...

## date pce pop psavert


## Min. :1967-07-01 Min. : 507.4 Min. :198712 Min. : 1.900
## 1st Qu.:1979-06-08 1st Qu.: 1582.2 1st Qu.:224896 1st Qu.: 5.500
## Median :1991-05-16 Median : 3953.6 Median :253060 Median : 7.700
## Mean :1991-05-17 Mean : 4843.5 Mean :257189 Mean : 7.937
## 3rd Qu.:2003-04-23 3rd Qu.: 7667.3 3rd Qu.:290291 3rd Qu.:10.500
## Max. :2015-04-01 Max. :12161.5 Max. :320887 Max. :17.000
## uempmed unemploy
## Min. : 4.00 Min. : 2685
## 1st Qu.: 6.00 1st Qu.: 6284
## Median : 7.50 Median : 7494
## Mean : 8.61 Mean : 7772
## 3rd Qu.: 9.10 3rd Qu.: 8691
## Max. :25.20 Max. :15352

## Observations: 1,704
## Variables: 6
## $ country <fctr> Afghanistan, Afghanistan, Afghanistan, Afghanistan,...
## $ continent <fctr> Asia, Asia, Asia, Asia, Asia, Asia, Asia, Asia, Asi...
## $ year <int> 1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992...
## $ lifeExp <dbl> 28.801, 30.332, 31.997, 34.020, 36.088, 38.438, 39.8...
## $ pop <int> 8425333, 9240934, 10267083, 11537966, 13079460, 1488...
## $ gdpPercap <dbl> 779.4453, 820.8530, 853.1007, 836.1971, 739.9811, 78...

## Observations: 1,392,618
## Variables: 4
## $ Date_Time <chr> "01-MAY-2009 00:00", "01-MAY-2009 00:00", "01-MA...
## $ Sensor_ID <int> 4, 17, 18, 16, 2, 1, 13, 15, 9, 10, 12, 11, 5, 6...
## $ Sensor_Name <chr> "Town Hall (West)", "Collins Place (South)", "Co...
## $ Hourly_Counts <int> 209, 28, 36, 22, 52, 53, 17, 124, 5, 8, 2, 5, 15...

Question 4
student2012.sub <- readRDS("data/student_sub.rds")
table(student2012.sub$CNT)
australia <- student2012.sub[student2012.sub$CNT=="AUS",]
shanghai <- student2012.sub[student2012.sub$CNT=="QCN",]
mean(australia$PV1READ)
sd(australia$PV1READ)
mean(shanghai$PV1READ)
sd(shanghai$PV1READ)

Вам также может понравиться