- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to view the complete output of tibble in R?
Tibbles are created when we analyze data using dplyr package and if the data size is large then only 10 values are printed in R. If we want to display the complete output of tibble then View function needs to be used. For example, if we want to perform calculation of counts then we should add View() at the end of the code with pipe operator.
Example
Consider the below data frame −
Group<−rep(c("A","B","C","D","E"),times=10) Rating<−sample(1:10,50,replace=TRUE) df<−data.frame(Group,Rating) head(df,20)
Output
Group Rating 1 A 4 2 B 2 3 C 8 4 D 3 5 E 3 6 A 1 7 B 8 8 C 8 9 D 1 10 E 2 11 A 2 12 B 8 13 C 10 14 D 4 15 E 6 16 A 3 17 B 7 18 C 1 19 D 5 20 E 10
Example
tail(df,20)
Output
Group Rating 31 A 2 32 B 5 33 C 4 34 D 1 35 E 4 36 A 8 37 B 2 38 C 6 39 D 2 40 E 5 41 A 1 42 B 4 43 C 9 44 D 5 45 E 2 46 A 7 47 B 10 48 C 9 49 D 1 50 E 6
Loading dplyr package −
library(dplyr)
Finding the counts for Group and Rating and viewing the whole output using View() −
df%>%group_by(Group,Rating)%>%mutate(count=n())%>%View()
Output
Advertisements