Reputation: 1107
I want to decode some vectors with HTMLdecode but it does not work in some cases. I read in data from an excel sheet and I want to decode a variable and it does not work. If I manually set up these variable it works for some reason and I really don't have an idea why.
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
This is what dput(Data.Guests)
looks like:
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>)
Upvotes: 0
Views: 56
Reputation: 1107
This is my hack now ... I'm not really satisfied with that but it works ...
fil <- file("Data/tmp.r")
dput(Data.Guests, fil)
Text <- readLines(fil)
Text %<>% str_replace(", \\.internal.*", ")")
writeLines(Text, con = fil)
Data.Guests <- dget(fil)
With that it works for some reason ...
Upvotes: 1