3.4 연습문제

다음의 연습문제는 plot과 관련 문제이다.

  1. R Console 창에서 다음을 입력하여 결과를 관찰하시오.
    demo(graphics)
    demo(image)
    demo(persp)
    demo(colors)
  1. ggplot2 package를 사용해 보시오. 기본 홈페이지는 https://ggplot2.tidyverse.org/ 이지만 https://ggplot2-book.org/ 를 방문해 보면 package를 만든 사람이 쓴 책을 볼 수 있다.

  2. 다음과 같이 하여 기본 package인 lattice package의 demo를 관찰해 보시오.

    require(lattice)
    demo(lattice)
  1. R에는 많은 내장된 자료가 있다. 그 중에 Theoph는 12명의 사람에게 각 320mg의 theophylline을 경구로 투약하면서, 약 24시간에 걸쳐 11회(투약 전 1회, 투약 후 10회)의 혈중농도를 측정한 것이다. 이 자료를 이용하여 그림을 4가지로 그렸다. 어떻게 다른 지 비교해 보시오. 그리고, subject ID가 순서대로 나오지 않는데, 어떤 순서로 출력되었는지 알아보시오.
    Theoph # Theophylline concentration after 320mg single oral dose of 12 subjects

    # Figure 1
    plot(Theoph)

    # Figure 2
    dev.new()
    plot(conc ~ Time, Theoph)

    # Figure 3
    require(lattice)
    dev.new()
    xyplot(conc ~ Time | Subject, Theoph, type="o")

    # Figure 4
    require(nlme)
    dev.new()
    plot(Theoph)
  1. R 기본 package인 nlme 내에는 6명의 어른에게 cefamandole을 15mg/kg의 용량으로 10분간 정주 후 14회 채혈하여 농도를 측정한 자료가 있다. 위와 유사하게 plot하여 비교해 보시오.
    require(nlme)
    Cefamandole