Convert c(‘a’ ‘c’, ‘b’) to c(‘a’, ‘a’, ‘c’, ‘c’, ‘b’, ‘b’) in R?
给定一个变量向量,变换向量,使每个变量重复
例如,我可以
1
|
sort(rep(c(‘a’, ‘c’, ‘b’)))
|
除了我不想对它们进行排序;我希望它返回 c(‘a’, ‘a’, ‘c’, ‘c’, ‘b’, ‘b’)
- 另见?rep。在提出问题之前阅读帮助文件被认为是一种好的做法。
使用 ?rep
1 2
|
vec <- c(‘a’, ‘b’, ‘c’)
rep(vec, each = 2)
|
来源:https://www.codenong.com/4523284/
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9083.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57