[R-sig-Geo] Manipulate extract output

Gustavo Carvalho gustavo.bio+R at gmail.com
Mon Apr 25 23:21:22 CEST 2011


Something like this should work:

bleh <- structure(list(`1` = structure(list(a = 1:10, b = 21:30),
.Names = c("a",
"b"), row.names = c(NA, -10L), class = "data.frame"), `2` = structure(list(
    a = 31:40, b = 41:50), .Names = c("a", "b"), row.names = c(NA,
-10L), class = "data.frame"), `3` = structure(list(a = 51:60,
    b = 61:70), .Names = c("a", "b"), row.names = c(NA, -10L), class =
"data.frame")), .Names = c("1",
"2", "3"))

bleh

cbind(Reduce(rbind, bleh), plot = rep(names(bleh), times = sapply(bleh, NROW)))

Don't forget to set the names attribute of your list.

Gustavo.

On Mon, Apr 25, 2011 at 3:45 PM, jm3389 <jm3389 at columbia.edu> wrote:
> I have an additional question.
>
> I know have extracted multiple bands and my list layout has changed.
>
> [[50]]
>      SMA-clipped_1 SMA-clipped_2 SMA-clipped_3
>  [1,]  0.0632362440    0.14176662     0.8255592
>  [2,]  0.1722273529    0.10599104     0.7607671
>  [3,]  0.1722273529    0.10599104     0.7607671
>  [4,]  0.2838407159    0.05971635     0.6902863
>  [5,]  0.0257746875    0.15945776     0.8517801
>  [6,]  0.2064613551    0.06632594     0.7841757
>  [7,]  0.2064613551    0.06632594     0.7841757
>  [8,]  0.2621570826    0.02389294     0.7842789
>  [9,]  0.2310775816    0.04211631     0.7626599
> [10,]  0.0287268255    0.18798502     0.8102853
> [11,]  0.0848897994    0.09991057     0.8653935
> [12,]  0.0848897994    0.09991057     0.8653935
> [13,]  0.1673026830    0.01770168     0.8713655
> [14,]  0.1527486742    0.03026910     0.8653567
> [15,]  0.0003926796    0.14994104     0.8714772
> [16,]  0.0003926796    0.14994104     0.8714772
> [17,]  0.0026585322    0.10952766     0.9157249
>
> [[51]]
>      SMA-clipped_1 SMA-clipped_2 SMA-clipped_3
>  [1,]    0.15911901     0.3241347     0.5089146
>  [2,]    0.15911150     0.3826110     0.4281845
>  [3,]    0.15911150     0.3826110     0.4281845
>  [4,]    0.10494564     0.2808739     0.5892844
>  [5,]    0.14055550     0.2827841     0.5563493
>  [6,]    0.13600963     0.3378267     0.4836067
>
>
>
> How can I get the same output but with this time 3 bands?
>
>      SMA-clipped_1 | SMA-clipped_2 | SMA-clipped_3 | Plot_ID
> [1,]  0.0632362440    0.14176662     0.8255592             [[50]]
>  [2,]  0.1722273529    0.10599104     0.7607671            [[50]]
>  [3,]  0.1722273529    0.10599104     0.7607671            [[50]]
>  [4,]  0.2838407159    0.05971635     0.6902863            [[50]]
>  [5,]  0.0257746875    0.15945776     0.8517801            [[50]]
>  [6,]  0.2064613551    0.06632594     0.7841757            [[50]]
>  [7,]  0.2064613551    0.06632594     0.7841757            [[50]]
>  [8,]  0.2621570826    0.02389294     0.7842789            [[50]]
>  [9,]  0.2310775816    0.04211631     0.7626599            [[50]]
> [10,]  0.0287268255    0.18798502     0.8102853           [[50]]
> [11,]  0.0848897994    0.09991057     0.8653935           [[50]]
> [12,]  0.0848897994    0.09991057     0.8653935           [[50]]
> [13,]  0.1673026830    0.01770168     0.8713655           [[50]]
> [14,]  0.1527486742    0.03026910     0.8653567           [[50]]
> [15,]  0.0003926796    0.14994104     0.8714772           [[50]]
> [16,]  0.0003926796    0.14994104     0.8714772           [[50]]
> [17,]  0.0026585322    0.10952766     0.9157249           [[50]]
>
>
> jm3389 wrote:
>>
>> My bad forgot to add utils::
>>
>> it's working ! Thanks a lot Gustavo
>>
>>>utils::stack(X)
>>              values       ind
>> 1     0.0850569680   1
>> 2     0.1152195707   1
>> 3     0.0702793971   1
>> 4     0.0702793971   1
>> 5     0.1055974513   1
>> 6     0.1036369652   1
>> 7     0.0935368910   1
>> 8     0.0935368910   1
>> 9     0.0967371687   1
>> 10    0.1253680587   1
>> 11    0.1569617689   1
>> 12    0.0930611789   1
>>
>>
>>>
>>>  On Sun, Apr 24, 2011 at 11:15 AM, Gustavo Carvalho [via R-sig-geo] <
>>>  [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=6301600&i=1&by-user=t>>
>>> wrote:
>>> >
>>> >> Dear Joseph,
>>> >>
>>> >> Could you please try this?
>>> >>
>>> >> names(X) <- 1:length(X)
>>> >> stack(X)
>>
>>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Manipulate-extract-output-tp6301073p6303557.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list