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

bind_rows fails with Error: not compatible with STRSXP #1389

Closed
safferli opened this issue Sep 7, 2015 · 9 comments
Closed

bind_rows fails with Error: not compatible with STRSXP #1389

safferli opened this issue Sep 7, 2015 · 9 comments
Assignees
Labels
Milestone

Comments

@safferli
Copy link

@safferli safferli commented Sep 7, 2015

I'm sorry if I'm just too much of an idiot, and am blind to boot. This might be related to #1346 but this is on non-empty data frames. What's plexing me is that do.call works, but bind_rows doesn't:

df <- lapply(1, function(x) data.frame(id=x, data=runif(5)))
df2 <- lapply(2:3, function(x) data.frame(id=x, data=runif(5)))

#doesn't work
bind_rows(df, df2)

#works
do.call(rbind, c(df, df2))

Am I doing something wrong here?

@npjc
Copy link
Contributor

@npjc npjc commented Sep 7, 2015

@safferli if you modify your bind_rows() call to the same as do.call() it works for me!

bind_rows(c(df, df2))
#> Source: local data frame [15 x 2]
#> 
#> id       data
#> (dbl)      (dbl)
#> 1      1 0.54358302
#> 2      1 0.77075381
#> 3      1 0.21797273
#> 4      1 0.24802491
#> 5      1 0.39316823
#> 6      2 0.50702872
#> 7      2 0.60293241
#> 8      2 0.90589808
#> 9      2 0.50936390
#> 10     2 0.47979525
#> 11     3 0.07552338
#> 12     3 0.07655688
#> 13     3 0.71382495
#> 14     3 0.70129482
#> 15     3 0.97582166

@safferli
Copy link
Author

@safferli safferli commented Sep 7, 2015

Indeed it does!

Is this always the case? If so, perhaps the documentation should be updated? It allows the simple supplying of dfs as arguments:

# You can either supply data frames as arguments
bind_rows(one, two)

@hadley
Copy link
Member

@hadley hadley commented Sep 7, 2015

You're not supplying two data frames - you're supplying two lists of data frames. We do need a better error message though.

@ahcyip
Copy link

@ahcyip ahcyip commented May 15, 2017

@romainfrancois Has this error message been fixed? I just tried to bind lists of data frames and I got the STRSXP message. #1389
I got the result I wanted by using sapply instead of lapply but it seems the error message is still confusing.

reprex:

listoflists<-list(list(data.frame(c(1,2,3),c("not","this","one")),data.frame(c(6,5,4),c("bind","this","one"))),
                  list(data.frame(c(1,2,3),c("not","this","one")),data.frame(c(3,2,1),c("bind","this","one"))),
                  list(data.frame(c(1,2,3),c("not","this","one")),data.frame(c(3,2,1),c("not","this","oneeither"))))
bind_rows(lapply(listoflists[c(1,2)],"[",2))

Result:
Error in bind_rows_(x, .id) : not compatible with STRSXP

@lionel-
Copy link
Member

@lionel- lionel- commented May 15, 2017

The proper reprex is:

x <- list(
  list(data.frame(c(1, 2, 3), c("not", "this", "one"))),
  list(data.frame(c(1, 2, 3), c("not", "this", "one")))
)
bind_rows(x)

It now says: Argument 1 can't be a list containing data frames

@lionel-
Copy link
Member

@lionel- lionel- commented May 15, 2017

Which is not an entirely accurate message. It can't be a list containing a list of data frames.

@ahcyip
Copy link

@ahcyip ahcyip commented May 15, 2017

Hi @lionel-

It now says: Argument 1 can't be a list containing data frames

I actually still get Error in bind_rows_(x, .id) : not compatible with STRSXP
using your reprex.

I am using dplyr 0.5.0

@lionel-
Copy link
Member

@lionel- lionel- commented May 15, 2017

The relevant version for bug reports is the current master branch which will become dplyr 0.6. You can install it with `devtools::install_github("tidyverse/dplyr").

@ahcyip
Copy link

@ahcyip ahcyip commented May 15, 2017

@lionel- Thanks for explaining!

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants