micstr
micstr

Reputation: 5206

How to reference .. .. elements in list in R?

How do you access list elements prefaced with double dots .. ..?

I am trying to isolate the $attr part of the html to help in another question into a variable, and then place it another mime variable. x$parts$attr gives me NULL.

Thanks for your help.

EXAMPLE

library(gmailr)
test_email <- mime()
x <- html_body(mime = test_email, body = "I wish I had a nice body")

str(x)
List of 5
 $ parts  :List of 2
  ..$ : NULL
  ..$ :List of 4
  .. ..$ parts : list()
  .. ..$ header:List of 2
  .. .. ..$ MIME-Version: chr "1.0"
  .. .. ..$ Date        : chr "Sun, 24 May 2015 09:44:59 GMT"
  .. ..$ body  : chr "I wish I had a nice body"
  .. ..$ attr  :List of 3                           # << HOW do I get this?
  .. .. ..$ content_type: chr "text/html"
  .. .. ..$ charset     : chr "utf-8"
  .. .. ..$ encoding    : chr "base64"
  .. ..- attr(*, "class")= chr "mime"

Upvotes: 2

Views: 1569

Answers (1)

Peter Diakumis
Peter Diakumis

Reputation: 4042

Try this:

str(x$parts[[2]]$attr)

List of 3
 $ content_type: chr "text/html"
 $ charset     : chr "utf-8"
 $ encoding    : chr "base64"

Upvotes: 2

Related Questions