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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:31:19+00:00 2026-06-19T02:31:19+00:00

I have a problem casting data from string into integer. For example, the original

  • 0

I have a problem casting data from string into integer.

For example, the original data looks like this

orderdt[1:10,2]

[1] 71004 13943 11337 9647  9363  6836  5957  5167  4963  4850  

But when I cast it into double like this it changes to completely different numbers

as.numeric(orderdt[1:10,2])

[1]  854  164   82 1069 1051  823  724  636  613  600

Originally I cast the column (some 1 mill rows) into double, and most of the lower part were converted, only the first 300 or so were screwed up this way. Do you know why this happened or how to fix it?

Please help.

  • 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-19T02:31:20+00:00Added an answer on June 19, 2026 at 2:31 am

    Almost certainly you have a factor. To check, use:

    is.factor(orderdt[1:10,2])
    

    If it is a factor, than

    as.numeric(as.character(is.factor(orderdt[1:10,2])))
    

    should do what you expect.

    The question you now (probably) have is why do I have a factor? Without further information that’s tricky to know, but the usual reason is you’ve loaded in your data (say via a csv file) and one of your “numbers” isn’t a number. For example, you have “1,12” rather than “1.12”

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

Sidebar

Related Questions

I have the following casting problem when my data structure sSpecificData contains a field
I have a problem with casting a variable (see below) to a String so
I have a problem with casting from float to double when fread; fread(doublePointer,sizeofFloat,500,f); if
Have problem with linq expressions. I want to get from db some data ordered
I'm have little problem in retrieving the data from a table here's the code:
I have a problem. I sent some data over a socket in string form.
I have the following problem with casting (or accessing data, I'm not sure): There
I have problem with casting custom event currentTarget to component. When I'm trying to
I have a problem about casting a CallableStatement to OracleCallableStatement . It gives ClassCastException
I think I have a problem with casting. $db = mysqli_connect('127.0.0.1','root','password','test'); if (! $db)

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.