Accessing Pointers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing Pointers

Lawrence Fomundam
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Pointers

David Winsemius

> On Jun 22, 2017, at 12:52 PM, Lawrence Fomundam <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Pointers

Roy Mendelssohn - NOAA Federal
Hi Lawrence:

> On Jun 22, 2017, at 4:26 PM, David Winsemius <[hidden email]> 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: [hidden email] 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.

______________________________________________
[hidden email] 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.