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

tbl_df breaks xtable() -- bug? #656

Closed
aammd opened this issue Oct 3, 2014 · 12 comments
Closed

tbl_df breaks xtable() -- bug? #656

aammd opened this issue Oct 3, 2014 · 12 comments
Assignees
Labels
Milestone

Comments

@aammd
Copy link

@aammd aammd commented Oct 3, 2014

I swear I used to be able to print tbl_df objects, but suddenly after upgrading to latest dplyr that went away:

library(dplyr)

iris %>% 
  tbl_df %>%
  xtable %>%
  print
## Error in .subset2(x, i, exact = exact) : subscript out of bounds
## doesn't work

iris %>% 
  tbl_df %>%
  as.data.frame %>%
  xtable %>%
  print
## works fine
@romainfrancois romainfrancois added this to the 0.3.1 milestone Oct 4, 2014
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Oct 4, 2014

I've' assigned you @hadley just so that you check I did not break anything else with the commit. Seems straightforward enough.

@happyshows
Copy link

@happyshows happyshows commented Oct 7, 2014

Hi, I have encountered a similar but really annoying issue, though I'm not sure whether it's due to xtable in dplyr or ggvis. (In addition, I found current release of dplyr breaks renderTable in shiny too)

> ds2 <- read.csv('test.csv')
> ds2 %>%  ggvis(~Family,~Measure)
Guessing layer_bars()   <- SUCCESS
> ds2 %>% tbl_df %>% ggvis(~Family,~Measure)
Guessing layer_bars()
Error in .subset2(x, i, exact = exact) : subscript out of bounds  <- FAIL

example dataset ('test.csv'):
   Family Measure
1       A    99.9
2       B    97.6
3       C     0.0
4       D    94.1
5       E    96.6
6       F    99.9
7       G    95.4
8       H    81.2
9       I    99.8
10      J    62.8
11      K    99.5
12      L    23.0
13      M     0.0
14      N    51.4
15      O     0.0
16      P    99.9
17      Q    99.9
18      R    98.3
19      S    99.9
20      T    99.9
21      U    38.1
22      V    88.6
23      W    98.9
24      X    72.7

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Oct 7, 2014

@happyshows can you create a reproducible example instead of using test.csv which we don't have.

@happyshows
Copy link

@happyshows happyshows commented Oct 7, 2014

@romainfrancois
Here you go

ds <- data.frame(x=letters[1:10],y=1:10) # --works
ds %>% ggvis(~x,~y) 

# --fails
# --Error in .subset2(x, i, exact = exact) : subscript out of bounds
ds %>% tbl_df %>% ggvis(~x,~y)

However,

cars %>%  ggvis(~speed,~dist)
cars %>% tbl_df %>% ggvis(~speed,~dist)

both works fine, as layer_points() seems to work
if I choose to plot as bar, similar error will happen

cars %>% mutate(speed = as.factor(speed)) %>% ggvis(~speed,~dist)
cars %>% tbl_df %>% mutate(speed = as.factor(speed)) %>% ggvis(~speed,~dist)

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Oct 7, 2014

It is indeed the same problem as this works fine with the dev_0_3_1 branch. This will be merged into the master branch once dplyr 0.3.0.1 is on CRAN.

BTW @happyshows I've slightly edited your comment so that the code format nicely. embed code chunks with ```.

@happyshows
Copy link

@happyshows happyshows commented Oct 7, 2014

@romainfrancois
Thanks, I did try to find a way to turn the codes into a block, but I'm not very familiar with markdown or github.
Do you have a estimated release time for the dev_0_3_1 on cran? I am currently working on a proof of concept model which utilizes shiny,dplyr,ggvis and would definitely want to fix broken ggvis charts before my meeting with vp soon.

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Oct 8, 2014

You can get it right now with:

install_github( "hadley/dplyr", ref = "dev_0_3_1" )

Now that dplyr 0.3.0.1 is on CRAN, it should not take too long for these to be merged into master. When dplyr 0.3.1 gets released depends on many things incl seriousness of bug reports we get about 0.3.0.1

@happyshows
Copy link

@happyshows happyshows commented Oct 8, 2014

@romainfrancois
Could you double check?

Downloading github repo hadley/dplyr@dev_0_3_1
Error in download(dest, src, auth) : client error: (404) Not Found

@hadley
Copy link
Member

@hadley hadley commented Oct 8, 2014

@happyshows we just merged the branch, so install_github("hadley/dplyr") should be adequate. Also check that you have devtools 1.6 or higher.

@happyshows
Copy link

@happyshows happyshows commented Oct 8, 2014

@hadley

looks like there is a more severe problem with this rev + ggvis (dplyr_0.3.0.9000+ggvis_0.4.0.9000)

mtcars %>% tbl_df %>% ggvis(~cyl,~mpg) %>% layer_bars()

I am seeing an empty chart with valid axis.

@hadley
Copy link
Member

@hadley hadley commented Nov 18, 2014

@happyshows can you please open a new issue with a minimal reprex if you're still having the problem?

@hadley hadley closed this in a9b861f Nov 18, 2014
@happyshows
Copy link

@happyshows happyshows commented Nov 19, 2014

@hadley with dplyr_0.3.0.9000 ggvis_0.4 , my code that had issues now works fine.

krlmlr pushed a commit to krlmlr/dplyr that referenced this issue Mar 2, 2016
krlmlr pushed a commit to krlmlr/dplyr that referenced this issue Mar 2, 2016
This is a little tricky to support commands like mtcars %>% tbl_df() %>% `[`(0) %>% `[`(1:5, ), which should yield a 5 x 0 tbl_df.

Closes tidyverse#656
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 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
4 participants