identification of function output

How can I determine what are the stored variables in a function such as t.test?
For example, I may want to only output one of the following at a time:
t,df,p-value, confidence interval or mean.

Thanks. MM

t.test(x,y,paired=TRUE,alpha=.10,mu=5,alternative="two.sided")

        Paired t-test

data:  x and y
t = -3.5292, df = 31, p-value = 0.001325
alternative hypothesis: true difference in means is not equal to 5
95 percent confidence interval:
 2.006935 4.199315
sample estimates:
mean of the differences 
               3.103125 

?t.test will bring up help. Then scroll down in help.

Note that the output of t.test() is a list object. It contains different parts of the outcome of the test. To output the aspects you listed above, respectively, I would use something like this:

ttest = t.test(x,y,paired=TRUE,alpha=.10,mu=5,alternative="two.sided")

ttest$statistic
ttest$parameter
ttest$p.value
ttest$conf.int
ttest$estimate

The dollar sign $ allows you to extract those elements.

In general you can see what is in a list with str(), if you get too much info you can limit that with max.level param

str(x,max.level=1)

Also at the top level you can get the names defined on an object with names.
names(x)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.