search for: obj2

Displaying 20 results from an estimated 55 matches for "obj2".

Did you mean: obj
2011 Oct 05
6
reporting multiple objects out of a function
Dear folks, I?m trying to build a function to create and make available some variables I frequently use for testing purposes. Suppose I have a function that takes some inputs and creates (internally) several named objects. Say, fun1 <- function(x, y, z) {obj1 <- x; obj2 <- y; obj3 <- z <missing stuff> } Here is the challenge: After I run it, I want the objects to be available in the calling environment, but not necessarily in the global environment. I want them to be individually available, not as part of a list or some larger object. I can not figu...
2011 Aug 28
2
converting matrix in array
Hi everyone, have a small problem trying to converting a dataset in matrix form to an array. Specifically: data include 3D measurement -x,y,z of 59 points in 36 objects. They are stored as a matrix (x) of 2124 rows and 3 columns. What I want to do is to extract each subject's dataset using an array (b). Accordingly, I tried the following command: b<-array(a,c(59,3,36)). The problem is
1998 May 14
0
all.equal - cut two, test.equal
...ly in a separate post. One shortcoming of the following all.equal is that numeric elements of a list are not compared using tolerance. If anyone has a simple suggestion for extracting the numeric parts of a list I would like to incorporate it. Paul Gilbert _______ test.equal <-function (obj1, obj2, ...) UseMethod("test.equal") test.equal.default <-function (obj1, obj2, ...) { if (is.array(obj1)) test.equal.array(obj1, obj2, ...) else is.logical(all.equal(obj1, obj2, ...)) } all.equal <- function(obj1, obj2, tolerance=100*Machine()$double.eps)...
1998 May 21
1
all.equal - cut three
...act all numeric elements and compare using tolerance. It also tries to do a relative comparison rather than an absolute comparison, except for very small numbers. I hope someone with more experience than I have will examine this part carefully! Paul Gilbert _______ test.equal <-function (obj1, obj2, ...) UseMethod("test.equal") test.equal.default <-function (obj1, obj2, ...) { if (is.array(obj1)) test.equal.array(obj1, obj2, ...) else is.logical(all.equal(obj1, obj2, ...)) } all.equal <- function(obj1, obj2,...) {UseMethod("all.equal&quo...
1998 May 13
1
all.equal
I need the function all.equal which is in Splus but not yet in R. Below is a first cut. Comments would be appreciated. Paul Gilbert _______ all.equal <- function(obj1, obj2, ...) {if(mode(obj1) != mode(obj2) ) return("modes differ.") if(class(obj1) != class(obj2)) return("classes differ.") if(! all(unlist(attributes(obj1)) == unlist(attributes(obj2)))) return("attributes dif...
1998 Jun 25
1
all.equal
I'm not sure what the process is for this, but can I get the following all.equal function put in the R base? Paul Gilbert ____ all.equal <- function(obj1, obj2,...) {UseMethod("all.equal")} all.equal.default <- function(obj1, obj2, tolerance=.Machine$double.eps) {if(mode(obj1) != mode(obj2) ) return("modes differ.") if (length(obj1) != length(obj2) ) return("lengths differ") if(is...
2005 Jan 11
5
global objects not overwritten within function
Dear useRs, I have a function that creates several global objects with assign("obj",obj,.GlobalEnv), and which I need to run iteratively in another function. The code is similar to f <- function(...) { assign("obj",obj,.GlobalEnv) } fct <- function(...) { for (i in 1:1000) { ... f(...) ...obj... rm(obj) #code fails without this line } } I don't understand
2006 Jul 07
3
attach and detach question
I have a large R program that I am constantly running over and over again. At the beginning of this program, I create a hige matrix and a huge dataframe but these are constant. What I mean by constant is that, if I run the program over later, I really should just use the old matrix and dataframe ( if they exist ) that were created in a previous run so that the program doesn't have to spend
2010 May 26
1
problem with not in in subseting dataframe
Hi all, I have a problem while subsetting a dataframe that is while I am using *%in%* condition like *stemp<-subset(temp, obj1 %in% obj2,select=c(temp))* this is working and giving results that what ever is there is both *obj1*and *obj2* ** ** but I want to get values which is there in *obj1* but not in *obj2 * can anyone help me how to get those values. i tried with *%o%* but i am not able to get it thanks in advance kiran [...
2004 Jan 16
2
reference to objects
Hi, is there a way to reference to a data object without copying it? For example I have a huge matrix called dist and I want two objects obj1 and obj2 to have a memeber dist that points to the matrix, but I don't want, for memory reasons, to copy the matrix twice. As far as I understand the following code will generate three copies of my data: dist <- some_code_that_generates_data obj1$dist <- dist obj2$dist <- dist Thank you! Gia...
2006 Mar 13
4
Trouble Using AR Object based on a Piggyback Query?
...e"=>"asd"}> # Here I''m accessing it''s data fine... >> obj["hc_city"] => "Carson City" # This is an ActiveRecord object which uses a hand-written piggyback query in the model (the query is working fine as you can see...) >> obj2 => [#<ContractHc:0x22e8e2c @attributes={"city"=>"Carson City", "zip"=>"22122", "region"=>"Wild West", "dep_name_short"=>"Posse HFR", "kind"=>"Active", "pnl_name_long"=&...
2008 Dec 23
1
.C and 'temporaries'
...C function using .C. What I would like to know is if the arguments in the .C call can also be 'temporary' objects. An example will illustrate this: # here we don't have a temporary Obj1 = 5 .C("Func", as.integer(Obj1 ), ...) # certainly works # here we do have a temporary Obj2 = 5 .C("Func", as.integer(Obj2 + 100), ...) # is this guaranteed to work? Is the second call valid? Is it also valid if DUP = FALSE, or only if DUP = TRUE ? Thanks, Thomas
2001 Oct 01
1
generic default values
I have a generic function test.equal <- function(obj1, obj2, ...) UseMethod("test.equal") however, the only argument that specific methods use is "fuzz" so I would like to change this to test.equal <- function(obj1, obj2, fuzz=???) UseMethod("test.equal") The problem is that some methods use slightly different default val...
2001 Apr 09
4
fastest R platform
...sum.weight <- 0; uu <- matrix(0, n.random, n.random); pi <- numeric(n); product <- numeric(n); func <- one.score.Hessian(D.u.inv, ada.part, x, y, z); for(i in 1:n.simu) { obj1 <- rmulti.norm(mean, var.half); obj2 <- func(obj1$ran); weight <- exp(obj2$log.likelihood - obj1$log.prob); uu <- uu + my.outer(obj1$ran) * weight; pi <- pi + obj2$pi * weight; product <- product + obj2$pi*(1-obj2$pi) * weight; sum.weight <- s...
2010 Mar 14
3
likelihood ratio test between glmer and glm
...Residual deviance: 235.34 on 173 degrees of freedom AIC: 255.97 Number of Fisher Scoring iterations: 3 Based on a discussion found on the R mailing list but dating back to 2008, I have compared the log-likelihoods of the glm model and of the glmer model as follows: lrt <- function (obj1, obj2){ L0 <- logLik(obj1) L1 <- logLik(obj2) L01 <- as.vector(- 2 * (L0 - L1)) df <- attr(L1, "df") - attr(L0, "df") list(L01 = L01, df = df, "p-value" = pchisq(L01, df, lower.tail = FALSE)) } gm0 <- glm(cbind(female,male)~date,family = binomial, data =...
2011 Sep 07
1
access objects
hi, say I have consecutively numbered objects obj1, obj2, ... in my R workspace. I want to acces one of them inside a function, with the number given as an argument. Where can I find help on how to do that? Somebody must have been trying to do this before... Some keywords to start a search are appreciated as well. Here's an example, I hope it clari...
2013 Sep 06
1
directives to explicitely exclude objects from import into namespaces
...ll import all the non-conflicting objects, methods, and classes of the respective package namespace. So would it be possible to have some new directives along the lines import(<pkg>) ## importing the whole namespace of <pkg> in a first step notimportFrom(<pkg>, <obj1>, <obj2>,....) ## exclude <obj1>, <obj2>, ... again from the previous namespace import ## and, similarly, notimportMethodsFrom(<pkg>, <meth1>, <meth2>,....) notimportClassesFrom(<pkg>, <cls1>, <cls2>,....) in the NAMESPACE file? Ot...
2005 Jul 04
3
How difficult is it to wrap a large C++ library with R?
...ort) using R? If most of the answers are yes, it may be a good idea to switch to R. * Wrap C++ class hierarchy. Virtual functions need to be supported. (SWIG can generate Python shadow classes that behave almost exactly like the underlying C++ classes) * Be able to do this: evolve(ops=c(obj1, obj2, obj3)) Internally, evolve will call virtual function fun() of obj1, obj2, .etc. obj1, obj2, ... are objects derived from the same base class. * Direct access to C++ data structure. For example, an object may keep a C array internally. I will need a method (maybe wrap this data into a R objec...
2005 May 07
1
Test on mu with multivariate normal distribution
...distribution. I thought ?simtest? could be the right function to get the p-value, but I fail to use R correctly. Here is what I tried to do: f1 <- factor(c("8", "10", "12", "14")) X <- matrix(1:16, ncol=4) colnames(X) <- c("Obj1","Obj2","Obj3","Obj4") X.frame <- data.frame(f1,X) Y <- matrix(1:12, ncol=4) colnames(Y) <- c("Obj1","Obj2","Obj3","Obj4") Y.frame <- data.frame(f1,Y) XY <- data.frame(X.frame, Y.frame) # won?t work, because of different nr...
2011 Jun 08
1
Reference Class error message: may be caused by lazy evaluation?
...# Error in print(addOne) : object 'addOne' not found obj$addOne() # return 2, works obj$show() # after calling addOne(), show() works ## works if use .self$... obj2 <- new("testclass", a = 1) obj2$showself() ## works when call the method directly within another method obj3 <- new("testclass", a = 1) obj3$add() ################ end ########################################## I am still learning this new technique, if I made any mista...