2019-03-10
阅读量:
1584
R语言中元素的翻转
rev
元素间翻转
> x <- c(1:5, 5:3)
> x
[1] 1 2 3 4 5 5 4 3
> rev(x)
[1] 3 4 5 5 4 3 2 1
> x <- c("ABC", "DEF", "GHIJ")
> rev(x)
[1] "GHIJ" "DEF" "ABC"
str_rev
元素内翻转
> install.packages("Kmisc")
> library(Kmisc)
> x <- c("ABC", "DEF", "GHIJ")
> x
[1] "ABC" "DEF" "GHIJ"
> str_rev(x)
[1] "CBA" "FED" "JIHG"
> x <- c(1:5, 5:3)
> x
[1] 1 2 3 4 5 5 4 3
> str_rev(x)
[1] "1" "2" "3" "4" "5" "5" "4" "3"
> x <- "I am here."
> x
[1] "I am here."
> str_rev(x)
[1] ".ereh ma I"
> rev(x)
[1] "I am here."






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论