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

unnest chokes on syntactically invalid variable names #190

Closed
lukeanker opened this issue May 22, 2016 · 1 comment
Closed

unnest chokes on syntactically invalid variable names #190

lukeanker opened this issue May 22, 2016 · 1 comment

Comments

@lukeanker
Copy link

@lukeanker lukeanker commented May 22, 2016

unnest refuses to process data frames with syntactically invalid column names (e.g. containing spaces or beginning with numbers):

library(dplyr)
library(tidyr)
dat <- data.frame("foo bar" = I(list(1:2, 3)), check.names = F)
unnest(dat)
# Error in parse(text = x) : <text>:1:5: unexpected symbol
#1: foo bar
#         ^

unnest_(dat, names(dat))
# Error in parse(text = x) : <text>:1:5: unexpected symbol
#1: foo bar
#         ^

dat %>% rename(foobar=`foo bar`) %>% unnest
# Source: local data frame [3 x 1]
# 
#   foobar
#    (dbl)
#1      1
#2      2
#3      3

I don't know if it's a bug or if I'm using the function wrongly, but I think it worked in previous versions of tidyr. I'm packageVersion("tidyr") ‘0.4.1’ and packageVersion("dplyr") ‘0.4.3’

@hadley
Copy link
Member

@hadley hadley commented May 22, 2016

Simpler reprex:

library(tibble)
library(tidyr)

data_frame("foo bar" = list(1:2, 3)) %>% unnest()
@hadley hadley closed this in a41e127 May 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants