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:
library(readr)
ChildrenAsthma_Survey <- read_csv("C:/Users/otuata4438/Downloads/ChildrenAsthma Survey.csv")
## New names:
## Rows: 20 Columns: 9
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (9): ...1, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
View(ChildrenAsthma_Survey)
x <- c(12,7,3,4.2,18, 2,54,-21,8,-5)
result.mean <- mean(x)
print(result.mean)
## [1] 8.22
result.mean <- mean(x,trim= 0.3)
print(result.mean)
## [1] 5.55
x <- c(12,7,3,4.2,18, 2,54,-21,8,-5, NA)
result.mean <- mean(x,na.rm=FALSE)
print(result.mean)
## [1] NA
median(x)
## [1] NA
median(x, na.rm = TRUE)
## [1] 5.6
library(readr)
ChildrenAsthma_Survey <- read_csv("C:/Users/otuata4438/Downloads/ChildrenAsthma Survey.csv")
## New names:
## Rows: 20 Columns: 9
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (9): ...1, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
library(readr)
View(ChildrenAsthma_Survey)
CAS <- ChildrenAsthma_Survey
View(CAS)
mean(CAS$Q1)
## [1] 9.1
table(CAS$Q2)
##
## 1 2
## 10 10
prop.table(table(CAS$Q2))
##
## 1 2
## 0.5 0.5
table(CAS$Q3)
##
## 1 2 3 4 5 6 7
## 3 2 2 3 5 4 1
prop.table(table(CAS$Q3))
##
## 1 2 3 4 5 6 7
## 0.15 0.10 0.10 0.15 0.25 0.20 0.05
communityChildAsthma <- (600/54786)*1000
print(communityChildAsthma)
## [1] 10.9517
AA <-CAS[CAS$Q3==5, ]
AA
## # A tibble: 5 × 9
## ...1 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 7 1 5 1 1 1 6 1
## 2 6 2 1 5 1 1 1 6 1
## 3 12 3 1 5 1 1 1 5 0
## 4 13 4 1 5 1 3 1 3 0
## 5 19 11 2 5 1 3 0 4 0
?table
## starting httpd help server ... done
table(AA$Q5)
##
## 1 3
## 3 2
print(AA)
## # A tibble: 5 × 9
## ...1 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 7 1 5 1 1 1 6 1
## 2 6 2 1 5 1 1 1 6 1
## 3 12 3 1 5 1 1 1 5 0
## 4 13 4 1 5 1 3 1 3 0
## 5 19 11 2 5 1 3 0 4 0
``` r
prop.table(table(AA$Q5 != 5))
##
## TRUE
## 1
table(AA$Q5 !=5)
##
## TRUE
## 5
table(AA$Q2)
##
## 1 2
## 4 1
AA$Q2
## [1] 1 1 1 1 2
table(AA$Q4)
##
## 1
## 5
prop.table(table(AA$Q4))*100
##
## 1
## 100
WK <- CAS[CAS$Q3==6, ]
WK
## # A tibble: 4 × 9
## ...1 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4 14 2 6 1 4 9 1 0
## 2 5 6 1 6 1 5 0 1 0
## 3 14 16 1 6 1 1 1 5 1
## 4 20 12 1 6 1 1 1 4 1
table(WK$Q4)
##
## 1
## 4
table(WK$Q5)
##
## 1 4 5
## 2 1 1
prop.table((table(WK$Q5)))
##
## 1 4 5
## 0.50 0.25 0.25
LK <- CAS[CAS$Q3==1, ]
LK
## # A tibble: 3 × 9
## ...1 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 13 2 1 1 2 1 3 1
## 2 10 8 2 1 1 2 1 1 9
## 3 11 7 1 1 1 2 1 3 9
table(LK$Q4)
##
## 1
## 3
table(LK$Q5)
##
## 2
## 3
prop.table((table(LK$Q5)))
##
## 2
## 1
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.