[R] cbind or ?

Henrique Dallazuanna wwwhsd at gmail.com
Fri Jan 15 20:34:51 CET 2010


Try this:

`class<-`(lapply(1:length(QuanImpUnsold),
function(idx)c(QuanImpUnsold[[idx]], PARCELS[[idx]])), "by")

On Fri, Jan 15, 2010 at 5:06 PM, L.A. <romsa at millect.com> wrote:
>
>
> Hey Guys,
>  It sure seems I get stuck on things that should be easy.
> Heres my question:
>
> PARCELS<-by(ResImp[ , "ACCOUNTNO"], ResImp["Property"], length)
>
>> PARCELS
> Property: UNSOLD
> [1] 9053
> -------------------------------------------------------------------------------------------
> Property: SOLD
> [1] 578
> -------------------------------------------------------------------------------------------
> Property: SubSale
> [1] 52
>
>
> QuanImpUnsold<-with(ResImp, by(Appraisal, Property,
> FUN=function(x)quantile(x,
> probs = c(1,25,50,75,90)/100)))
>
>> QuanImpUnsold
> Property: UNSOLD
>      1%      25%      50%      75%      90%
>  18106.4  92817.0 131794.0 185742.0 262365.0
> -------------------------------------------------------------------------------------------
> Property: SOLD
>       1%       25%       50%       75%       90%
>  35335.65 105034.25 138967.00 181971.25 254946.00
> -------------------------------------------------------------------------------------------
> Property: SubSale
>       1%       25%       50%       75%       90%
>  37255.72 117055.50 149314.00 196207.00 259288.60
>
>
> tb<-cbind(PARCELS, QuanImpUnsold)
>
> tb
>        PARCELS QuanImpUnsold
> UNSOLD  9053    Numeric,5
> SOLD    578     Numeric,5
> SubSale 52      Numeric,5
>
> This is what I want
>
>> tb
> Property: UNSOLD
>   Parcels   1%      25%      50%      75%      90%
>    9053    18106.4  92817.0 131794.0 185742.0 262365.0
> -------------------------------------------------------------------------------------------
> Property: SOLD
>   Parcels   1%       25%       50%       75%       90%
>     578    35335.65 105034.25 138967.00 181971.25 254946.00
> -------------------------------------------------------------------------------------------
> Property: SubSale
>  Parcels   1%       25%       50%       75%       90%
>      52   37255.72 117055.50 149314.00 196207.00 259288.60
>
> Any suggestions?
> Thanks,
> L.A.
>
> Don't know if this helps:
>> str(PARCELS)
>  'by' int [1:3(1d)] 9053 578 52
>  - attr(*, "dimnames")=List of 1
>  ..$ Property: chr [1:3] "UNSOLD" "SOLD" "SubSale"
>  - attr(*, "call")= language by.default(data = ResImp[, "ACCOUNTNO"],
> INDICES = ResImp["Property"],      FUN = length)
>
>> str(QuanImpUnsold)
> List of 3
>  $ UNSOLD : Named num [1:5] 18106 92817 131794 185742 262365
>  ..- attr(*, "names")= chr [1:5] "1%" "25%" "50%" "75%" ...
>  $ SOLD   : Named num [1:5] 35336 105034 138967 181971 254946
>  ..- attr(*, "names")= chr [1:5] "1%" "25%" "50%" "75%" ...
>  $ SubSale: Named num [1:5] 37256 117056 149314 196207 259289
>  ..- attr(*, "names")= chr [1:5] "1%" "25%" "50%" "75%" ...
>  - attr(*, "dim")= int 3
>  - attr(*, "dimnames")=List of 1
>  ..$ Property: chr [1:3] "UNSOLD" "SOLD" "SubSale"
>  - attr(*, "call")= language by.default(data = Appraisal, INDICES =
> Property, FUN = function(x) quantile(x,      probs = c(1, 25, 50, 75,
> 90)/100))
>  - attr(*, "class")= chr "by"
>
> --
> View this message in context: http://n4.nabble.com/cbind-or-tp1015187p1015187.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list