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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:12:43+00:00 2026-06-05T01:12:43+00:00

I’m trying to split a numeric string of 40 digits (ie. splitting 123456789123456789123456789 into

  • 0

I’m trying to split a numeric string of 40 digits (ie. splitting 123456789123456789123456789 into 1 2 3 4 etc.)

Unfortunately strsplit doesn’t work as it requires characters, and converting the string using as.character doesn’t work as it is very long and R automatically cuts off decimals for long digits (maximum is 22 decimals). I thus end up with "1.2345e+35" as a character string, instead of the full digit.

Is there a numeric variant of strsplit, or a work around to the decimal-cutting-off issue? I can’t seem to find the answer on stackoverflow, but apologies if this has already been answered before. Thanks in advance!

  • 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-05T01:12:44+00:00Added an answer on June 5, 2026 at 1:12 am

    If R is calculating the number I do not know the solution. If the number is in a data file I think the code below might work. Although, if the number is in a data file there are probably much easier solutions.

    a1 <- read.table("c:/users/Mark W Miller/simple R programs/long_number.txt", colClasses = 'character')
    
    # a1 <- c('1234567891234567891234567891234567891234') ;
    
    a1 <- as.character(a1) ;
    a2 <- strsplit(a1, "") ;
    a3 <- unlist(a2) ;
    a4 <- as.vector(as.numeric(a3)) ;
    a4
    # [1] 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4
    

    EDIT

    I realize I might not understand the question, and my answer is probably pretty silly. Nevertheless, if you have an entire data set of really long numbers you could split all of them with the code below. Note that there are no quotes in the file ‘three_long_numbers.txt’, and the data start out as numeric:

    a1 <- read.table("c:/users/Mark W Miller/simple R programs/three_long_numbers.txt", colClasses = 'character')
    a1
    
    #      V1                                        
    # [1,] "1234567891234567891234567891234567891234"
    # [2,] "1888678912345678912345678912345678912388"
    # [3,] "1234999891234567891234567891234567891239"
    
    # a1 <- matrix(c(
    # "1234567891234567891234567891234567891234",
    # "1888678912345678912345678912345678912388",
    # "1234999891234567891234567891234567891239"), nrow=3, byrow=T)
    
    a1 <- as.matrix(a1) ;
    a2 <- strsplit(a1, "") ;
    a3 <- unlist(a2) ;
    a3 <- as.numeric(a3) ;
    a4 <- matrix(a3, nrow=dim(a1)[1], byrow=T)
    a4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.