Some R functions retrieve many statistical parameters such as pvalue, confidence interval etc… I would like to know how it is possible to extract those parameters from a R object ? For example here how can I get pvalue, t, df or the confidence interval of a simple t test ?
Thank’s for your help !
julia> using RCall
julia> x = randn(10)
10-element Array{Float64,1}:
-0.47693327074660957
1.0387442907193456
1.471145177183246
1.2446523937552667
-0.2859950512876116
-0.237134944977618
-0.46232255238398723
-0.5811878146338813
1.6876079198157776
-1.2109048316637905
julia> r = R"t.test($x)"
RObject{VecSxp}
One Sample t-test
data: `#JL`$x
t = 0.67176, df = 9, p-value = 0.5186
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-0.5179367 0.9554709
sample estimates:
mean of x
0.2187671
julia> fieldnames(RObject{VecSxp})
(:p,)
julia> getfield(r,:p)
Ptr{VecSxp} @0x000000000355c7d8
julia> r.p
Ptr{VecSxp} @0x000000000355c7d8
@Fred, it was already late when I wrote my first answer and therefore this supplement: Why do you take R for the t-test? Julia also offers the t-Test in all variations:
julia> EqualVarianceTTest(x, y)
Population details:
parameter of interest: Mean difference
value under h_0: 0
point estimate: -0.19901727472999997
95% confidence interval: (-0.4737, 0.0757)
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.1546
Details:
number of observations: [100,100]
t-statistic: -1.4287730680428585
degrees of freedom: 198
empirical standard error: 0.13929243151441464
Attention, advertising block! The t-test with Julia and RCall is described here: ISBN-13: 978-3749485086
@Gunter_Faes Thank you very much for your answer ! I will try your solution
In fact the t.test is just a simple example for illustration purpose. What I tried do do is much more complex : I have to computes a lot of hazard ratios and their pvalues. Unfortunately in Julia package I did not found the equivalent of the R packages.
I thought to use the hazard ratio from R into Julia. But, the functions I need are not in R base, and I have to load at least 2 R packages
library(survival)
library(qvalue)
I realized that for each hasard ratio + pvalue computation I will have to load not only a R function but also some R packages, such as
I thus imagined that the time I would gain computing loops in Julia will be certainly lost by the overaid of a lot of many “heavy” RCalls (loading not only functions but packages). Do you agree ?
@Fred, possibly. If you want to use some R-packages and even more R-functions, which are not available in Julia (-packages) yet, it is surely right to work with R. Creating an R script and then importing the required R information into Julia is certainly too much effort. I once did a PCA (This is my sample script page for the book) in Julia with R support, just for info.