删除< U + 00A0>从R中的列中的值 [英] Remove <U+00A0> from values in columns in R

查看:61
本文介绍了删除< U + 00A0>从R中的列中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用read.csv并使用encoding参数读取csv文件时,会得到一些值.

When I read my csv file using read.csv and using the encoding parameter, I get some values with in them.

application <- read.csv("application.csv", na.strings = c("N/A","","NA"), encoding = "UTF-8")

数据集看起来像

           X                                      Y
Met<U+00A0>Expectations               Met<U+00A0>Expectations
Met<U+00A0>Expectations               Met<U+00A0>Expectations
        NA                            Met<U+00A0>Expectations  
Met<U+00A0>Expectations               Exceeded Expectations
Did<U+00A0>Not Meet Expectations      Met<U+00A0>Expectations
Unacceptable                          Exceeded Expectations

如何从这些值中删除?如果我不使用"encoding"参数,则在闪亮的应用程序中显示这些值时,将显示为:

How can I remove the from these values? If I do not use the "encoding" parameter, when I show these values in the shiny application, it is seen as:

Met<a0>Expectations and Did<a0>Not Meet Expectations

我不知道如何处理.

PS:我用遇到的问题的例子修改了原始问题.

PS: I have modified the original question with examples of the problem faced.

推荐答案

问题困扰了我很长时间,并且我在R社区周围进行了搜索,在我的情况下,"r"标签中没有答案.在扩大搜索范围之前,我已经在"java"标签中找到了可行的答案.好的,对于数据框,解决方案是:

The problem bores me a long time, and I search all around the R communities, no answer in "r" tag can work in my situation. Until I expanded search area, I got the worked answer in "java" tag. Okay,for the data frame, the solution is:

application <- as.data.frame(lapply(application, function(x) {
              gsub("\u00A0", "", x) 
         })) 

这篇关于删除&lt; U + 00A0&gt;从R中的列中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆