I have a list of about 1000 character vectors in R that I need to convert to UTF-8
. The only tool that I could find for reliable conversions is iconv()
, but it only works on character vectors. How can I convert my entire list without smashing it together into a single vector?
Asked
Active
Viewed 233 times
-2

DataWiz
- 401
- 6
- 14
-
`help("lapply")` – Roland Jul 31 '18 at 09:27
-
Give a reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jogo Jul 31 '18 at 09:36
1 Answers
0
OK, I managed to solve this with the "helpful" answers given by the commenters (but thanks nonetheless, since I figured it out anyways). Assuming this is my original list list_1
:
[[1]] 縺薙l縺ッ
[[2]] 萓ソ蛻ゥ縺ァ縺・
I now use lapply
to iterate the function iconv
over the entire list, with the arguments for iconv
simply listed after a comma inside lapply
:
list_1_iconv <- lapply(list_1, iconv, from = "SHIFT-JIS", to = "UTF-8")
Which yields:
[[1]] これは
[[2]] 便利です

DataWiz
- 401
- 6
- 14