在 tibble 中查看超过 10 行时遇到问题
Having trouble viewing more than 10 rows in a tibble
首先 - 我是编程和 R 的初学者,如果这是一个愚蠢的问题,请原谅。我无法查看由以下代码生成的 tibble 中的十行以上。
下面的代码用于查找书中最常用的单词。我得到了我想要的结果,但是我如何查看超过10行的数据。据我所知,它没有被保存为我可以调用的数据框。
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
当我想看到像这样的管道的输出时,我经常做的是直接将其通过管道传输到 View()
library(dplyr)
library(tidytext)
tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE) %>%
View()
如果你想将它保存到一个新的对象中以便以后使用,你可以在管道的开头将它分配给一个新的变量名。
word_counts <- tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE)
如果您想留在控制台中,请注意 tibbles 已定义打印 S3 方法,因此您可以使用诸如(参见 ?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
请注意,tail
不使用 tibbles,因此如果您想将 tail
与 tibbles 结合使用以查看数据的末尾,则必须执行以下操作:
print(tail(very_long, n = 3), n = 3)
# A tibble: 3 x 1
value
<int>
1 998
2 999
3 1000
虽然这个问题有一个完美的答案,@Marius 的评论要短得多,所以:
tidy_books %>% print(n = 100)
正如你所说的你是初学者,你可以用你想要的任何数字替换n = 100
也如你是初学者,看全table:
tidy_books %>% print(n = nrow(tidy_books))
首先 - 我是编程和 R 的初学者,如果这是一个愚蠢的问题,请原谅。我无法查看由以下代码生成的 tibble 中的十行以上。
下面的代码用于查找书中最常用的单词。我得到了我想要的结果,但是我如何查看超过10行的数据。据我所知,它没有被保存为我可以调用的数据框。
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
当我想看到像这样的管道的输出时,我经常做的是直接将其通过管道传输到 View()
library(dplyr)
library(tidytext)
tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE) %>%
View()
如果你想将它保存到一个新的对象中以便以后使用,你可以在管道的开头将它分配给一个新的变量名。
word_counts <- tidy_books %>%
anti_join(stop_words) %>%
count(word, sort=TRUE)
如果您想留在控制台中,请注意 tibbles 已定义打印 S3 方法,因此您可以使用诸如(参见 ?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
请注意,tail
不使用 tibbles,因此如果您想将 tail
与 tibbles 结合使用以查看数据的末尾,则必须执行以下操作:
print(tail(very_long, n = 3), n = 3)
# A tibble: 3 x 1
value
<int>
1 998
2 999
3 1000
虽然这个问题有一个完美的答案,@Marius 的评论要短得多,所以:
tidy_books %>% print(n = 100)
正如你所说的你是初学者,你可以用你想要的任何数字替换n = 100
也如你是初学者,看全table:
tidy_books %>% print(n = nrow(tidy_books))