library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
orgdat <- read.csv("organdata.csv", header = T)
head(orgdat)
## country year donors pop pop_dens gdp gdp_lag health health_lag
## 1 Australia <NA> NA 17065 0.2204433 16774 16591 1300 1224
## 2 Australia 1/1/91 12.09 17284 0.2232723 17171 16774 1379 1300
## 3 Australia 1/1/92 12.35 17495 0.2259980 17914 17171 1455 1379
## 4 Australia 1/1/93 12.51 17667 0.2282198 18883 17914 1540 1455
## 5 Australia 1/1/94 10.25 17855 0.2306484 19849 18883 1626 1540
## 6 Australia 1/1/95 10.18 18072 0.2334516 21079 19849 1737 1626
## pubhealth roads cerebvas assault external txp_pop world opt
## 1 4.8 136.5954 682 21 444 0.9375916 Liberal In
## 2 5.4 122.2518 647 19 425 0.9257116 Liberal In
## 3 5.4 112.8322 630 17 406 0.9145470 Liberal In
## 4 5.4 110.5451 611 18 376 0.9056433 Liberal In
## 5 5.4 107.9810 631 17 387 0.8961075 Liberal In
## 6 5.5 111.6091 592 16 371 0.8853475 Liberal In
## consent_law consent_practice consistent ccode
## 1 Informed Informed Yes Oz
## 2 Informed Informed Yes Oz
## 3 Informed Informed Yes Oz
## 4 Informed Informed Yes Oz
## 5 Informed Informed Yes Oz
## 6 Informed Informed Yes Oz
orgdat %>% select(1:6) %>% sample_n(size = 10)
## country year donors pop pop_dens gdp
## 1 Netherlands 1/1/97 14.4 15611 37.5896942 23753
## 2 Ireland 1/1/93 17.1 3576 5.0889426 14927
## 3 Spain 1/1/93 22.6 39096 7.7266349 14359
## 4 Switzerland 1/1/00 14.0 7184 17.3988859 29837
## 5 Canada 1/1/94 13.9 29036 0.2912159 21428
## 6 Belgium 1/1/97 22.5 10181 30.7583082 22936
## 7 Ireland <NA> NA 3514 5.0007115 12917
## 8 United Kingdom 1/1/00 13.2 58817 24.2134947 25271
## 9 Denmark 1/1/92 16.1 5171 12.0004641 19644
## 10 France 1/1/98 16.5 58398 10.5889393 24044
p1 <- ggplot(data = orgdat, mapping = aes(x = year, y = donors))
p1 + geom_point()
## Warning: Removed 34 rows containing missing values or values outside the scale range
## (`geom_point()`).

p2 <- ggplot(data = orgdat, mapping = aes(x = year, y = donors))
p2 + geom_line(aes(group = country)) + facet_wrap(~country)
## Warning: Removed 34 rows containing missing values or values outside the scale range
## (`geom_line()`).

p3 <- ggplot(data = orgdat, mapping = aes(x = country, y = donors))
p3 + geom_boxplot()
## Warning: Removed 34 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

p3 <- ggplot(data = orgdat, mapping = aes(x = country, y = donors))
p3 + geom_boxplot() + coord_flip()
## Warning: Removed 34 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

p4 <- ggplot(data = orgdat,
mapping = aes(x = reorder(country, donors, na.rm=TRUE),
y = donors, color = world))
p4 +
geom_jitter(position = position_jitter(width = 0.15, height = 0.05)) +
labs(x = NULL, y = "Donors") +
coord_flip() +
theme_minimal()
## Warning: Removed 34 rows containing missing values or values outside the scale range
## (`geom_point()`).
