我正在使用readxl软件包加载Excel文件。默认情况下,它应该去除空格,但实际上并没有这样做。
该文件可以直接从下面的链接下载,或者可以通过包含附录B的网站下载。
这个问题会在分析中造成麻烦,就像这个例子中的数字列实际上是字符一样。 需要帮助。
该文件可以直接从下面的链接下载,或者可以通过包含附录B的网站下载。
http://www2.nationalgrid.com/WorkArea/DownloadAsset.aspx?id=8589937799
require(readxl);require(tidyverse)
test <- read_excel("ETYS 2016 Appendix B.xlsx", skip = 1, sheet = 22, trim_ws = TRUE)
print(test$`MVAr Generation`)
test$`MVAr Generation` %>% str_count(patter = "\\s")
test$`MVAr Generation` %>% table #all are numeric
test$`MVAr Generation` %>% class #however the class is characer
test$`MVAr Generation` %>% str_count(patter = "\\s") %>%
sum(na.rm = T) #It should be 0 however it is 2
这个问题会在分析中造成麻烦,就像这个例子中的数字列实际上是字符一样。 需要帮助。