Displaying 20 results from an estimated 600 matches similar to: "S4 Inheritance of environments"
2010 Nov 07
2
stupid R tricks
Hi all,
Just thought I'd post this (maybe) helpful tool I wrote. For people
like me who are bad at keeping a clean environment, it's a time-saver.
#simple command to get only one type of object in current environment
lstype<-function(type='closure'){
inlist<-ls(.GlobalEnv)
if (type=='function') type <-'closure'
2007 Jun 26
1
A really simple data manipulation example
In response to those who asked for a better explanation of what the
Vilno software does, here's a simple example that gives some idea of
what it does.
LABRESULTS is a dataset with multiple rows per patient , with lab
sodium measurements. It has columns: PATIENT_ID, VISIT_NUM, and
SODIUM.
DEMO is a dataset with one row per patient, with demographic data.
It has columns: PATIENT_ID, GENDER.
2008 Jun 07
1
slot(obj, "nosuch") documentation question
Using slot() on object (or "@") and using a nonexistent
slotname returns an error (see example code).
R> setClass("foobar", representation=list(a="numeric"))
[1] "foobar"
R> foobar <- new("foobar", a=5)
R> foobar at a
[1] 5
R> foobar at b
Error: no slot of name "b" for this object of class "foobar"
The details
2005 Jan 18
1
"Attach" for S4 objects?
When passing a list as an argument to a function, I find it convenient
to attach it in the first line of th function code, then refer to the
components as A, B, etc. rather than as list$A, list$B, etc.
If I pass a S4 class object, is there a way to "attach" it, or do I have
to refer to the slots as object at A, objetc at B, etc.?
I could always make copies,
A <- object at A
2011 Feb 22
1
error with 'hash' library
Hello,
I'm using R2.10 on Windows 2000 and I'm having trouble installing the 'hash'
library. This is the error I get:
> library(hash)
_ _
___ _ __ ___ _ __ __| | __ _| |_ __ _
/ _ \| '_ \ / _ \ '_ \ / _` |/ _' | __/ _' |
| (_) | |_) | __/ | | | (_| | (_| | || (_| |
\___/| .__/ \___|_| |_|\__,_|\__,_|\__\__,_|
2013 Feb 15
1
Iterating through slots of an S4 object
I want to loop through slots of an S4 object and am unsure how to do so
since the only way I can find to access them is individually in the form
'object@slotName'. I have guessed at a few possibilities which did not work
and I have read some S4 object tutorials and things but still unsuccessful.
I presume it is possible though?
Any help would be much appreciated,
Scott
[[alternative
2010 May 07
0
hash-2.0.0
The hash-2.0.0 has been released to CRAN.
This package implements a data structure similar to hashes in Perl and
dictionaries in Python but with a purposefully R flavor. For objects of
appreciable size, access using hashes outperforms native named lists and
vectors.
This version accounts for changes in R-2.11.0 and is optimized for both
speed and usabiity.
Some references:
2010 May 07
0
hash-2.0.0
The hash-2.0.0 has been released to CRAN.
This package implements a data structure similar to hashes in Perl and
dictionaries in Python but with a purposefully R flavor. For objects of
appreciable size, access using hashes outperforms native named lists and
vectors.
This version accounts for changes in R-2.11.0 and is optimized for both
speed and usabiity.
Some references:
2005 Nov 18
3
Method for $
Dear R experts,
I have defined a class "myclass" and would like the slots to be extractable
not only by "@" but also by "$". I now try to write a method for "$" that
simply executes the request object at slotname, whenever someone calls
object$slotname for any object of class "myclass".
I don't manage to find out how I can provide this
2017 Jun 06
2
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
Hi,
It's nice to be able to define S4 classes with slots that correspond
to standard attributes:
setClass("A1", slots=c(names="character"))
setClass("A2", slots=c(dim="integer"))
setClass("A3", slots=c(dimnames="list"))
By doing this, one gets a few methods for free:
a1 <- new("A1", names=letters[1:3])
2007 Jun 13
3
Awk and Vilno
In clinical trial data preparation and many other data situations, the
statistical programmer needs to merge and re-merge multiple input
files countless times. A syntax for merging files that is clear and
concise is very important for the statistical programmer's
productivity.
Here is how Vilno does it:
inlist dataset1 dataset2 dataset3 ;
joinby variable1 variable2 where ( var3<=var4 ) ;
2008 Nov 20
1
How to convert S4 class slots into data.frame or how to assign variables of type 'Date'
Hi,
I created a class (S4) with some slots like value, date, description
(it's actually a financial transaction class). Now I need a method to
convert this class forth and back into a single row data.frame, where
every slots represents a column. This method looks at the moment like
this:
> setMethod("as.data.frame", "Transaction",
function(x, row.names =
2017 Jun 06
1
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
I've fixed this and will commit soon.
Disregard my dim<-() example; that behaves as expected (the class needs a
dim<-() method).
Michael
On Tue, Jun 6, 2017 at 5:16 AM, Michael Lawrence <michafla at gene.com> wrote:
> Thanks for the report. The issue is that one cannot set special attributes
> like names, dim, dimnames, etc on S4 objects. I was aready working on this
>
2005 Feb 24
4
r: functions
hi all
i have a function that uses two inputs, say xdata and ydata. An example
is the following,
simple1<-function(xdata,ydata)
{
ofit<-lm(ydata~xdata)
list(ofit)
}
say i use arbitray number for xdata and ydata such that
D =
x1 x2 y
1 1 10
2 6 6
3 10 7
x<-D[,1:2]
and
y<-D[,3]
if one uses these inputs and rund the program we get the following:
>simple(xdata=x,ydata=y)
2010 Dec 17
4
using ls() to find a function
Dear R People:
Is there a way to find which objects are functions via ls(), please?
I'm sure that there is, but I'm not sure how.
Thanks,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
2008 Sep 10
3
writing simple function through script
Hi all,
I try to write a simple function in a script. The script is as follows
yo<-function(Xdata)
{
n<-length(Xdata[,1])
Lgm<-nls(formula=LgmFormula,
data=Xdata,
start=list(a=1500,b=0.1),weights=Xdata$Qe)
return(Lgm)
}
After the execution of the script, when I call the function yo on data
called NC60.DATA I get an error.
#yo(NC60.DATA)
Erreur dans eval(expr, envir, enclos)
2012 Dec 27
2
Bootstrap
Hola, buenas tardes
estoy intentando hacer un bootstrap de un modelo, pero me da el siguiente
error:
"Error in FUN(newX[, i], ...) :
unused argument(s) (list(age = c(33, 47, 49, 56, 60, 64, 64, 66, 68, 69,
71, 71, 72, 73, 74, 75, 75, 76, 78, 81, 83, 83, 36, 43, 46, 47, 49, 49, 51,
51, 52, 52, 53, 54, 54, 54, 55, 56, 56, 57, 57, 58, 58, 58, 58, 59, 59, 60,
61, 62, 63, 64, 65, 65, 66, 66,
2009 Jun 18
1
validObject throws non-caught error when slot doesn't exist
I have been retooling an S4 class definition to include another slot and
have found that the methods::validObject function (defined in
methods/R/SClasses.R) in R-devel throws an error that isn't caught
internally (and thus not controllable by 'test' argument) when
retrieving a non-existent slot. The offending line of code is shown below:
> validObject
function (object, test =
2008 Dec 18
1
using jackknife in linear models
Hi R-experts,
I want to use the jackknife function from the bootstrap package onto a
linear model.
I can't figure out how to do that. The manual says the following:
# To jackknife functions of more complex data structures,
# write theta so that its argument x
# is the set of observation numbers
# and simply pass as data to jackknife the vector 1,2,..n.
# For example, to jackknife
#
2012 Sep 13
1
[LLVMdev] Parsing C++ template parameters using cindex.py
Hi,
I am parsing a C++ file using cindex.py and want to get the template
parameters to a specific node. However, the tree seems to be different
depending on if the template parameter is a struct/class or a simple
type such as int or float. In the first case the template type is
appended as a child to the VAR_DECL node (the TYPE_REF node seen in
the example below), but this is not the case with