I have a library with html files and in files_dep I have the list of them. I need to convert the text stored in them to a table, but the issue is that they have accents and ñ. I wrote this to read it and works ok.
for (i in files_dep) {
text<-readLines(i,encoding="UTF-8")
aa<-paste(text, collapse=' ')
if (grepl(empieza,aa) & grepl(termina,aa)) {
nota=gsub(paste0("(^.*", empieza, ")(.*?)(", termina, ".*)$"), "\\2", aa)
#nota<-iconv(nota,to="ASCII//TRANSLIT")
df<-rbind(df, data.frame(fileName=i, nota=nota)) }}
I can read things like:
Este sábado enfrentarán a un equipo.
So I only need to delete the accents. I tried uncommenting the
nota <- iconv(nota,to="ASCII//TRANSLIT")
but I get:
Este sA!bado se enfrentarA!n a un equipo.
So, I don't know what the problem is.
Also, I need to delete accents and all special characters. Thanks
Edition:
I took the last data stored in nota at the end of the loop. THis is what I see:
nota
[1] " <p>La inclusión del seleccionado argentino en el viejo Tres Naciones significó, hace tres años, la confirmación de que el nivel del rugby argentino estaba a la altura de los grandes equipos del planeta, aunque se preveía que esa transición entre ser un equipo <em>del montón</em> a formar parte de la<em> elite </em>no iba a ser sencilla<em>. </em>Hoy, luego de dos años de competencia en el Rugby Championship, Los Pumas están cada vez más cerca de dar el batacazo y conseguir su primer triunfo en la historia del torneo.</p><p>
If I do:
iconv(nota,to="ASCII//TRANSLIT")
I get:
iconv(nota,to="ASCII//TRANSLIT")
[1] " <p>La inclusiA3n del seleccionado argentino en el viejo Tres Naciones significA3, hace tres aA?os, la confirmaciA3n de que el nivel del rugby argentino estaba a la altura de los grandes equipos del planeta, aunque se preveA-a que esa transiciA3n entre ser un equipo <em>del montA3n</em> a formar parte de la<em> elite </em>no iba a ser sencilla<em>. </em>Hoy, luego de dos aA?os de competencia en el Rugby Championship, Los Pumas estA!n cada vez mA!s cerca de dar el batacazo y conseguir su primer triunfo en la historia del torneo.