Doubt_merging data

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

Doubt_merging data

Lara Dutra Silva
Hello,

I gather data from 5 objects and 5 data. frames and  would like to join
information.

join:  pb_SM + pb_T + pb_P + pb_F + pb_SJ = total_pb


join: sdmdata_SM + sdmdata_T + sdmdata_P + sdmdata_F + sdmdata_SJ
=total_sdmdata
code:
rbind, merge?

total_pb<-   ??

total_sdmdata<-   ??


1

absvals_SM <- extract(grid_present_SM, absences_10000)

presvals_SM <- extract(grid_present_SM, LSM)

pb_SM <- c(rep(1, nrow(presvals_SM), rep(0, nrow(absvals_SM)))

sdmdata_SM <- data.frame(cbind(pb_SM, rbind(presvals_SM, absvals_SM))

                                            ######
2

absvals_T <- extract(grid_present_T, absences_10000)

presvals_T <- extract(grid_present_T, LT)

pb_T <- c(rep(1, nrow(presvals_T), rep(0, nrow(absvals_T)))

sdmdata_T <- data.frame(cbind(pb_T, rbind(presvals_T, absvals_T))

                                          ######

3

absvals_P <- extract(grid_present_T, absences_10000)

presvals_P <- extract(grid_present_P, LP)

pb_P <- c(rep(1, nrow(presvals_P), rep(0, nrow(absvals_P)))

sdmdata_P <- data.frame(cbind(pb_P, rbind(presvals_P, absvals_P))

                                ######

4

absvals_F <- extract(grid_present_F, absences_10000)

presvals_F <- extract(grid_present_F, LF)

pb_F <- c(rep(1, nrow(presvals_F), rep(0, nrow(absvals_F)))

sdmdata_F <- data.frame(cbind(pb_F, rbind(presvals_F, absvals_F))


                           ######

5

absvals_SJ <- extract(grid_present_SJ, absences_10000)

presvals_SJ <- extract(grid_present_SJ, LSJ)

pb_SJ <- c(rep(1, nrow(presvals_SJ), rep(0, nrow(absvals_SJ)))

sdmdata_SJ <- data.frame(cbind(pb_SJ, rbind(presvals_SJ, absvals_SJ))


Regards,

Silva





<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Sem
vírus. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Doubt_merging data

Jeff Newmiller
I don't see how anyone can help you if you don't provide the input data (or a fake version of the data) you are using.

On April 8, 2018 3:47:55 PM PDT, Lara Dutra Silva <[hidden email]> wrote:

>Hello,
>
>I gather data from 5 objects and 5 data. frames and  would like to join
>information.
>
>join:  pb_SM + pb_T + pb_P + pb_F + pb_SJ = total_pb
>
>
>join: sdmdata_SM + sdmdata_T + sdmdata_P + sdmdata_F + sdmdata_SJ
>=total_sdmdata
>code:
>rbind, merge?
>
>total_pb<-   ??
>
>total_sdmdata<-   ??
>
>
>1
>
>absvals_SM <- extract(grid_present_SM, absences_10000)
>
>presvals_SM <- extract(grid_present_SM, LSM)
>
>pb_SM <- c(rep(1, nrow(presvals_SM), rep(0, nrow(absvals_SM)))
>
>sdmdata_SM <- data.frame(cbind(pb_SM, rbind(presvals_SM, absvals_SM))
>
>                                            ######
>2
>
>absvals_T <- extract(grid_present_T, absences_10000)
>
>presvals_T <- extract(grid_present_T, LT)
>
>pb_T <- c(rep(1, nrow(presvals_T), rep(0, nrow(absvals_T)))
>
>sdmdata_T <- data.frame(cbind(pb_T, rbind(presvals_T, absvals_T))
>
>                                          ######
>
>3
>
>absvals_P <- extract(grid_present_T, absences_10000)
>
>presvals_P <- extract(grid_present_P, LP)
>
>pb_P <- c(rep(1, nrow(presvals_P), rep(0, nrow(absvals_P)))
>
>sdmdata_P <- data.frame(cbind(pb_P, rbind(presvals_P, absvals_P))
>
>                                ######
>
>4
>
>absvals_F <- extract(grid_present_F, absences_10000)
>
>presvals_F <- extract(grid_present_F, LF)
>
>pb_F <- c(rep(1, nrow(presvals_F), rep(0, nrow(absvals_F)))
>
>sdmdata_F <- data.frame(cbind(pb_F, rbind(presvals_F, absvals_F))
>
>
>                           ######
>
>5
>
>absvals_SJ <- extract(grid_present_SJ, absences_10000)
>
>presvals_SJ <- extract(grid_present_SJ, LSJ)
>
>pb_SJ <- c(rep(1, nrow(presvals_SJ), rep(0, nrow(absvals_SJ)))
>
>sdmdata_SJ <- data.frame(cbind(pb_SJ, rbind(presvals_SJ, absvals_SJ))
>
>
>Regards,
>
>Silva
>
>
>
>
>
><http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>Sem
>vírus. www.avg.com
><http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
><#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Doubt_merging data

MacQueen, Don
In reply to this post by Lara Dutra Silva
Your email is hard to read because you sent html email. Please send plain text.

You will need to say what you mean by "join". It's not a standard term with a universally agreed upon meaning within R.

If you have 5 data frames, each with 5 rows, and it makes sense that after joining you should have one data frame with 25 rows and the same number of columns, then rbind() is probably what you want.

If you have 5 data frames, each with 5 rows, and it makes sense that after joining you should have one data frame with 5 rows, and more columns, then merge() is probably what you want.

But some of your code suggests you have a somewhat complex data structure, so it's hard to say.

extract() is not a base R function; when asking for help one should indicate where non-base functions come from.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 
On 4/8/18, 3:47 PM, "R-help on behalf of Lara Dutra Silva" <[hidden email] on behalf of [hidden email]> wrote:

    Hello,
   
    I gather data from 5 objects and 5 data. frames and  would like to join
    information.
   
    join:  pb_SM + pb_T + pb_P + pb_F + pb_SJ = total_pb
   
   
    join: sdmdata_SM + sdmdata_T + sdmdata_P + sdmdata_F + sdmdata_SJ
    =total_sdmdata
    code:
    rbind, merge?
   
    total_pb<-   ??
   
    total_sdmdata<-   ??
   
   
    1
   
    absvals_SM <- extract(grid_present_SM, absences_10000)
   
    presvals_SM <- extract(grid_present_SM, LSM)
   
    pb_SM <- c(rep(1, nrow(presvals_SM), rep(0, nrow(absvals_SM)))
   
    sdmdata_SM <- data.frame(cbind(pb_SM, rbind(presvals_SM, absvals_SM))
   
                                                ######
    2
   
    absvals_T <- extract(grid_present_T, absences_10000)
   
    presvals_T <- extract(grid_present_T, LT)
   
    pb_T <- c(rep(1, nrow(presvals_T), rep(0, nrow(absvals_T)))
   
    sdmdata_T <- data.frame(cbind(pb_T, rbind(presvals_T, absvals_T))
   
                                              ######
   
    3
   
    absvals_P <- extract(grid_present_T, absences_10000)
   
    presvals_P <- extract(grid_present_P, LP)
   
    pb_P <- c(rep(1, nrow(presvals_P), rep(0, nrow(absvals_P)))
   
    sdmdata_P <- data.frame(cbind(pb_P, rbind(presvals_P, absvals_P))
   
                                    ######
   
    4
   
    absvals_F <- extract(grid_present_F, absences_10000)
   
    presvals_F <- extract(grid_present_F, LF)
   
    pb_F <- c(rep(1, nrow(presvals_F), rep(0, nrow(absvals_F)))
   
    sdmdata_F <- data.frame(cbind(pb_F, rbind(presvals_F, absvals_F))
   
   
                               ######
   
    5
   
    absvals_SJ <- extract(grid_present_SJ, absences_10000)
   
    presvals_SJ <- extract(grid_present_SJ, LSJ)
   
    pb_SJ <- c(rep(1, nrow(presvals_SJ), rep(0, nrow(absvals_SJ)))
   
    sdmdata_SJ <- data.frame(cbind(pb_SJ, rbind(presvals_SJ, absvals_SJ))
   
   
    Regards,
   
    Silva
   
   
   
   
   
    <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    Sem
    vírus. www.avg.com
    <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
   
    [[alternative HTML version deleted]]
   
    ______________________________________________
    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    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 -- To UNSUBSCRIBE and more, see
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.