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 9146499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:45:56+00:00 2026-06-17T10:45:56+00:00

I have the need to build a function that will plot multiple pdfs, read

  • 0

I have the need to build a function that will plot multiple pdfs, read them in, combine the results (different sized pdfs), save the combined file and delete the initial files. I’m getting hung up on the initial part of interactively plotting multiple plots to external pdfs. The problem is I need a way of pausing in the for loop, waiting for the plot and then moving on after receiving the plot. I thought readLines was the way to go (and it may be) but this did not work (i.e. no plot was produced).

How can I make R pause between pdf take the plot, move onto dev.off and reiterate through the process again? The desired outcome is to have three files in the wd called file1.pdf, file2.pdf and file3.pdf. Again, after running the loop/lapply, this process will be interactive.

This is a MWE of the problem:

widths <- c(10, 9, 8)
heights <- c(11, 9, 7)
file <- "foo.pdf"
lapply(1:3, function(i) {  #will askfor/take 3 plots interactively
    qo <- gsub(".pdf", paste0(i, ".pdf"), file, fixed = TRUE)
    cat("plot now...")
    pdf(file=qo, width = widths[i], height = heights[i])
#pause command here
    dev.off()
})

#the interactive part
plot(1:10)
plot(1:13)
plot(1:15)  

EDIT 1 Related question: Determine ghostscript version

EDIT 2 Here’s a link to the package I used this information to create -click here-

  • 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-17T10:45:57+00:00Added an answer on June 17, 2026 at 10:45 am

    Is it as simple as this?

    for(i in 1:3){
      cat(i, "\n")
      cat("plot now...")
      readLines(n=1)
    }
    

    This stops to read a single line from stdin, i.e. the console. Press Enter to carry on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have projects that need to be build with a specific version of the
I have a DLL that contains all my object I need to build my
I need to build an ajax search function which, as the user types, will
I am trying to create a function that will build it's own query with
I would like to build two buttons with an onclick function that will insert
I am trying to create view or a function that will build a HTML
I need to run a query that will return multiple rows and export it
So I need to build an application that will receive xml request and based
I have a need to build the data string dynamically. This is not working,
(java 1.5) I have a need to build up a String, in pieces. I'm

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.