如何转换数据列以减少字符
我正在处理一个数据集,其中有一列包含我想要转换的值。 我现在遇到的问题是我的数据如下所示:
- 网站数量
- 1 1 35
- 1 10 38
- 1 2 56
- 1 3 23
- 1 4 25
- 1 5 45
- ......
我想删除所有站点中存在的 1,只保留 1, 2, 3 , 4, 5... 10。
我尝试使用 as.number 对其进行转换,但它为我提供了站点 1.10 作为第二个值,因此它不正确。
I am working with a data set that has a column with values that I would like to transform.
The problem that I have right now is that my data looks like:
- Site Count
- 1 1 35
- 1 10 38
- 1 2 56
- 1 3 23
- 1 4 25
- 1 5 45
- .......
I would like to remove the 1 that is present in all the sites and just leave it 1, 2, 3, 4, 5... 10.
I tried to transform it using as.number but it gives me the site 1.10 as the second value so it is not right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
示例数据集:
去掉
1
位:这里我使用
sub
将1
替换为空字符串。然后转换为数字即可:An example dataset:
To get rid of the
1
bit:Here I use
sub
to substitute the1
by an empty string. The transformation to numeric then works: