[R] Subtracting one based on an If

2010-02-18 Thread LCOG1

For the following:

 Bldgid-c(1000,1000,1000,1001,1002,1003,1003,1003)
 Maplot-c(2,20001,20002,3,30001,4,40001,40002)
 Area-c(40,170,160,50,100,100,90,110)
 #Construct Sample dataframe
 MultiLotBldgs..-data.frame(Bldgid,Maplot,Area)

CondoLots_ - tapply(MultiLotBldgs..$Maplot, MultiLotBldgs..$Bldgid, length)


CondoLots_ Returns:

1000 1001 1002 1003 
   3113 

What i want to do is to subtract 1 from the above for all cases where there
are more than one, so that  CondoLots_ returns:
1000 1001 1002 1003 
   2   112

I have tried 

for(i in 1:length(CondoLots_)){
ifelse(CondoLots_1){ 
 CondoLots2_-CondoLots_-1
}

 }
But it doesnt seem to work properly.  I think this should be simple.

Thanks in advance.
JR
-- 
View this message in context: 
http://n4.nabble.com/Subtracting-one-based-on-an-If-tp1561047p1561047.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.


Re: [R] Subtracting one based on an If

2010-02-18 Thread Ista Zahn
I think you can just use

CondoLots[CondoLots  1] - CondoLots[CondoLots  1] -1

-Ista

__
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.