-2
$\begingroup$

I have this dataframe

> head(mut)
  sample chr     pos ref alt
1  t_005   1  928006   G   A
2  t_005   1 1649842   G   T
3  t_005   1 2020408   G   A
4  t_005   1 2031677   T   A
5  t_005   1 2901878   G   A
6  t_005   1 3039338   G   A
>

How I can add "chr" to the chr column? I mean, instead of "1" I want "chr1", etc.

$\endgroup$
1
  • 2
    $\begingroup$ This is basic R question and more suitable to StackOverflow main site, and it is already has been asked many times, see here for example $\endgroup$
    – zx8754
    Apr 1 '19 at 9:21
4
$\begingroup$

This should work:

mut$chr <- paste("chr", mut$chr, sep = "")
$\endgroup$
1
  • 4
    $\begingroup$ if you use paste0 instead of paste, you can omit the 'sep=""' $\endgroup$
    – gringer
    Mar 31 '19 at 22:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.