Convert Data frame into a clean list

Hello R lovers,

I need you help because I'm trying to create XML sitemaps from URLS crawled.
However I'm stuck when I need to convert dataframe into list ... let me explain :

1st step : I crawl my website
2nd step : I create data frames with urls scraped ("sitemap_#")


3rd step : I create XML sitemaps (I found the following code on the web). In this extract it is working well but urls are in list.

tpl <- '
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">

links <- c("", "", "")

map_links <- function(l) {
  tmp <- GET(l)
  d <- tmp$headers[['last-modified']]
       lastmod=format(as.Date(d,format="%a, %d %b %Y %H:%M:%S")),

links <- lapply(links, map_links)



As you can see with the screenshot, It works well. When I try to replace

links <- c("", "", "")


links = as.character(sitemap_3)

I have a format that is not compliant (see 2nd & 3rd screenshot) then it does not work :confused:


Can somebody helps me here ?

Thanks :pray:

we don't have sight of sitemap_3 to understand how it might be malformed / causing you problems

Hi @nirgrahamuk
I add a screenshot in my post :wink:


links = as.character(sitemap_3$Url)

Thanks for your reply ! It is working now :wink:
However I got a new error related to date format :

 Error in as.Date.default(d, format = "%a, %d %b %Y %H:%M:%S") : 
  incapable de convertir 'd' dans la classe “Date”```

Any idea how to fix it ?

maybe add a cat() to print to you the contents of d before that function call, so you can observe it, or use browser() to browse in.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.