Skip to content
Prev 154927 / 398506 Next

Filter Values Out of R Output

On 9/3/2008 12:20 PM, Tobias Binz wrote:
str() will compactly display the structure of an object, including the
result of calling cor.test().  Once you know the structure, you can
isolate and save a component.

x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)

str(cor.test(x, y, method = "kendall", alternative = "greater"))
List of 8
 $ statistic  : Named num 26
  ..- attr(*, "names")= chr "T"
 $ parameter  : NULL
 $ p.value    : num 0.0597
 $ estimate   : Named num 0.444
  ..- attr(*, "names")= chr "tau"
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "tau"
 $ alternative: chr "greater"
 $ method     : chr "Kendall's rank correlation tau"
 $ data.name  : chr "x and y"
 - attr(*, "class")= chr "htest"

cor.test(x, y, method = "kendall", alternative = "greater")$p.value
[1] 0.05971947