dplyr show all rows and columns for small data.frame inside a tbl_df

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

How do I force dplyr to show all columns and rows of a rather small data.frame. The ddf object below, for example:

df = data.frame(a=rnorm(100), b=c(rep('x', 50), rep('y', 50)), c=sample(1:20, 100, replace=T), d=sample(letters,100, replace=T), e=sample(LETTERS,100,replace=T), f=sample("asdasdasdasdfasdfasdfasdfasdfasdfasdfasd asdfasdfsdfsd", 100, replace=T)) ddf= tbl_df(df) 

回答1:

if you want to still use dplyr and print your dataframe just run

print.data.frame(ddf) ddf 


回答2:

Ah, I was getting angry with dplyr therefore I could not see. the solution is simple: as.data.frame(ddf). That is to convert dplyr-backed data.frame to generic data.frame.



回答3:

You can use the function print and adjust the n parameter to adjust the number of rows to show.

For example, the following commdands will show 20 rows.

print(ddf, n = 20) 

You can also use the typical dplyr pipe syntax.

ddf %>% print(n = 20) 

If you want to show all rows, you can use n = Inf (infinity).

print(ddf, n = Inf) ddf %>% print(n = Inf) 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!