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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:35:45+00:00 2026-06-01T23:35:45+00:00

I’m looking into converting an R script into C-code for speed reasons and for

  • 0

I’m looking into converting an R script into C-code for speed reasons and for the ability to have it packaged as an .exe. I’m new to C.

My question is will it be significantly faster in C? The rate limiting step is a sort algorithm that has to be applied a lot of times to big vectors. I’m not sure if the vectorized functionality in R will help this or slow it down. Also I’ve read that for-loops are inefficient in R.

If I should do this in C, what libraries might help me mimic some of the data-processing functions of R like basic matrix manipulations? Where should I look to get started? Right now I don’t even know how to read my data into C (comma delimited text file).

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

    I’ll try to answer this question as well as I can.

    …but the question your NOT asking is perhaps more relevant: Can the R algorithm be made faster in R? The answer here is usually “yes”. Can it be “fast enough”? Well, that is impossible to answer without trying (and seeing the current R code).

    Q: Will my R algorithm be faster in C?

    A: Yes! If you write the “best” C code for the algorithm, it will most likely be faster. It will most likely also be a lot more work to do so.

    Q: Can sorting of large vectors be done faster in C?

    A: Yes. Using multi-threading, you can improve the speed quite a lot. …But start by calling sort(x, method='quick') in R and see if that improves things! The default method isn’t very fast for random data.

    x <- runif(1e7)
    system.time( sort(x) )                   # 2.50 secs
    system.time( sort(x, method='quick') )   # 1.37 secs
    #system.time( tommysort(x) )             # 0.51 secs (4 threads)
    

    Q: What libraries mimic basic R functions?

    A: LAPACK/BLAS handles matrix math in R. If that’s all you need, you can find libraries that are much faster than the vanilla ones in R (you can use some of them in R too to improve performance!).

    More info on BLAS

    Another way is to make a .Call from R to C and from there you have access to all of R’s functionality! The inline package and the Rcpp package can help make it easier.

    A third way is to embed R in your application. Rinside can help make that easier.

    Q: How do I read CSV data into C?

    A: Look at the fopen and fscanf functions. …and use them to write a data import function.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported

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.