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

  • Home
  • SEARCH
  • 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 7717635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:57:05+00:00 2026-06-01T02:57:05+00:00

I am plotting multiple plots: a <- dir(pattern=stuff.*\\.txt$) for (i in 1:length(a)) { b

  • 0

I am plotting multiple plots:

a <- dir(pattern="stuff.*\\.txt$")
for (i in 1:length(a)) {
  b <- read.table(a[i])
  jpeg(paste("/../.../", i, ".jpg"))
  plot(b$V1,b$V2, main=?)
  dev.off()
}

I want to name all jpg & main=? with original file name. All jpgs from this code are named from 1 to N. Is their any way to do this?

  • 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-01T02:57:07+00:00Added an answer on June 1, 2026 at 2:57 am

    Perhaps I’m missing something, but the variable a[i] is the original data file name. So you just need to do:

    plot(b$V1, b$V2, main=a[i])
    

    In your ‘paste’ function, the default separator is a space, so:

    paste("A", "B") 
    

    gives A B. Instead, you want: paste(A,B, sep=""). When creating the jpeg file you should remove the .txt or .csv file extension from your data. So something like:

    library(tools)
    fname = file_path_sans_ext(a[i])
    jpeg(paste("/../.../", fname, ".jpg", sep=""))
    

    Should work

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

Sidebar

Related Questions

i am plotting some data in R using the following commands: jj = ts(read.table(overlap.txt))
I'm trying to write a function that plots a ggplot facet_wrap plot over multiple
I am plotting line charts showing the change in price over time for multiple
When plotting multiple data series using both line specification ( X , Y ,
Possible Duplicate: Plotting 4 curves in a single plot, with 3 y-axes assuming I
Possible Duplicate: Plotting 4 curves in a single plot, with 3 y-axes I have
I am plotting a continuous variable against a factor using plot() in R (see
I have created a MATLAB plotting with the plot() function. How do I change
This is a follow-up of this question . I wanted to plot multiple curves
When plotting a function using Plot, I would like to obtain the set of

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.