What is Error in funcion_2(i) : task 2 failed - "non-character argument"??.
I'm trying to create a list of list , extracting words from xml files named on "lista".
cl <- makeCluster(mc)
registerDoParallel(cl)
list_of_list <- foreach(i=lista_xmls, .packages='XML') %dopar% funcion_2(i)
stopCluster(cl)
lista_xmls is ...
lista_xmls <- c("1.xml", "10.xml", "100.xml", "1000.xml", "10000.xml")
class(lista_xmls[1])
[1] "character"
funcion_2 is ...
funcion_2 <- function (archivo) {
#archivo = paste(archivo, ".xml", sep = "")
dataa <- xmlParse(archivo)
xml_data <- xmlToList(dataa)
titulo <- is.vacio(xml_data$metadata$obaa$general$title)
t <- strsplit(titulo, " ")
t <- unlist(t, recursive = TRUE, use.names = TRUE)
descripcion <- is.vacio(xml_data$metadata$obaa$general$description)
d <- strsplit(descripcion, " ")
d <- unlist(d, recursive = TRUE, use.names = TRUE)
# d <- d[nchar(d) > 2]
doc = xmlTreeParse(archivo, useInternalNodes = TRUE)
# node <- getNodeSet(doc ,"general")
palabras <- xpathApply(doc, "//keyword", function(n) xmlValue(n[[1]]))
#df <- data.frame(matrix( c( titulo,descripcion,rep( 1, each=length(palabras) ) ) , nrow=1, byrow=T))
#colnames(df) <- c("title","description",unlist(palabras))
atsil <- c(t,d,palabras)
#atsil <- unlist(atsil)
atsil <- list(atsil)
return(atsil)
}
Rstudio respond Error in funcion_2(i) : task 2 failed - "non-character argument", but I don't even know what does that mean, what is causing it, nor how to overcome it?
testing funcion_2 it does return a list with the words, soo I belive the error is in %dopar% ,it doesn't work with %do% , nor ...
results2 <- foreach(i=lista, .packages='XML') %dopar% funcion_2(as.character(i))
This is my first question in Stack and I'm begginer on R programing