[R] httr::content without message

William Dunlap wdunlap at tibco.com
Tue Jan 2 18:46:18 CET 2018


You can suppress all messages from that command with
    junk <- suppressMessages(httr::content(r1))

If you only want to suppress that specific message you can use
withCallingHandlers:
    junk <- withCallingHandlers(
        httr::content(r1),
        message=function(e){
            if (grepl("Parsed with column specification",
conditionMessage(e))) {
               invokeRestart("muffleMessage")
            }
         }
      )


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Jan 2, 2018 at 9:30 AM, Roy Mendelssohn - NOAA Federal <
roy.mendelssohn at noaa.gov> wrote:

> Hi All:
>
> I am using httr to download files form a service, in this case a .csv
> file.  When I use httr::content on the result,  I get a message.  Since
> this will be in a package.  I want to suppress the message,  but haven't
> figured out how to do so.
>
> The following should reproduce the result:
>
> myURL <- 'https://coastwatch.pfeg.noaa.gov/erddap/griddap/
> erdMH1sstdmday.csvp?time[0:1:last]'
> r1 <- httr::GET(myURL)
> junk <- httr::content(r1)
>
> when the last command is run, you get:
>
> Parsed with column specification:
> cols(
>   `time (UTC)` = col_datetime(format = "")
> )
>
> I want to suppress that output.
>
> Thanks,
>
> -Roy
>
> **********************
> "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.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list