Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading in merged cells - need to know number of columns they span #166

Closed
lindsayplatt opened this issue Apr 6, 2016 · 3 comments
Closed

Comments

@lindsayplatt
Copy link

I am trying to read excel files that have merged cells as column names. In the example below, there is no way to determine that Merged Column Name applies to only Column Name 1 and Column Name 2, or that Column name 2 corresponds to two columns of content.

It would be helpful if read_excel could give information about the number of rows/columns that merged cells span.

In Excel:

Merged Column Name
Column Name 1 Column Name 2 Column Name 3 Column Name 3
Content Content Content Content Content

Data frame in R looks like:

Merged Column Name NA NA NA NA
Column Name 1 Column Name 2 NA Column Name 3 Column Name 3
Content Content Content Content Content
@jennybc
Copy link
Member

jennybc commented Apr 6, 2016

Is this the sort of R data frame you would expect in this case (I'm assuming you did not mean to repeat Column Name 3):

Merged Column Name Merged Column Name Merged Column Name something else
Column Name 1 Column Name 2 Column Name 2 Column Name 3 Column Name 4
Content Content Content Content Content

Or maybe this?

MCN.1 MCN.2a MCN.2b something else
Content Content Content Content Content

In any case, you might also be interested in the TableToLongForm package:

https://cran.r-project.org/web/packages/TableToLongForm/index.html
https://www.stat.auckland.ac.nz/~joh024/Research/TableToLongForm/
https://journal.r-project.org/archive/2014-2/oh.pdf

@burchill
Copy link

I've made a pull request that has the behavior of the first example @jennybc gave: #220
However, be warned: column names that have the same name are a pain in the but.

@jennybc
Copy link
Member

jennybc commented Jan 19, 2017

As discussed in #220 and above, it's best to handle these problems via other packages. There are no near term plans to get into merged cell issues here.

@jennybc jennybc closed this as completed Jan 19, 2017
@lock lock bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants