[R] Extract information from S4 object

2010-02-22 Thread Jay
The function prediction() returns this:

Formal class 'performance' [package ROCR] with 6 slots
  ..@ x.name  : chr Cutoff
  ..@ y.name  : chr Accuracy
  ..@ alpha.name  : chr none
  ..@ x.values:List of 1
  .. ..$ : Named num [1:89933] Inf 2.23 2.22 2.17 2.16 ...
  .. .. ..- attr(*, names)= chr [1:89933]  36477 56800
41667 ...
  ..@ y.values:List of 1
  .. ..$ : num [1:89933] 0.5 0.5 0.5 0.5 0.5 ...
  ..@ alpha.values: list()

Now, since I want to match each prediction with its original case, I
need to extract the names, i.e. the information in - attr(*,
names)= chr [1:89933]  36477 56800 41667 ... so I can use
it with a simple datafile[names,] query.

How do I get these names in plain number formats?

__
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] Extract information from S4 object

2010-02-22 Thread Henrique Dallazuanna
Try this:

 names(o...@x.values)

On Mon, Feb 22, 2010 at 11:05 AM, Jay josip.2...@gmail.com wrote:
 The function prediction() returns this:

 Formal class 'performance' [package ROCR] with 6 slots
  ..@ x.name      : chr Cutoff
  ..@ y.name      : chr Accuracy
  ..@ alpha.name  : chr none
  ..@ x.values    :List of 1
  .. ..$ : Named num [1:89933] Inf 2.23 2.22 2.17 2.16 ...
  .. .. ..- attr(*, names)= chr [1:89933]  36477 56800
 41667 ...
  ..@ y.values    :List of 1
  .. ..$ : num [1:89933] 0.5 0.5 0.5 0.5 0.5 ...
  ..@ alpha.values: list()

 Now, since I want to match each prediction with its original case, I
 need to extract the names, i.e. the information in - attr(*,
 names)= chr [1:89933]  36477 56800 41667 ... so I can use
 it with a simple datafile[names,] query.

 How do I get these names in plain number formats?

 __
 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] Extract information from S4 object

2010-02-22 Thread David Winsemius


On Feb 22, 2010, at 8:05 AM, Jay wrote:


The function prediction() returns this:

Formal class 'performance' [package ROCR] with 6 slots
 ..@ x.name  : chr Cutoff
 ..@ y.name  : chr Accuracy
 ..@ alpha.name  : chr none
 ..@ x.values:List of 1
 .. ..$ : Named num [1:89933] Inf 2.23 2.22 2.17 2.16 ...
 .. .. ..- attr(*, names)= chr [1:89933]  36477 56800
41667 ...
 ..@ y.values:List of 1
 .. ..$ : num [1:89933] 0.5 0.5 0.5 0.5 0.5 ...
 ..@ alpha.values: list()

Now, since I want to match each prediction with its original case, I
need to extract the names, i.e. the information in - attr(*,
names)= chr [1:89933]  36477 56800 41667 ... so I can use
it with a simple datafile[names,] query.

How do I get these names in plain number formats?


Not sure what you mean by plain number formats but this should get  
you a vector of names assuming the prediction object is named  
predobject:


names( predobj...@x.values )

If you wanted them as.numeric, then that is the name of the  
appropriate function.


--
David



__
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.


__
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] Extract information from S4 object

2010-02-22 Thread Jay
Tahnk you. But, when I try the command you both suggested I get a NULL
as the results.

 names(object1 @ x.values)
NULL

Where did I go wrong?


On Feb 22, 4:34 pm, David Winsemius dwinsem...@comcast.net wrote:
 On Feb 22, 2010, at 8:05 AM, Jay wrote:



  The function prediction() returns this:

  Formal class 'performance' [package ROCR] with 6 slots
   ..@ x.name      : chr Cutoff
   ..@ y.name      : chr Accuracy
   ..@ alpha.name  : chr none
   ..@ x.values    :List of 1
   .. ..$ : Named num [1:89933] Inf 2.23 2.22 2.17 2.16 ...
   .. .. ..- attr(*, names)= chr [1:89933]  36477 56800
  41667 ...
   ..@ y.values    :List of 1
   .. ..$ : num [1:89933] 0.5 0.5 0.5 0.5 0.5 ...
   ..@ alpha.values: list()

  Now, since I want to match each prediction with its original case, I
  need to extract the names, i.e. the information in - attr(*,
  names)= chr [1:89933]  36477 56800 41667 ... so I can use
  it with a simple datafile[names,] query.

  How do I get these names in plain number formats?

 Not sure what you mean by plain number formats but this should get  
 you a vector of names assuming the prediction object is named  
 predobject:

 names( predobj...@x.values )

 If you wanted them as.numeric, then that is the name of the  
 appropriate function.

 --
 David



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

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

__
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] Extract information from S4 object

2010-02-22 Thread Martin Morgan
On 02/22/2010 08:46 AM, Jay wrote:
 Tahnk you. But, when I try the command you both suggested I get a NULL
 as the results.
 
 names(object1 @ x.values)
 NULL
 
 Where did I go wrong?
 
 
 On Feb 22, 4:34 pm, David Winsemius dwinsem...@comcast.net wrote:
 On Feb 22, 2010, at 8:05 AM, Jay wrote:



 The function prediction() returns this:

 Formal class 'performance' [package ROCR] with 6 slots
  ..@ x.name  : chr Cutoff
  ..@ y.name  : chr Accuracy
  ..@ alpha.name  : chr none
  ..@ x.values:List of 1
  .. ..$ : Named num [1:89933] Inf 2.23 2.22 2.17 2.16 ...
  .. .. ..- attr(*, names)= chr [1:89933]  36477 56800

pred...@x.values is a list. The first element of the list
pred...@x.values[[1]] is a numeric vector. The numeric vector has names.
So names(pred...@x.values[[1]]).

Martin

 41667 ...
  ..@ y.values:List of 1
  .. ..$ : num [1:89933] 0.5 0.5 0.5 0.5 0.5 ...
  ..@ alpha.values: list()

 Now, since I want to match each prediction with its original case, I
 need to extract the names, i.e. the information in - attr(*,
 names)= chr [1:89933]  36477 56800 41667 ... so I can use
 it with a simple datafile[names,] query.

 How do I get these names in plain number formats?

 Not sure what you mean by plain number formats but this should get  
 you a vector of names assuming the prediction object is named  
 predobject:

 names( predobj...@x.values )

 If you wanted them as.numeric, then that is the name of the  
 appropriate function.

 --
 David



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

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
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.