1. 작업 디렉토리 설정
> setwd("d:/yul/temp")
2. ggplot2() 패키지 설치 후 로딩
> install.packages("ggplot2")
Installing package into ‘C:/Users/stu/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.nexr.com/bin/windows/contrib/3.0/ggplot2_0.9.3.1.zip'
Content type 'application/zip' length 2656354 bytes (2.5 Mb)
opened URL
downloaded 2.5 Mb
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\stu\AppData\Local\Temp\RtmpMB6sAR\downloaded_packages
> library(ggplot2)
3. csv 파일 읽어서 데이터 프레임 생성
> stemp <- read.csv("서울의기온변화.csv",header=T)
> stemp
Date Month MeanTemp MaxTemp MinTemp
1 20130101 1 -6 0 -11
2 20130102 1 -11 -6 -16
3 20130103 1 -14 -10 -19
4 20130104 1 -14 -8 -19
(이하 생략)
4. ggplot 을 이용하여 차트를 그린다.