How can I use java variables in R



  • Hey, I have a list int in java code, and I need this list to be rolled into R script, and I have to do the calculations based on the values from List'a, so I've got my hands on the violin, how can I instead of the static crypt make it dynamic, so that the crypt can take different meanings from java? Code R:

        > data=read.csv("/Users/IsaakIsbergman/Documents/viktfore_data2Update.csv")
    > data
        X75.74
    1    77.99
    2    89.48
    3    64.87
    4    80.91
    5    77.45
    6    85.55
    7    83.35
    8    79.41
    9    88.28
    10   61.88
    11   85.56
    12   80.20
    13   84.97
    14   70.03
    15   66.64
    16   91.42
    17   70.43
    18   56.55
    19   73.35
    20   66.67
    21   81.75
    22   81.77
    23   88.47
    24   69.27
    25   79.61
    26   42.41
    27   64.96
    28   62.16
    29   74.18
    30   82.16
    31   73.60
    32   89.29
    33   75.41
    34   83.82
    35   60.15
    36   59.05
    37   88.93
    38   80.65
    39   56.61
    40   69.02
    41   42.31
    42  105.44
    43   75.74
    44   50.88
    45   77.99
    46   64.87
    47   77.45
    48   83.35
    49   88.28
    50   85.56
    51   84.97
    52   66.64
    53   70.43
    54   73.35
    55   81.75
    56   88.47
    57   79.61
    58   64.96
    59   74.18
    60   78.98
    61   77.02
    62   86.01
    63   98.53
    64   88.15
    65   55.93
    66  170.91
    67   71.59
    68   80.86
    69   73.12
    70   57.60
    71   93.90
    72  110.19
    73   66.28
    74   56.13
    75   55.96
    76   87.45
    77   73.64
    78   66.77
    79   70.98
    80  143.06
    81   60.12
    82   65.92
    83   87.82
    84   89.70
    85   74.44
    86   89.02
    87  103.04
    88   90.25
    89   46.97
    90   77.74
    91   80.94
    92   84.42
    93   58.15
    94   65.03
    95  112.27
    96   79.96
    97   73.37
    98   78.26
    99   59.46
    100  84.56
    101  91.05
    102  89.39
    103  58.09
    104  64.41
    105  88.69
    106  63.49
    107  85.86
    108  60.57
    109 145.15
    110  74.82
    111  65.22
    112  74.47
    113  63.20
    114  62.46
    115  98.01
    116  86.15
    117  42.39
    118  97.16
    119  62.65
    120  81.40
    121  57.61
    122 103.62
    123  73.66
    124  68.91
    125  72.76
    126  71.75
    127  77.08
    128  93.25
    129 106.08
    130  87.48
    131  87.83
    132  61.56
    133  77.19
    134  50.89
    135 110.63
    136  80.00
    137  89.14
    138  82.45
    139 111.84
    140  70.21
    141  59.72
    142  87.96
    143  84.15
    144  89.38
    145  73.51
    146  58.56
    147  84.20
    148  71.71
    149  84.20
    150  79.08
    151  70.97
    152  75.24
    153  99.67
    154  81.29
    155  69.78
    156  80.58
    > median(data)
    Error in median.default(data) : need numeric data
    > dim(data)
    [1] 156   1
    > data[156,1]
    [1] 80.58
    > data[1:156,1]
      [1]  77.99  89.48  64.87  80.91  77.45  85.55  83.35  79.41  88.28  61.88
     [11]  85.56  80.20  84.97  70.03  66.64  91.42  70.43  56.55  73.35  66.67
     [21]  81.75  81.77  88.47  69.27  79.61  42.41  64.96  62.16  74.18  82.16
     [31]  73.60  89.29  75.41  83.82  60.15  59.05  88.93  80.65  56.61  69.02
     [41]  42.31 105.44  75.74  50.88  77.99  64.87  77.45  83.35  88.28  85.56
     [51]  84.97  66.64  70.43  73.35  81.75  88.47  79.61  64.96  74.18  78.98
     [61]  77.02  86.01  98.53  88.15  55.93 170.91  71.59  80.86  73.12  57.60
     [71]  93.90 110.19  66.28  56.13  55.96  87.45  73.64  66.77  70.98 143.06
     [81]  60.12  65.92  87.82  89.70  74.44  89.02 103.04  90.25  46.97  77.74
     [91]  80.94  84.42  58.15  65.03 112.27  79.96  73.37  78.26  59.46  84.56
    [101]  91.05  89.39  58.09  64.41  88.69  63.49  85.86  60.57 145.15  74.82
    [111]  65.22  74.47  63.20  62.46  98.01  86.15  42.39  97.16  62.65  81.40
    [121]  57.61 103.62  73.66  68.91  72.76  71.75  77.08  93.25 106.08  87.48
    [131]  87.83  61.56  77.19  50.89 110.63  80.00  89.14  82.45 111.84  70.21
    [141]  59.72  87.96  84.15  89.38  73.51  58.56  84.20  71.71  84.20  79.08
    [151]  70.97  75.24  99.67  81.29  69.78  80.58
    > x=data[,1]
    > hist(x)
    > mean(x)
    [1] 78.18949
    > median(x)
    [1] 77.865
    > sum(x)
    [1] 12197.56
    > 12197.56/156
    [1] 78.18949
    > sd(x)
    [1] 17.52989
    > sd(x)*sd(x)
    [1] 307.2971
    > 307.2971/156
    [1] 1.969853
    > 17.52989/12.48999
    [1] 1.403515
    > 1.403515*1.96
    [1] 2.750889
    > 78.18949+2.750889
    [1] 80.94038
    > 78.18949-2.750889
    [1] 75.4386
    > data=read.csv("/Users/IsaakIsbergman/Documents/vikt-efter_data2.csv")
    > data
        X71.93
    1    69.48
    2    64.76
    3    73.12
    4    73.35
    5    71.14
    6    85.56
    7    69.53
    8    66.52
    9    72.05
    10   66.72
    11   75.11
    12   66.66
    13   73.96
    14   76.36
    15   69.28
    16   73.96
    17   75.47
    18   78.14
    19   70.67
    20   74.60
    21   78.70
    22   88.40
    23   75.49
    24   85.93
    25   76.14
    26   66.23
    27   90.85
    28   72.96
    29   77.61
    30   73.22
    31   84.21
    32   67.46
    33   72.10
    34   79.47
    35   72.29
    36   68.02
    37   74.66
    38   81.03
    39   74.09
    40   61.06
    41   73.60
    42   82.66
    43   67.37
    44   71.04
    45   65.04
    46   75.33
    47   87.47
    48   76.59
    49   57.85
    50   73.52
    51   76.97
    52   90.05
    53   60.48
    54   81.39
    55   75.65
    56   86.17
    57   83.48
    58   74.94
    59   65.19
    60   75.74
    61   85.84
    62   88.14
    63   82.22
    64   85.65
    65   83.77
    66   78.84
    67   72.59
    68   76.97
    69   78.21
    70   66.74
    71   70.82
    72  104.62
    73   69.60
    74   64.01
    75  102.63
    76   73.35
    77   93.42
    78   76.27
    79   81.34
    80   79.39
    81   59.20
    82   52.47
    83   63.66
    84   62.66
    85   56.57
    86   77.21
    87   60.14
    88   48.01
    89   82.61
    90   69.96
    91   61.39
    92   69.77
    93   67.38
    94   88.12
    95   65.50
    96   74.37
    97   75.30
    98   81.37
    99   69.88
    100  69.32
    101  74.77
    102  57.19
    103  62.61
    104  78.46
    105  81.80
    106  75.81
    107  74.92
    108  72.28
    109  74.60
    110  76.63
    111  74.35
    112  77.34
    113  70.88
    114  75.31
    115  70.76
    116  74.28
    117  74.40
    118  70.37
    119  67.99
    120  75.19
    121  72.73
    122  80.29
    123  73.53
    124  74.80
    125  71.81
    126  72.56
    127  71.07
    128  69.59
    129  76.65
    130  73.11
    131  80.28
    132  75.16
    133  78.82
    134  71.72
    > y=data[,1]
    > hist(y)
    > mean(x)
    [1] 78.18949
    > mean(y)
    [1] 74.16612
    > median(y)
    [1] 74.315
    > sd(y)
    [1] 8.570946
    > sd(y)*sd(y)
    [1] 73.46112
    > 73.46112/134
    [1] 0.5482173
    > 
    

    How can I cross the list of whole numbers in the violin R and make calculations based on these values (i.e. start the java code violette) ?



  • You can keep the java object in the simplest text file and then count it in R. Or watch the package. https://cran.r-project.org/web/packages/rJava/index.html


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2