[R] simple subtraction in a single vector

Peter Alspach Peter.Alspach at plantandfood.co.nz
Wed Feb 10 03:45:34 CET 2010


Tena koe Keith

?which

perhaps.  As in:

which(Tanks=='h4')-which(Tanks=='a3')

HTH ...

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Marlin Keith Cox
> Sent: Wednesday, 10 February 2010 3:37 p.m.
> To: r-help at r-project.org
> Subject: [R] simple subtraction in a single vector
> 
> OK, this is very elementary, but I need help.  I have looked 
> in Verzani, past postings etc.
> 
> Problem:  I need to subtract the "length" date between "h4" 
> and "a3"  #which would be 4-1 I would rather not convert the 
> two columns into four columns (with headings being 
> "a3","a4","c4","h4").
> 
> 
> DF <- data.frame(length=c(1,2,3,4),
> Tanks=c("a3","a4","c4","h4"))
> 
> ???
> 
> Much appreciated, keith
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 



More information about the R-help mailing list