Reverse digits in R

后端 未结 7 2047
清歌不尽
清歌不尽 2020-12-15 11:48

How can you reverse a string of numbers in R?

for instance, I have a vector of about 1000 six digit numbers, and I would like to know if they are palindromes. I wo

7条回答
  •  借酒劲吻你
    2020-12-15 12:18

    Edit: I misread the question. Here's my answer for posterity.


    You can use the rev function:

    > 1:10
     [1]  1  2  3  4  5  6  7  8  9 10
    > rev(1:10)
     [1] 10  9  8  7  6  5  4  3  2  1
    

提交回复
热议问题