Please take a look at the introduction to R too ... > df <- read.delim(textConnection(Lines),sep="") > df A B C D 1 0.1 0.7 0.9 0.80 2 0.2 0.6 0.8 0.70 3 0.4 0.8 0.7 0.76 > d['A-B'] <- with(df, A-B) Error in d["A-B"] <- with(df, A - B) : object 'd' not found > d$v1 <- with(df, A-B) Error in d$v1 <- with(df, A - B) : object 'd' not found > d Error: object 'd' not found > df$v1 <- with(df, A-B) > df A B C D v1 1 0.1 0.7 0.9 0.80 -0.6 2 0.2 0.6 0.8 0.70 -0.4 3 0.4 0.8 0.7 0.76 -0.4 > df$v2 <- with(df, C-D) > df A B C D v1 v2 1 0.1 0.7 0.9 0.80 -0.6 0.10 2 0.2 0.6 0.8 0.70 -0.4 0.10 3 0.4 0.8 0.7 0.76 -0.4 -0.06
On Mon, Jan 31, 2011 at 7:02 AM, Ramya <ramya.vict...@gmail.com> wrote: > > Hi, > > I have a Dataframe. > > A B C D > 0.1 0.7 0.9 0.8 > 0.20 0.60 0.80 0.70 > 0.40 0.80 0.70 0.76 > > I need a resultant dataframe > > (A-B) (C-D) > -0.6 0.1 > -0.40 0.1 > -0.40 -0.06 > > Any suggestion would be of a great help > > Thanks > Ramya > > -- > View this message in context: > http://r.789695.n4.nabble.com/Finding-a-Diff-within-a-Dataframe-columns-tp3247943p3247943.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.