I have a tibble as :
# A tibble: 2 × 2
read_seq unique_id
<chr> <dbl>
1 AATTGGCC 1
2 GGGTTT 2
I want to create a new variable containing a string of the same size as read_seq. I did that but have an error:
> r %>% mutate(y=paste(rep("H",width(read_seq)),sep=""))
Error in mutate_impl(.data, dots) : argument 'times' incorrect
When I only try to catch read_seq width it works :
> r %>% mutate(y=width(read_seq))
# A tibble: 2 × 3
read_seq unique_id y
<chr> <dbl> <int>
1 AATTGGCC 1 8
2 GGGTTT 2 6
Here's the dput() of the example for reproducibility :
r <- structure(list(read_seq = c("AATTGGCC", "GGGTTT"), unique_id = c(1,
2)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-2L), .Names = c("read_seq", "unique_id"))