Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hmmm... Vincent, I beg to differ.

What's wrong with :

sage: A=[1,3,2,5]
sage: B=[2,2,1,3]
sage: r.t_test(A,B) ## Note : "t_test", NOT "t.test" !!! See below

Welch Two Sample t-test

data:  sage4 and sage9
t = 0.79241, df = 4.3033, p-value = 0.4695
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.806398  3.306398
sample estimates:
mean of x mean of y 
     2.75      2.00


And, BTW :

sage: r.t_test(A,B).sage()

{'DATA': {'alternative': 'two.sided',
  'conf_int': {'DATA': [-1.80639768054045, 3.30639768054045],
   'conf_level': 0.95},
  'data_name': 'sage5 and sage0',
  'estimate': {'DATA': [2.75, 2], '_Names': ['mean of x', 'mean of y']},
  'method': 'Welch Two Sample t-test',
  'null_value': {'DATA': 0, '_Names': 'difference in means'},
  'p_value': 0.469526519083806,
  'parameter': {'DATA': 4.3033359193173, '_Names': 'df'},
  'statistic': {'DATA': 0.792405815693061, '_Names': 't'}},
 '_Names': ['statistic',
 '_r_class': 'htest'}

The point is, don't forget to replace the "." in R's object's names with "_" (the dot is a "normal character" in R, whereas it has a syntactic value in Python ; the underscore is a "normal character" in Python, whereas it used to represent symbol assignment in (antique versions of) R).

This has been documented ; but I didn't check if this documentation still exists...