-
Notifications
You must be signed in to change notification settings - Fork 129
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
print.tbl_df() fixup #51
Changes from 21 commits
44d9cf9
92a7191
ead7eca
ade1107
3dea6e5
68f726b
c928632
3f4f968
23e1860
3c60db9
606e1f0
40c032c
179e3b1
e5e62ca
390196f
e10ba05
880533d
22fa833
3dd4c87
f469b20
c858418
51f5693
46bd4c8
1477a2d
e965547
262424a
b35106c
127cb99
1e9afc1
c66545a
396863f
eaaa0e8
c1e71be
fee06df
e019d2f
a8454a9
f4321f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ You can create a tibble from an existing object with `as_data_frame()`: | |
``` r | ||
library(tibble) | ||
as_data_frame(iris) | ||
#> Source: local data frame [150 x 5] | ||
#> | ||
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species | ||
#> <dbl> <dbl> <dbl> <dbl> <fctr> | ||
#> 1 5.1 3.5 1.4 0.2 setosa | ||
|
@@ -29,7 +27,7 @@ as_data_frame(iris) | |
#> 8 5.0 3.4 1.5 0.2 setosa | ||
#> 9 4.4 2.9 1.4 0.2 setosa | ||
#> 10 4.9 3.1 1.5 0.1 setosa | ||
#> .. ... ... ... ... ... | ||
#> ... with 140 more rows | ||
``` | ||
|
||
This will work for reasonable inputs that are already data.frame, list, matrix, or table. | ||
|
@@ -38,8 +36,6 @@ You can also create a new tibble from vectors that represent the columns with `d | |
|
||
``` r | ||
data_frame(x = 1:5, y = 1, z = x ^ 2 + y) | ||
#> Source: local data frame [5 x 3] | ||
#> | ||
#> x y z | ||
#> <int> <dbl> <dbl> | ||
#> 1 1 1 2 | ||
|
@@ -59,8 +55,6 @@ frame_data( | |
"a", 2, 3.6, | ||
"b", 1, 8.5 | ||
) | ||
#> Source: local data frame [2 x 3] | ||
#> | ||
#> x y z | ||
#> <chr> <dbl> <dbl> | ||
#> 1 a 2 3.6 | ||
|
@@ -84,23 +78,22 @@ Tibbles have a refined print method that shows only the first 10 rows, and all t | |
``` r | ||
library(nycflights13) | ||
flights | ||
#> Source: local data frame [336,776 x 16] | ||
#> | ||
#> year month day dep_time dep_delay arr_time arr_delay carrier tailnum | ||
#> <int> <int> <int> <int> <dbl> <int> <dbl> <chr> <chr> | ||
#> 1 2013 1 1 517 2 830 11 UA N14228 | ||
#> 2 2013 1 1 533 4 850 20 UA N24211 | ||
#> 3 2013 1 1 542 2 923 33 AA N619AA | ||
#> 4 2013 1 1 544 -1 1004 -18 B6 N804JB | ||
#> 5 2013 1 1 554 -6 812 -25 DL N668DN | ||
#> 6 2013 1 1 554 -4 740 12 UA N39463 | ||
#> 7 2013 1 1 555 -5 913 19 B6 N516JB | ||
#> 8 2013 1 1 557 -3 709 -14 EV N829AS | ||
#> 9 2013 1 1 557 -3 838 -8 B6 N593JB | ||
#> 10 2013 1 1 558 -2 753 8 AA N3ALAA | ||
#> .. ... ... ... ... ... ... ... ... ... | ||
#> Variables not shown: flight <int>, origin <chr>, dest <chr>, air_time | ||
#> <dbl>, distance <dbl>, hour <dbl>, minute <dbl>. | ||
#> year month day dep_time sched_dep_time dep_delay arr_time | ||
#> <int> <int> <int> <int> <int> <dbl> <int> | ||
#> 1 2013 1 1 517 515 2 830 | ||
#> 2 2013 1 1 533 529 4 850 | ||
#> 3 2013 1 1 542 540 2 923 | ||
#> 4 2013 1 1 544 545 -1 1004 | ||
#> 5 2013 1 1 554 600 -6 812 | ||
#> 6 2013 1 1 554 558 -4 740 | ||
#> 7 2013 1 1 555 600 -5 913 | ||
#> 8 2013 1 1 557 600 -3 709 | ||
#> 9 2013 1 1 557 600 -3 838 | ||
#> 10 2013 1 1 558 600 -2 753 | ||
#> ... with 336,766 more rows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "and" would be better than "with" here to better line up with the next line |
||
#> ... and 12 more variables (sched_arr_time <int>, arr_delay <dbl>, carrier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just |
||
#> <chr>, flight <int>, tailnum <chr>, origin <chr>, dest <chr>, air_time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if we could keep the type with the variable name, but that's probably going to be tricky |
||
#> <dbl>, distance <dbl>, hour <dbl>, minute <dbl>, time_hour <time>) | ||
``` | ||
|
||
Tibbles are strict about subsetting. If you try to access a variable that does not exist, you'll get an error: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
Source: local data frame [2 x 8] | ||
|
||
a b c d | ||
<dbl> <int> <lgl> <chr> | ||
1 1.0 1 TRUE a | ||
2 2.5 2 FALSE b | ||
Variables not shown: e | ||
... with 4 more variables: e | ||
<fctr>, f <date>, g <time>, | ||
h <list>. | ||
h <list> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
a b c d | ||
<dbl> <int> <lgl> <chr> | ||
1 1 1 TRUE a | ||
... with 1 more rows, and 4 | ||
more variables |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
a b c d | ||
<dbl> <int> <lgl> <chr> | ||
1 1 1 TRUE a | ||
.. ... ... ... ... | ||
Variables not shown: e | ||
<fctr>, f <date>, and 2 | ||
more <...>. | ||
a b c d | ||
<dbl> <int> <lgl> <chr> | ||
1 1 1 TRUE a | ||
... with 1 more rows, and 4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a test case where the length of a variable name is greater than the width? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's in the iris-3-5 test case below (width = 5). |
||
more variables: e <fctr>, f | ||
<date>, ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
Source: local data frame [150 x 5] | ||
|
||
Sepal.Length | ||
<dbl> | ||
1 5.1 | ||
2 4.9 | ||
3 4.7 | ||
.. ... | ||
Variables | ||
not | ||
shown: | ||
Sepal.Length | ||
<dbl> | ||
1 5.1 | ||
2 4.9 | ||
3 4.7 | ||
... | ||
with | ||
147 | ||
more | ||
rows, | ||
and | ||
4 | ||
more | ||
variables: | ||
Sepal.Width | ||
<dbl>, | ||
Petal.Length | ||
<dbl>, | ||
Petal.Width | ||
<dbl>, | ||
Species | ||
<fctr>. | ||
<fctr> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
Source: local data frame [150 x 5] | ||
|
||
Sepal.Length Sepal.Width | ||
<dbl> <dbl> | ||
1 5.1 3.5 | ||
2 4.9 3.0 | ||
3 4.7 3.2 | ||
4 4.6 3.1 | ||
5 5.0 3.6 | ||
.. ... ... | ||
Variables not shown: | ||
Sepal.Length Sepal.Width | ||
<dbl> <dbl> | ||
1 5.1 3.5 | ||
2 4.9 3.0 | ||
3 4.7 3.2 | ||
4 4.6 3.1 | ||
5 5.0 3.6 | ||
... with 145 more rows, and 3 | ||
more variables: | ||
Petal.Length <dbl>, | ||
Petal.Width <dbl>, Species | ||
<fctr>. | ||
<fctr> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Sepal.Length Sepal.Width Petal.Length Petal.Width Species | ||
<dbl> <dbl> <dbl> <dbl> <fctr> | ||
1 5.1 3.5 1.4 0.2 setosa | ||
2 4.9 3.0 1.4 0.2 setosa | ||
3 4.7 3.2 1.3 0.2 setosa | ||
4 4.6 3.1 1.5 0.2 setosa | ||
5 5.0 3.6 1.4 0.2 setosa | ||
6 5.4 3.9 1.7 0.4 setosa | ||
7 4.6 3.4 1.4 0.3 setosa | ||
8 5.0 3.4 1.5 0.2 setosa | ||
9 4.4 2.9 1.4 0.2 setosa | ||
10 4.9 3.1 1.5 0.1 setosa | ||
... with more rows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like getting rid of this line - it is nice to have an up front summary, but it does cost two lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still there for the non-data.frame sources in dplyr. The information is now available in the summary lines.
How about:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even: