R code help to change table format

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

R code help to change table format

peziza
I am trying to input an OTU table into EstimateS, however, the format of the OTU table has to be changed to fit the format EstimateS will accept. In R, I would like to change the format of the OTU table (from excel).  Here is what I need to do, take Example 1 and create Example 2.  The problem is that I have hundreds of OTUs, so I can't do this by hand (and I'd love to have a code that I could use for different OTU tables).
Thanks!

Example 1                                             Example 2
Species         Abundance                         Species
1                             3                                           1
2                             2                                           1
3                             2                                           1
4                             2                                           2
5                             4                                           2
                                                                             3
                                                                             3
                                                                             4
                                                                             4
                                                                             5                                                                              5
                                                                             5
                                                                             5
                                                                             5
Reply | Threaded
Open this post in threaded view
|

Re: R code help to change table format

Rui Barradas
Hello,

You should say what is the package you are using, EstimateS returns
hundreds of hits. [ package sos, findFn() ].

As for the question, try


sp <- 1:5
ab <- c(3, 2, 2, 2, 4)
rep(sp, ab)


Hope this helps,

Rui Barradas

Em 10-07-2012 18:23, peziza escreveu:

> I am trying to input an OTU table into EstimateS, however, the format of the
> OTU table has to be changed to fit the format EstimateS will accept. In R, I
> would like to change the format of the OTU table (from excel).  Here is what
> I need to do, take Example 1 and create Example 2.  The problem is that I
> have hundreds of OTUs, so I can't do this by hand (and I'd love to have a
> code that I could use for different OTU tables).
> Thanks!
>
> Example 1                                             Example 2
> Species         Abundance                         Species
> 1                             3                                           1
> 2                             2                                           1
> 3                             2                                           1
> 4                             2                                           2
> 5                             4                                           2
>
> 3
>
> 3
>
> 4
>
> 4
>
> 5
> 5
>
> 5
>
> 5
>
> 5
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-code-help-to-change-table-format-tp4636022.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.