Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #set up some data
  2. mycodat <- read.csv(stdin(),header=TRUE)
  3. country,obsv
  4. Spain,4
  5. Spain,5
  6. Portugal,3
  7. Portugal,7
  8. Venezuala,8
  9. Zambia,2
  10. Zambia,4
  11. Zambia,3
  12.  
  13. regdat <- data.frame(country=unique(mycodat$country)) # the thing you're trying to get
  14. # the country means into
  15.  
  16. # Now generate the summary and put it in the data
  17. regdat$meanobsv <- with(mycodat,tapply(obsv,country,mean))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement