Published:
Updated:

TIL

  • Study
    • Today, I reviewed Part 2 of the “Introduction to Statistics”.
    • I realized that passively viewing the lecture on a mobile phone without a keyboard was inefficient for my learning.
    • Swiching to a PC environment significantly enhanced my comprehension and allowed for practice.
    • Additionally, I supplemented the lecture by reviewing the corresponding textbook chapters.
    • The R script provided below illustrates the statistical computing exercises covered in Part 2.

R Code

library(ggplot2)

transp = c("bicycle", "bus", "bus", "walking", "bus", "bicycle", "bicycle", "bus")

dat1 = data.frame(transp)

library(forcats)
ggplot(data=dat1) + geom_bar(mapping=aes(x=fct_infreq(transp))) + xlab("Transportation")

obesity = factor(c("underweight", "normal", "overweight", "obese"), 
                 levels=c("underweight", "normal", "overweight", "obese"))

count = c(6, 69, 27, 13)
perc = count / sum(count) * 100

dat2 = data.frame(obesity, count, perc)

ggplot(data=dat2) + geom_bar(mapping=aes(x=obesity, y=perc), stat="identity") + xlab("Obesity") + ylab("Percentage(%)")

table(transp)
dat3 = data.frame(transportation=c("bus", "bicycle", "walking"), 
                  count=c(15, 13, 4))

Tags:

Categories:

Published:
Updated:

Leave a comment