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(dplyr)
##
## 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
library(ggplot2)
data_kesehatan <- read.csv("data_kesehatan.csv")
head(data_kesehatan)
## X id umur jenis_kelamin tinggi_badan berat_badan gula_darah tekanan_sistolik
## 1 1 1 33 Perempuan 159.5587 62.85027 80.08403 129.2978
## 2 2 2 59 Perempuan 152.9881 54.73592 79.20090 108.6373
## 3 3 3 39 Perempuan 156.1915 66.84162 99.64040 132.7729
## 4 4 4 64 Laki-laki 173.8024 54.83932 97.35650 108.7811
## 5 5 5 67 Perempuan 164.0242 62.21020 49.01314 129.4536
## 6 6 6 20 Perempuan 150.0967 61.15284 120.81147 136.4499
## tekanan_diastolik kolesterol skor_kesehatan
## 1 69.13882 181.3293 100.00000
## 2 73.34697 209.6954 100.00000
## 3 87.14848 176.3801 88.52949
## 4 75.68339 172.1841 100.00000
## 5 82.27615 138.6886 100.00000
## 6 92.94946 183.7165 75.39378
aggregate(tinggi_badan ~ jenis_kelamin, data = data_kesehatan, mean)
## jenis_kelamin tinggi_badan
## 1 Laki-laki 171.0215
## 2 Perempuan 159.6470
data_kesehatan[order(data_kesehatan$skor_kesehatan), ] |>
head(5)
## X id umur jenis_kelamin tinggi_badan berat_badan gula_darah
## 49 49 49 32 Perempuan 147.6860 72.92436 135.0351
## 11 11 11 68 Perempuan 162.9534 39.93666 155.9478
## 70 70 70 41 Laki-laki 170.6245 80.10678 135.5821
## 193 193 193 69 Laki-laki 176.1898 78.86749 143.8718
## 176 176 176 50 Laki-laki 165.8736 88.77864 115.3701
## tekanan_sistolik tekanan_diastolik kolesterol skor_kesehatan
## 49 141.0703 85.51274 218.5767 45.44594
## 11 123.0276 80.65068 224.3279 48.51474
## 70 136.8850 71.69891 238.1264 53.51686
## 193 135.8586 75.48187 236.9744 54.22224
## 176 129.4345 88.19628 232.7038 57.96087
data<-read.csv("data_kesehatan.csv")
data$kelompok_umur<- cut(data$umur, breaks = c(0,29,50,120),labels = c("<30", "30-50", ">50"), right = TRUE)
rata_skor <- aggregate(skor_kesehatan~kelompok_umur,data=data,mean)
print(rata_skor)
## kelompok_umur skor_kesehatan
## 1 <30 90.37880
## 2 30-50 89.35499
## 3 >50 89.53153
q2 <-data_kesehatan %>%
filter(gula_darah <110) %>%
filter(kolesterol <200) %>%
summarise(mean(skor_kesehatan))
q2
## mean(skor_kesehatan)
## 1 96.57272
`
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.