
png("text-scatter.png",500,500)
attach(USArrests)
plot(Murder ~ UrbanPop, type="n")
text(Murder ~ UrbanPop, row.names(USArrests))
detach(USArrests)
dev.off()
plot(Murder ~ UrbanPop, type="n")
plot에서 type을 "n"으로 하면 그래프에 아무 것도 출력하지 않는다. 크기를 확보하기 위해서 사용한다.
text(Murder ~ UrbanPop, row.names(USArrests))
text는 그래프에 글자를 출력한다. row.names 함수는 데이터프레임의 행 이름을 뽑아주는 함수이다.
png("text-scatter.png",500,500)
그래프를 저장할 파일을 설정한다. 가로 500px, 세로 500px, 이름은 text-scatter.png 화면에 출력하려면 생략.
dev.off()
그래프 출력을 끝내고 파일로 저장한다.
attach(USArrests)
USArrests를 이름 탐색 경로에 포함시킨다. Murder라고만 써도 USArrest$Murder와 똑같아진다.
detach(USArrests)
attach의 효과를 끝낸다.