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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:49:37+00:00 2026-05-27T15:49:37+00:00

I have a script to output graphic files via png() the filename is based

  • 0

I have a script to output graphic files via png()

the filename is based on a value(p) and the observation id ID(numerical value).

> summary(p)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.05328 0.10770 0.20830 0.31140 0.42360 0.99990 
> summary(id)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
100000000 114100000 130400000 186100000 287300000 4513000
> str(p)
 num [1:223] 0.175 0.1499 0.156 0.0636 0.1628 ...
> str(id)
 int [1:223] 100037005 100270001 100270002 100801001 101910002 101910003 101910007 102510001 103630003 103630005 ...

so that

png(paste(p," - ", id,".png)

My goal is that the files in the output directory, when sorted by name, are in increasing p order, while the id is still in the filename.

I cant understand why but the sort order gets messed up, like in the attached screenshot.

File Order

Any ideas how I can get the output i need? A transformation of p is OK as long as it is easy to track back to the original value, and both p and id must be in the file name. I’m on Ubuntu 11.10.

Thanks a lot

  • 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-05-27T15:49:37+00:00Added an answer on May 27, 2026 at 3:49 pm

    You could try to make sure the p values are all the same length when converted to strings. Use sprintf:

    pstring = sprintf("%010.8f",p)
    

    will create a string with exactly 8 decimals, leading and trailing zeroes, and for values 0 to 1 will always be 10 characters long (zero, point, then eight decimals).

    sprintf("%010.8f",runif(100))
    

    should show you what it does.

    Adjust the format according to your taste, simmer gently, serve.

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

Sidebar

Related Questions

I currently have a script which allows me to output the list of files
I have a script that will output a jpg, gif or png image. It
I have this warning every time I run my CGI-script (output is rendered by
I have a script (worker.py) that prints unbuffered output in the form... 1 2
I have a script that generates two lines as output each time. I'm really
Does anyone have a script for logparser that will output a graph for daily
I have a script that creates an image and calls imagepng to output it
I have a batch file containing a python script using the Output template> %(NAME)s
I have a ruby bash script to download a zip file and output a
I have this script to output everything from table called Articles. If I load

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.