[R] Filter Values Out of R Output

2008-09-03 Thread Tobias Binz

Hi list

Is there a possibility to filter certain values out of an R output?

In my case: I want to create a vector of p-values in a for loop that  
invokes for every increment cor.test() on two vectors.


I haven't found a way yet to tell cor.test() to only return the p- 
values instead of the whole text.


Thanks,
Tobi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filter Values Out of R Output

2008-09-03 Thread Jorge Ivan Velez
Dear Tobias,
From ?cor.test:

# Data set
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)

# Including text
res=cor.test(x, y, method = pearson)
res

# Just the p.value
res$p.value

Also, you might be interested in
thishttp://www.nabble.com/Re:-applying-cor.test-to-a-(m,-n)-matrix---SUMMARY-to17150239.html#a17150239post.

HTH,


Jorge



On Wed, Sep 3, 2008 at 12:20 PM, Tobias Binz [EMAIL PROTECTED]
 wrote:

 Hi list

 Is there a possibility to filter certain values out of an R output?

 In my case: I want to create a vector of p-values in a for loop that
 invokes for every increment cor.test() on two vectors.

 I haven't found a way yet to tell cor.test() to only return the p-values
 instead of the whole text.

 Thanks,
 Tobi

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filter Values Out of R Output

2008-09-03 Thread Chuck Cleland
On 9/3/2008 12:20 PM, Tobias Binz wrote:
 Hi list
 
 Is there a possibility to filter certain values out of an R output?
 
 In my case: I want to create a vector of p-values in a for loop that
 invokes for every increment cor.test() on two vectors.
 
 I haven't found a way yet to tell cor.test() to only return the p-values
 instead of the whole text.

  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

 Thanks,
 Tobi
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.