我想用 HTMLdecode 解码一些向量,但在某些情况下它不起作用。我从 excel 表中读取数据,我想解码一个变量,但它不起作用。如果我手动设置这些变量,它会出于某种原因工作,我真的不知道为什么。
library(magrittr)
library(openxlsx)
library(data.table)
library(textutils)
Data.Guests <- read.xlsx("Data/xxx.xlsx") %>%
setDT
HTMLdecode(Data.Guests[, Name]) # does not work, nothing happens
vector <- Data.Guests[, Name]
HTMLdecode(vector) # does not work
HTMLdecode(c("Rübezahl", "Meier")) # does work. "Rübezahl" is one element of the variable
这dput(Data.Guests)
看起来像:
structure(list(Titel = NA_character_, Vorname = NA_character_,
Name = "Rübezahl", Email = NA_character_, Institution = NA_character_,
Position = NA_character_, Anrede = "Herr", `Priorität-einladen` = NA_character_,
nachrangig = NA_character_, Noch.überlegen = NA_character_,
Bemerkung.1 = NA_character_, Salutation = "Sehr geehrter Herr Rübezahl,\n"), row.names = c(NA,
-1L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000000002571ef0>)