Tibble after transform a dataframe?

dplyr

#1

Hi
The following code adds an additional column to a tibble using transform

library(tidyverse)
data <-tibble(x = letters, y=letters)
data2 <- data %>%
  transform(z = y)
str(data2)

The funny or intended thing is that data2 is now a dataframe and not a tibble anymore. Is this intended or am I doing something wrongly?

'data.frame':	26 obs. of  3 variables:
 $ x: chr  "a" "b" "c" "d" ...
 $ y: chr  "a" "b" "c" "d" ...
 $ z: Factor w/ 26 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 ...

Cheers
Renger


#2

transform comes from base R, meaning that it converts whatever you give into base R data.frame. The tidyverse equivalent of this function is dplyr::mutate. If you give it a tibble, it'll return a tibble as well.


#3

Thanks a lot!
Renger