plots and loops with panel data

#1
Hey,

my questions:
1. What is the command for a plot of PersonA money against time?
2. I need a for loop over the string variable person which applies a function (e.g. mean of money from 2000 to 2002).

Data:
year, person, money
2000, PersonA, 100
2000, PersonB, 200
2001, PersonC, 200
2001, PersonA, 300
2001, PersonC, 600
2002, PersonA, 12000

in R:
Code:
a <- c(2000, 2000, 2001, 2001, 2001, 2002)
b <- c("PersonA", "PersonB", "PersonC", "PersonA", "PersonC", "PersonA")
c <- c(100, 200, 200, 300, 400, 200)
mydata <- data.frame(a,b,c)
colnames(mydata) <- c("year", "person", "money")


Thanks in advance!
 

trinker

ggplot2orBust
#2
This would get you there:

Code:
mydata$year <- factor(mydata$year)

library(ggplot2)
ggplot(mydata, aes(y=money, x=year)) + 
    geom_point() + 
    facet_grid(person~.)
 

trinker

ggplot2orBust
#4
Code:
ggplot(subset(mydata, person == "PersonA"), aes(y=money, x=year)) + 
    geom_point()
or:

Code:
with(subset(mydata, person == "PersonA"), plot(year, money))