Graphics Reference
In-Depth Information
[
1
]
FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE TRUE
[
13
]
FALSE TRUE TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
[
25
]
TRUE TRUE TRUE
Then we'll use that Boolean vector to overwrite all the otherentries in
Name1
with
NA
:
cdat$Name1[!idx]
<-
NNA
This is what the result looks like:
cdat
Name Code Year GDP laborrate healthexp infmortality Name1
Andorra AND
2009
NA
NA
3089.636
3.1
<
NA
>
Australia AUS
2009 42130
65.2 3867.429
4.2
<
NA
>
...
Switzerland CHE
2009 63524
66.9 7140.729
4.1
Switzerland
United Kingdom GBR
2009 35163
62.2 3285.050
4.7
United Kingdom
United States USA
2009 45744
65.0 7410.163
6.6
United States
Now we can make the plot (
Figure 5-33
). This time, we'll also expand the xrange so that the
text will fit:
ggplot(cdat, aes(x
=
healthexp, y
=
infmortality))
+
geom_point()
+
geom_text(aes(x
=
healthexp
+
100
, label
=
Name1), size
=
4
, hjust
=
0
)
+
xlim(
2000
,
10000
)