merge multiple .csv files

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

merge multiple .csv files

btc1
Am trying to merge about 15 .csv tables - tried a test run but came up with
0 rows (no data for each variable/column head)

> CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE)
> CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact Math.csv", header=TRUE)
> testmerge<-merge(CAHSEE.EA.feb.2009,CAHSEE.IM.MATH.2009)
> testmerge
 [1] Grade          LocalStudentID MathPassed     MathScaleScore SchoolCode

 [6] LastName       FirstName      ELAPassed      ELAScaleScore
 MathTestDate
<0 rows> (or 0-length row.names)

I know several variables are shared in both sheets. Please advise.

        [[alternative HTML version deleted]]

______________________________________________
[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: merge multiple .csv files

Erik Iverson-3
On 02/09/2011 09:21 PM, Benjamin Caldwell wrote:

> Am trying to merge about 15 .csv tables - tried a test run but came up with
> 0 rows (no data for each variable/column head)
>
>> CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE)
>> CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact Math.csv", header=TRUE)
>> testmerge<-merge(CAHSEE.EA.feb.2009,CAHSEE.IM.MATH.2009)
>> testmerge
>   [1] Grade          LocalStudentID MathPassed     MathScaleScore SchoolCode
>
>   [6] LastName       FirstName      ELAPassed      ELAScaleScore
>   MathTestDate
> <0 rows>  (or 0-length row.names)
>
> I know several variables are shared in both sheets. Please advise.

Please provide a reproducible example, otherwise we have no idea what
your objects that are giving you trouble look like.  You can use the
?dput function to facilitate this.

In general, I end up with your situation when I have data that differ
between the common names in the two data.frames. You might try the "by"
argument in merge...

Best.
--Erik

______________________________________________
[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: merge multiple .csv files

Bill.Venables
In reply to this post by btc1
You want advice?

1. Write sentences that contain a subject and where appropriate, an object as well.  This makes your email just that bit more polite.  This list is not a paid service.

2. The "sheets" may have variables in common, but do they have the same name in both, and the same class, and some values in common?  

You do not give us very much to go on.  

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin Caldwell
Sent: Thursday, 10 February 2011 1:22 PM
To: r-help
Subject: [R] merge multiple .csv files

Am trying to merge about 15 .csv tables - tried a test run but came up with
0 rows (no data for each variable/column head)

> CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE)
> CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact Math.csv", header=TRUE)
> testmerge<-merge(CAHSEE.EA.feb.2009,CAHSEE.IM.MATH.2009)
> testmerge
 [1] Grade          LocalStudentID MathPassed     MathScaleScore SchoolCode

 [6] LastName       FirstName      ELAPassed      ELAScaleScore
 MathTestDate
<0 rows> (or 0-length row.names)

I know several variables are shared in both sheets. Please advise.

        [[alternative HTML version deleted]]

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

Re: merge multiple .csv files

btc1
Very well, Bill. all = TRUE seemed to fix the problem.

On Wed, Feb 9, 2011 at 7:54 PM, <[hidden email]> wrote:

> You want advice?
>
> 1. Write sentences that contain a subject and where appropriate, an object
> as well.  This makes your email just that bit more polite.  This list is not
> a paid service.
>
> 2. The "sheets" may have variables in common, but do they have the same
> name in both, and the same class, and some values in common?
>
> You do not give us very much to go on.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Benjamin Caldwell
> Sent: Thursday, 10 February 2011 1:22 PM
> To: r-help
> Subject: [R] merge multiple .csv files
>
> Am trying to merge about 15 .csv tables - tried a test run but came up with
> 0 rows (no data for each variable/column head)
>
> > CAHSEE.EA.feb.2009<-read.csv("2009 CAHSEE EA feb 2009.csv", header=TRUE)
> > CAHSEE.IM.MATH.2009<-read.csv("2009 CAHSEE Impact Math.csv", header=TRUE)
> > testmerge<-merge(CAHSEE.EA.feb.2009,CAHSEE.IM.MATH.2009)
> > testmerge
>  [1] Grade          LocalStudentID MathPassed     MathScaleScore SchoolCode
>
>  [6] LastName       FirstName      ELAPassed      ELAScaleScore
>  MathTestDate
> <0 rows> (or 0-length row.names)
>
> I know several variables are shared in both sheets. Please advise.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [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.
>

        [[alternative HTML version deleted]]

______________________________________________
[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.