#load &see
data <- datasets::USPersonalExpenditure
head(data)
##                       1940   1945  1950 1955  1960
## Food and Tobacco    22.200 44.500 59.60 73.2 86.80
## Household Operation 10.500 15.500 29.00 36.5 46.20
## Medical and Health   3.530  5.760  9.71 14.0 21.10
## Personal Care        1.040  1.980  2.45  3.4  5.40
## Private Education    0.341  0.974  1.80  2.6  3.64
str(data)
##  num [1:5, 1:5] 22.2 10.5 3.53 1.04 0.341 44.5 15.5 5.76 1.98 0.974 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : chr [1:5] "Food and Tobacco" "Household Operation" "Medical and Health" "Personal Care" ...
##   ..$ : chr [1:5] "1940" "1945" "1950" "1955" ...
# transform to long form
library(reshape2)
mdata <- melt(data)  
head(mdata)
##                  Var1 Var2  value
## 1    Food and Tobacco 1940 22.200
## 2 Household Operation 1940 10.500
## 3  Medical and Health 1940  3.530
## 4       Personal Care 1940  1.040
## 5   Private Education 1940  0.341
## 6    Food and Tobacco 1945 44.500
#Def. colname
colnames(mdata) <- c("category", "year", "expenditure")
head(mdata)
##              category year expenditure
## 1    Food and Tobacco 1940      22.200
## 2 Household Operation 1940      10.500
## 3  Medical and Health 1940       3.530
## 4       Personal Care 1940       1.040
## 5   Private Education 1940       0.341
## 6    Food and Tobacco 1945      44.500
##transform the dollar amounts to log base 10  
logexp <- round(log10(mdata$expenditure),2)
head(logexp)
## [1]  1.35  1.02  0.55  0.02 -0.47  1.65
resultdata <- cbind(mdata,logexp)
##draw ggplot
library(ggplot2)
p0 <- ggplot(resultdata) +
  aes(x=logexp, y=category,color = logexp>mean(logexp))  +
  geom_point(size=rel(3)) +
  facet_grid(. ~ year) +
  geom_segment(aes(xend=logexp, yend=category, x=mean(logexp))) + 
  geom_vline(aes(xintercept=mean(logexp)))+
 scale_colour_manual(values = c("purple", "blue"))

       
p0 + theme(legend.position = 'top')