0
votes

I try to use a paste function on a tibble but I get this result below. I have tried to transform it with as.data.frame but the result is the same. I really need to use dplyr to manage a bigger dataset.

Thanks in advance.

Species=iris %>% select(Species)
paste("This is a ",Species)

[1] "This is a c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)"

1
what exactly are you trying to do? Probably you need Species=iris %>% pull(Species) and not the select - Onyambu
paste('This is a', iris$Species) ? - Ronak Shah

1 Answers

1
votes

Here's a solution I got to work. You can use mutate to paste together your string "This is a " with the Species column. I've saved it as a variable called which_species.

# Load tidyverse
library(tidyverse)

# Select Species from iris 
Species = iris %>% select(Species)
 
# I created a new variable pasting your string and the Species column together
Species <- Species %>% mutate(which_species = paste0("This is a ", Species))

# Check out the output
head(Species)