Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8145833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:47:23+00:00 2026-06-06T13:47:23+00:00

All of my R code runs as expected in a standalone script. Once inside

  • 0

All of my R code runs as expected in a standalone script. Once inside an R Markdown file the get_map() call breaks down.

map <- get_map(location = 'minneapolis', zoom = 9)

I get an error:

label: unnamed-chunk-2
Warning in sink() : no sink to remove
label: unnamed-chunk-2
Error in process_file(text) :
Quitting from lines 53-64: Error in close.connection(con) : invalid connection
Calls: knit -> process_file
Execution halted
knitr terminated with status 1

Any ideas why knitr and get_map aren’t playing nice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:47:26+00:00Added an answer on June 6, 2026 at 1:47 pm

    It took me a while to figure out the problem. The root reason is ggmap was being “rude” to closeAllConnections() in four of its functions: mapdist(), geocode(), revgeocode() and route(); knitr uses the evaluate package to evaluate R code, which opens text connections to record R output. Because ggmap has closed all connections, evaluate will not be able to close its connections again, which caused the error you saw. See https://github.com/hadley/evaluate/blob/master/R/watcher.r for details.

    Normally one should be explicit about which connections to close using the close() function, and it is dangerous to use closeAllConnections() because this may close connections which are not supposed to be closed. I do not understand why the author has to use it, and I guess you need to report this issue to him. Finally we should be able to run this without errors:

    library(evaluate); library(ggmap)
    evaluate("map <- get_map(location = 'minneapolis', zoom = 9)")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code that runs all lovely on SQL Server 2008, however I'm
my jquery code not run with IE6 but runs all others including IE7. It
First, an example of something that works as expected: (all code was executed in
I have a problem where I need to remove all code and triggers from
I frequently code numerous experiments to test various algorithms, libraries, or hardware. All code,
I'm trying to find a way to delay all code that takes place after
As a standard at my company, all code documents use 4 spaces instead of
All the code examples always use base() as follows class A { public A()
I found all the code I need to make SHBrowseForFolder work in my application.
Note that all the code is a simplified example in order to only communicate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.