[R] Clarification
Hello, Could someone help me understand why one of these structures would be preferred over the other? x - setClass( patient, representation( data = numeric, fname = character, lname=character, disease = character )) jd - new(patient, data = rnorm(10), fname = John, lname = Doe, disease = CB4) OR x - rnorm(10) attr(x,fname) - Bill attr(x,lname) - Carson attr(x,disease) - CB4 Is this a S3 vs S4 topic? Anyone have suggested reading for this type of stuff? I read S4 classes in 15 pages; are there other resources? Thanks in advance ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] An example of overloading [
Great. Thanks again for all the suggestions. On 3/13/07, Vincent Goulet [EMAIL PROTECTED] wrote: Le Mardi 13 Mars 2007 00:28, Sender a écrit: Hello: Could anyone point me to a nice example where someone has created methods for [ on a user defined Class? I looked at the package Matrix but that was a little daunting. I'm looking for someone a little more introductory. I've tried to search the help section and the web but its difficult since [ isn't searchable. Thanks in advance! You might also have a look at the methods for [ and [- created for grouped data objects in the development version of package actuar. Creation of the objects: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/R/grouped.data.R Extraction methods: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/R/Extract.grouped.data.R Doc: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/man/grouped.data.Rd https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/man/Extract.grouped.data.Rd Package: http://vgoulet.act.ulaval.ca/actuar/ HTH -- Vincent Goulet, Associate Professor Ãcole d'actuariat UniversitÃ(c) Laval, QuÃ(c)bec [EMAIL PROTECTED] http://vgoulet.act.ulaval.ca __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] distance metrics
Hello: Does anyone know if there exists a package that handles methods for [ for dist objects? I would like to access a dist object using matrix notation e.g. dMat = dist(x) dMat[i,j] Thanks in advance to anyone who can point me in the right direction. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] distance metrics
Thanks for the suggestion Christian. I'm trying to avoid expanding the dist object to a matrix, since i'm usually working with microarray data which produces a distance matrix of size 5000 x 5000. If i can keep it in its condensed form i think it will speed things up. Is my thinking correct? On 3/12/07, Christian Hennig [EMAIL PROTECTED] wrote: On Mon, 12 Mar 2007, Sender wrote: Hello: Does anyone know if there exists a package that handles methods for [ for dist objects? I would like to access a dist object using matrix notation e.g. dMat = dist(x) dMat[i,j] Try dMat - as.matrix(dist(x)) Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] An example of overloading [
Hello: Could anyone point me to a nice example where someone has created methods for [ on a user defined Class? I looked at the package Matrix but that was a little daunting. I'm looking for someone a little more introductory. I've tried to search the help section and the web but its difficult since [ isn't searchable. Thanks in advance! Greg [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] An example of overloading [
Super. Thanks for the leads. On 3/12/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Mon, 2007-03-12 at 21:28 -0700, Sender wrote: Hello: Could anyone point me to a nice example where someone has created methods for [ on a user defined Class? I looked at the package Matrix but that was a little daunting. I'm looking for someone a little more introductory. I've tried to search the help section and the web but its difficult since [ isn't searchable. Thanks in advance! Greg You might want to look at this thread from last year: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77057.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77060.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77059.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77102.html You can also review the existing methods defined for '[' in your current installation by using: methods([) It may be easiest to then review the code for a given method by using something like the following as an example: getAnywhere([.data.frame) BTW, for searching the R help files, REGEX's are used, so for [, you would need: help.search(\\[) since '[' is a special character in regular expressions and you need to escape it to search on the literal character. In R, you need to double the '\' to be interpreted properly. HTH, Marc Schwartz [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] An example of overloading [
Any insight as to why this is printing twice? [.mydist - function(x,...){ print(I called my function) } m - a_mydist_obj m[] I called my function I called my function On 3/12/07, Sender [EMAIL PROTECTED] wrote: Super. Thanks for the leads. On 3/12/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Mon, 2007-03-12 at 21:28 -0700, Sender wrote: Hello: Could anyone point me to a nice example where someone has created methods for [ on a user defined Class? I looked at the package Matrix but that was a little daunting. I'm looking for someone a little more introductory. I've tried to search the help section and the web but its difficult since [ isn't searchable. Thanks in advance! Greg You might want to look at this thread from last year: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77057.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77060.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77059.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77102.html You can also review the existing methods defined for '[' in your current installation by using: methods([) It may be easiest to then review the code for a given method by using something like the following as an example: getAnywhere([.data.frame) BTW, for searching the R help files, REGEX's are used, so for [, you would need: help.search (\\[) since '[' is a special character in regular expressions and you need to escape it to search on the literal character. In R, you need to double the '\' to be interpreted properly. HTH, Marc Schwartz [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] setMethod
Hello R-help: I was hoping someone could help me understand a particular function i came across in a package: $.myClass - function( x, name ) { sym = paste( foo, name, sep = _ ) if( is.loaded(sym) ) .Call(sym,x) } I understand the paste, and .Call part, but I'm not sure how this function would get called? What exactly is $. ? is it a regular expression? Would a user call this method directly, or is it an internal function that gets called according to a class/type. something similar to: plot.lm() Thanks in advance ! Greg [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] References about dot a files
Hello: I'm trying to find some reading material about .a files. I'm attempting to build a package which accesses many C routines via .Call, and its been suggested that I need a lib_C_code.a file inside the C directory. What does such a file do? Where can I read somthing about it? I've tried to search for it, but keywords R package .a doesn't work because the .a is too generic. Thanks in advance! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] return tree from .Call
Hello: I was hoping to get some advice about how to return a tree (basically a linked list -- with each node containing a parent, left, and right node pointers) from a C routine back into R. Each node itself contains several attributes (a double, a char *, an int, and a void * ) Initially I was thinking I could just return to R a SEXP containing a pointer to the Root Node, but then realized that the pointer would be useless since C probably frees the memory after I leave the routine. Since trees vary in length (or height) I need to be able to loop thru the tree until all Nodes have been visited and saved in a SEXP. I'm really new to handling R objects from within C, and converting and returning a large tree structure is daunting. Here is some rough code I was thinking about using to do this. Any suggestions or help will be greatly appreciated! SEXP list ; PROTECT( list = allocVector(VECSXP, tree-size) ) ; for( i = 0; i tree-size; ++i ){ SEXP node, tree_double, tree_char, tree_int, tree_voidPTR ; PROTECT( tree_double = NEW_NUMERIC( tree-weight ) ) ; PROTECT( tree_char = NEW_CHARACTER( tree-name ) ) ; PROTECT( tree_int = NEW_INTEGER( tree-exons ) ) ; PROTECT( tree_voidPTR = NEW_CHARACTER( tree-data ) ) ; ??? not sure about this... PROTECT( node = allocVector( VECSXP, 4 ) ) ; SET_VECTOR_ELT( node, 0, tree_double) ; SET_VECTOR_ELT( node, 1, tree_char) ; SET_VECTOR_ELT( node, 2, tree_int) ; SET_VECTOR_ELT( node, 3, tree_voidPTR ) ; SET_VECTOR_ELT( list, i, node ) ; } UNPROTECT( tree-size * 4 ) ; ??? Tricky.. return( list ) ; Look reasonable ? THANKS ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.