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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:46:50+00:00 2026-05-26T16:46:50+00:00

I want R to produce, for example, normal data and then use this data

  • 0

I want R to produce, for example, normal data and then use this data in Java. I know there is a function to convert an REXP object to an array but it doesn’t seem to work. Here is what I have:

REXP x;
x = re.eval("rnorm(100,50,10)");
double[] test = x.asDoubleArray();
System.out.println(x);
System.out.println(test);

I have printed both out to see what is wrong. The results are as follows:

[REAL* (61.739814266023316, 40.25177570831545, 36.09450830843867, 48.06821029847672,...etc)]
[D@61de33

The problem is how R returns the results to java; it tells java what x is, if they were strings it would say [String*(..whatever..)]. I just want what is in the bracket. Also the line it returns is a string regardless.

I will be working with large data so I want it to be fast. I had tried to use subsets, extracting what is in the brackets and then parsing them to doubles but there must be a better solution. Also that doesn’t seem to work for data with more than 100 points.

  • 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-26T16:46:50+00:00Added an answer on May 26, 2026 at 4:46 pm

    Since there’s already a reference to this question, let here be an answer:

    System.out.println(test); where test is double[] literally means System.out.println(test.toString());

    The problem is, in Java, arrays have got a very poor implementation of toString(). Hence, in order to get the result you need, you need to use

    REXP x;
    x = re.eval("rnorm(100,50,10)");
    double[] test = x.asDoubleArray();
    System.out.println(x);
    System.out.println(Arrays.asList(test)); // note we get an array-backed list here
    

    as lists have proper toString() method.

    Again, my apologies for an obvious answer.

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

Sidebar

Related Questions

I want to produce an HTML file like this example: English En Lorem ipsum
I want a C program to produce a core dump under certain circumstances. This
I want a spreadsheet function that will produce a sum of all values in
I'm trying to produce a line chart using Flot, but I want the data
I have some problems when I want to use implicit methods to convert a
I have following type of data and I want to produce bar graph. Mark
Does anyone know of or can anyone please produce a simple example of Django's
I want to produce an output of data which will line up, but the
I want to produce a desktop application with a very simple GUI (a background
If I want to produce a Base64-encoded output, how would I do that in

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.