***geom_text
library(gcookbook)
library(ggplot2)
## Name Code Year GDP laborrate healthexp infmortality
## 1 Afghanistan AFG 1960 55.60700 NA NA NA
## 2 Afghanistan AFG 1961 55.66865 NA NA NA
## 3 Afghanistan AFG 1962 54.35964 NA NA NA
## 4 Afghanistan AFG 1963 73.19877 NA NA NA
## 5 Afghanistan AFG 1964 76.37303 NA NA NA
## 6 Afghanistan AFG 1965 94.09873 NA NA NA
ggplot(countries,aes(x=healthexp,y=infmortality))+
geom_point()
## Warning: Removed 8205 rows containing missing values (geom_point).
Warning message:Removed 8205 rows containing missing values (geom_point). ###We have to remove rows
First, create a new data frame;
data<-subset(countries,healthexp>6000)
ggplot(data,aes(x=healthexp,y=infmortality))+
geom_point()+
geom_text(aes(label=Name),size=4)
ggplot(data,aes(x=healthexp,y=infmortality))+ geom_point()+ annotate(“text”,x=7000,y=6,label=“Swiss”)
ggplot(data,aes(x=healthexp,y=infmortality))+
geom_point()+
annotate("text",x=7000,y=6,label="this is a sentence")