1

I have a tibble that contains long strings in it's cells.

How can I view the complete string in a cell, without tibble restricting the number of characters I see?

Let's say I have my tibble created like this:

library(stringi)
df <- tibble(example = stri_paste(rep(stri_paste(letters, collapse = " "), 4), collapse = " "))

Then when I want to view a cell with df[1, 1] the output looks like:

# A tibble: 1 x 1
  example                                                                                 
  <chr>                                                                                   
1 a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r…

But I want to read the entire string in the cell.

How do I do this? Thanks ahead!

JNab
  • 125
  • 9
  • convert it to dataframe? `data.frame(df)` ? – Ronak Shah Mar 05 '19 at 09:27
  • 1
    Do you need `df[[1, 1]]` ? – markus Mar 05 '19 at 09:29
  • @RonakShah, I would like to stick to the tidyverse approach, so that's why I chose tibble. – JNab Mar 05 '19 at 09:36
  • @markus, Thanks! That is the solution! Do you happen to know why this double indexing does the trick? – JNab Mar 05 '19 at 09:36
  • If you want a `tidyverse` solution, you could use `pull` to get a character vector, `df %>% pull(example)` – Ronak Shah Mar 05 '19 at 09:37
  • @JNab Check the link Ronak posted. The double brackets extracts a vector, while the single bracket returns a `tibble`. Note that this behavior is different compared to regular `data.frame`s. Look at the default of the `drop` argument in `?"[.tbl_df"` compared to `?"[.data.frame"`. – markus Mar 05 '19 at 09:41

0 Answers0