Dataset in parts - how to join together?

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

Dataset in parts - how to join together?

majesty
Hello, I am new to R - could somebody suggest a function to investigate for the following:

I have data of the form

OA_CODE  VALUE
xyz           0.42
abd           0.10

but I have it in 12 separate files, each with output areas and value for one of 12 regions. I would like to combine the 12 files into one data set of the same format.

Any suggestion would be appreciated, I will read on it.
Reply | Threaded
Open this post in threaded view
|

Re: Dataset in parts - how to join together?

Joshua Wiley-2
Hi,

If all the datasets have the same columns, you could just use rbind().
 You might also look into the merge function.  You can look up the
documentation by typing (at the console):

?rbind
?merge

We can give more detailed help with a more detailed example.

Cheers,

Josh

On Sun, Jul 10, 2011 at 12:22 PM, majesty
<[hidden email]> wrote:

> Hello, I am new to R - could somebody suggest a function to investigate for
> the following:
>
> I have data of the form
>
> OA_CODE  VALUE
> xyz           0.42
> abd           0.10
>
> but I have it in 12 separate files, each with output areas and value for one
> of 12 regions. I would like to combine the 12 files into one data set of the
> same format.
>
> Any suggestion would be appreciated, I will read on it.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Dataset-in-parts-how-to-join-together-tp3658088p3658088.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.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
https://joshuawiley.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.
Reply | Threaded
Open this post in threaded view
|

Re: Dataset in parts - how to join together?

Hasan Diwan-2
In reply to this post by majesty
region1 <- read.table(file1, header=T)
...
region12 <- read.table(file12, header=T)
region <- data.frame(rbind(region1, region=1)..., rbind(region12, region=12)))
rm(region1, region2, region3..., region11, region12)

On 10 July 2011 12:22, majesty <[hidden email]> wrote:

> Hello, I am new to R - could somebody suggest a function to investigate for
> the following:
>
> I have data of the form
>
> OA_CODE  VALUE
> xyz           0.42
> abd           0.10
>
> but I have it in 12 separate files, each with output areas and value for one
> of 12 regions. I would like to combine the 12 files into one data set of the
> same format.
>
> Any suggestion would be appreciated, I will read on it.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Dataset-in-parts-how-to-join-together-tp3658088p3658088.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.
>



--
Sent from my mobile device
Envoyait de mon telephone mobil

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: Dataset in parts - how to join together?

majesty
Thanks a lot for both suggestions, I used region <- rbind(region1, region2..., region12), they were all already data frames. It worked well.