如何从r中的列标题中删除_字符(0)_字符(0)
我正在使用R中的DF工作,并且列标题也正在获取_ contric> _ trace(0)_ trace(0)
值。我想用“ na”或“”替换/删除它们,以便我可以 trimws()删除空间。我该怎么做?
|S.no|A _ character(0) _ character(0)|B _character(0) _ character(0)|
|:---|:-----------------------------|:----------------------------|
|1 | 20 |55 |
|2 | 30 |56 |
我尝试了colnames(df)< - gsub(“ _ artial(0)_ targinal(0)”,“”,colnames(df))
,以便我以后可以修剪空间以获取列标题为,
|S.no|A|B|
|:---|:|:|
但我仍然在标题中获得相同的字符。
I'm working on a df in R and the column headers are getting _ character(0) _ character(0)
values too. I want to replace/remove them either with "NA" or "" so that I can trimws() to remove the spaces. How would I do that?
|S.no|A _ character(0) _ character(0)|B _character(0) _ character(0)|
|:---|:-----------------------------|:----------------------------|
|1 | 20 |55 |
|2 | 30 |56 |
I tried colnames(df) <- gsub(" _ character(0)_ character(0)","",colnames(df))
so that I can trim the space later to just get the column header as
|S.no|A|B|
|:---|:|:|
But I'm still getting the same characters in the header.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要逃脱此字符才能使其起作用:
(
You will need to escape this character to make it work:
(