[R] More issues with apply

LCOG1 jroll at lcog.org
Fri Jan 13 22:55:46 CET 2012


Hi all, 
     Please consider the following:

DataSet1.. <-
data.frame(Bldgtype=c("SFDM","SFDM","SFDM","SFDM","SFDM","SFDM","APT"),
Taz=c("254","254","254","564","564","564","564"),stringsAsFactors = FALSE)
PeriodResType_Zx <- tapply(as.character(DataSet1..$Bldgtype),
as.character(DataSet1..$Taz), table)
PeriodResType_Zx 

$`254`

SFDM 
   3 

$`564`

 APT SFDM 
   1    3 

DataSet2.. <-
data.frame(Bldgtype=c("SFDM","SFDM","SFDM","SFDM","SFDM","SFDM"),
Taz=c("254","245","564","564","564","564"))
PeriodResType_Zx <- tapply(DataSet2..$Bldgtype, DataSet2..$Taz, table)
PeriodResType_Zx 

Data set 1 returns the desired outcome, an array with elements consisting of
a labeled table

Data set 2 returns an array without the table labeled.  

This is occuring becuase there are not a variety of Bldgtypes in data set
two, but this is a reality of the data so how can i get the data into the
same format, with a Bldgtype descriptor in the array like the Data set 1
result?

Thanks all

Cheers


--
View this message in context: http://r.789695.n4.nabble.com/More-issues-with-apply-tp4293529p4293529.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list