Having trouble viewing more than 10 rows in a tibble
Solution 1
What I often do when I want to see the output of a pipe like that is pipe it straight to View()
library(dplyr)
library(tidytext)
tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE) %>%
View()
If you want to save this to a new object that you can work with later, you can assign it to a new variable name at the beginning of the pipe.
word_counts <- tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE)
Solution 2
Although this question has a perfectly ok answer, the comment from @Marius is much shorter, so:
tidy_books %>% print(n = 100)
As you say you are a beginner you can replace n = 100
with any number you want
Also as you are a beginner, to see the whole table:
tidy_books %>% print(n = nrow(tidy_books))
Solution 3
If you want to stay in the console, then note that tibbles have print S3 methods defined so you can use options such as (see ?print.tbl
):
very_long <- as_tibble(seq(1:1000))
print(very_long, n = 3)
# A tibble: 1,000 x 1
value
<int>
1 1
2 2
3 3
# ... with 997 more rows
Note, tail
doesn't play with tibbles, so if you want to combine tail
with tibbles to look at the end of your data, then you have to do something like:
print(tail(very_long, n = 3), n = 3)
# A tibble: 3 x 1
value
<int>
1 998
2 999
3 1000
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on July 25, 2020Comments
-
Admin almost 4 years
First off - I am a beginner at programming and R, so excuse me if this is a silly question. I am having trouble viewing more than ten rows in a tibble that is generated from the following code.
The code below is meant to find the most common words in a book. I am getting the results I want, but how do I view more than 10 rows of data. To my knowledge, it is not being saved as a data frame that I can call.
library(dplyr) tidy_books %>% anti_join(stop_words) %>% count(word, sort=TRUE) Joining, by = "word" # A tibble: 3,397 x 2 word n <chr> <int> 1 alice 820 2 queen 247 3 time 141 4 king 122 5 head 112 6 looked 100 7 white 97 8 round 96 9 voice 86 10 tone 81 # ... with 3,387 more rows
-
Agile Bean almost 5 yearsfor some reason,
print(n = ...)
turns on scientific notation in the tibble display. is there away to avoid that? -
Alpha Bravo over 3 yearsYou can do
options(scipen=10)
to penalize the display of scientific notation. Higher numbers penalize (and thus reduce) the chance of scientific notation being displayed, lower numbers (like -10) increase the chance.