Hello, I am relatively new to R and would like to access the document my pointer is pointing to in the following line of code. Need some help. #install.packages('xml2') library('xml2') pg1 <- read_html("www.msn.com") str(pg1) ptr <- pg1[[2]] [[alternative HTML version deleted]]
> On Jun 22, 2017, at 12:52 PM, Lawrence Fomundam <lawfom at gmail.com> wrote: > > Hello, > > I am relatively new to R and would like to access the document my pointer"my pointer"?> is pointing to in the following line of code. Need some help. > > #install.packages('xml2') > library('xml2') > pg1 <- read_html("www.msn.com")Error: 'www.msn.com' does not exist in current working directory ('/Users/davidwinsemius').> str(pg1) > ptr <- pg1[[2]] > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA
Hi Lawrence:> On Jun 22, 2017, at 4:26 PM, David Winsemius <dwinsemius at comcast.net> wrote: > > > >> is pointing to in the following line of code. Need some help. >> >> #install.packages('xml2') >> library('xml2') >> pg1 <- read_html("www.msn.com") > > Error: 'www.msn.com' does not exist in current working directory ('/Users/davidwinsemius'). > >I suggest you do: ?read_html and peruse it carefully. You are not passing it a URL.> library('xml2') > pg1 <- read_html("http://www.msn.com") > str(pg1)List of 2 $ node:<externalptr> $ doc :<externalptr> - attr(*, "class")= chr [1:2] "xml_document" "xml_node" ********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.