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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:49:45+00:00 2026-06-04T23:49:45+00:00

The code given below is to convert binary files from float32 to 16b with

  • 0

The code given below is to convert binary files from float32 to 16b with scale factor of 10. I am getting error of invalidation of %d.

setwd("C:\\2001")
for (b in paste("data", 1:365, ".flt", sep="")) {
   conne <- file(b, "rb")
   file1<- readBin(conne, double(), size=4,  n=360*720, signed=TRUE)
   file1[file1 != -9999] <- file1[file1 != -9999]*10
   close(conne)
   fileName <- sprintf("C:\\New folder (11)\\NewFile%d.bin", b)
   writeBin(as.integer(file1), fileName, size = 2) 
}

Result:

Error in sprintf("C:\\New folder (11)\\NewFile%d.bin",  : 
invalid format '%d'; use format %s for character objects

I used %s as suggested by R.But the files from 1:365 were totally empty

  • 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-04T23:49:47+00:00Added an answer on June 4, 2026 at 11:49 pm

    The %d is a placeholder for a integer variable inside a string. Therefore, when you use sprintf(%d, var), var must be an integer.

    In your case, the variable b is a string (or a character object). So, you use the placeholder for string variables, which is %s.

    Now, if your files are empty, there must be something wrong elsewhere in your code. You should ask another question more specific to it.

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

Sidebar

Related Questions

How to convert the vertical menu into horizontal? Which lines in the below-given code
I want to convert JSON into java code. My jsoncode as per given below.
how do I convert a reference to a pointer correctly? The code below gives
I'm attempting to convert a string to a TStream. My code below gives me
In the code given below, I need to position the userid box in the
In the code given below, I am trying to modify it in such a
Hello friends i am running code given below which contains the setLogTimeEntery function and
Technology Used:- Asp.Net 2.0 Code:- See Below Description:- hello code given below is working
How to know the Id of item I clicked? my code is given below:
Given the below setup and code snippets, what reasons can you come up with

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.