清洁以下字符串并将此字符向量C转换为整数类型的向量类型
字符串:
c1 <- c("cSVgKl9yyb", "e7w4o11oh8", "iYdWYvV7b2", "Epal3cNuGH", "NNhbMR0ocT", "fYaRvoag8B",
"LO4fkHm7Kn", "JK8jKhS5De", "DcMAZ7Rxtp", "sV0tqC8XSd")
输出必须是:
[1] 9 74118 72 3 0 8 47 85 7 8
任何知道解决此问题的代码的人?
The string:
c1 <- c("cSVgKl9yyb", "e7w4o11oh8", "iYdWYvV7b2", "Epal3cNuGH", "NNhbMR0ocT", "fYaRvoag8B",
"LO4fkHm7Kn", "JK8jKhS5De", "DcMAZ7Rxtp", "sV0tqC8XSd")
Output must be:
[1] 9 74118 72 3 0 8 47 85 7 8
Anyone who knows the code to solve this question?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里,我们删除了数字类中包含的所有内容,其中“非”是通过
^
表示的,而数字类则由0-9表示
。另外,正如@yonyambu所建议的那样,您可以将否定字符类用于不是的任何东西,\\ d
。如果您希望值是数字:
Here we remove everything that is not contained in the class of digits, where "not" is expressed via
^
and the class of digits is expressed by0-9
. Alternatively, as suggested by @onyambu, you can use the negative character class for anything that is not a digit,\\D
.If you want the values to be numeric: