[R] adding year information to a scatter plot

2010-05-02 Thread Ozan Bakis
Hi R users, I would like to add year information to each point in a scatter plot. The following example shows what i mean: df=data.frame(year=c(2001,2002,2003),a=c(8,9,7),b=c(100,90,95)) df plot(b~a,data=df) Now, I would like to see which point belongs to 2001, 2002 and 2003 in the above graphic

[R] conditional grouping of variables: ave or tapply or by or???

2009-04-23 Thread ozan bakis
Dear R Users, I have the following data frame: v1 <- c(rep(10,3),rep(11,2)) v2 <- sample(5:10, 5, replace = T) v3 <- c(0,1,2,0,2) df <- data.frame(v1,v2,v3) > df v1 v2 v3 1 10 9 0 2 10 5 1 3 10 6 2 4 11 7 0 5 11 5 2 I want to add a new column v4 such that its values are equal to the v

[R] function which can apply a function by a grouping variable and also hand over an additional variable, e.g. a weight

2010-10-01 Thread Ozan Bakis
Hi, I was wondering if there is an easy way to accomplish the following in R: Often I want to apply a function, e.g. weighted.quantile from the Hmisc package to grouped subsets of a data.frame (grouping variable) but then I also need to hand over the weights which seems not possible with summaryBy

[R] Installing R+Emacs+MikTeX editor on a USB drive

2010-11-12 Thread Ozan Bakis
Hi R-users, Since it has been already asked for several times, I would like to share my solution that I have gathered from several sources on internet for portable R+Emacs+MikTeX. This may also help some future R-users. My best, Ozan Installing R, MikTeX, Emacs (+auctex+aspell) on USB Useful inf

[R] conditional weighted quintiles

2009-01-18 Thread Ozan Bakis
uot;education"=c(0,5,5,0,0),"weight"=c(3,2,3,1,1)) x library(Hmisc) wtd.quantile(x$income,weights=x$weight) wtd.quantile(x$education,weights=x$weight) I would like to see the expenditure of each quintile conditional on income, i.e. the education expenditures of the