Displaying 20 results from an estimated 20000 matches similar to: "global objects not overwritten within function"
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
2004 Oct 11
5
read "4-jan-02" as date
Dear R users,
I have a column with dates (character) in a data frame:
12-Jan-01 11-Jan-01 10-Jan-01 9-Jan-01 8-Jan-01 5-Jan-01
and I need to convert them to (Julian) dates so that I can
sort the whole data frame by date. I thought it would be
very simple, but after checking the documentation and the
list I still don't have something that works.
1. as.Date returns the error below. What am I
2005 Apr 06
3
looking for a plot function
Dear useRs,
I have a data frame and I want to plot all rows. Each row is
represented as a line that links the values in each column. The plot
looks like this:
dfr <- data.frame(A=sample(1:50,10),B=sample(1:50,10),
C=sample(1:50,10),D=sample(1:50,10))
xa <- 10*1:4
plot(c(10,40),c(0,50))
for (i in 1:nrow(dfr)) {
lines(xa,dfr[i,],pch=20,type="o")
}
Things get more complicated
2007 Dec 27
1
A function for random test based on longest run (UNCLASSI FIED)
Classification: UNCLASSIFIED
Caveats: NONE
Thanks for your quick response. The program you mentioned below available
from R is based on number of runs (up or down) not based on a longest length
of runs of same events. To be more specific, for example, from a series,
HHTHTTTTHHH, the number of runs are 5, and the longest length of runs of the
same events is 4. I'll check for the website you
2005 Jul 21
3
Rprof fails in combination with RMySQL
Dear R community,
I tried to optimized my R code by using Rprof. In my R code I'm using MySQL
database connections intensively. After a bunch of queries R fails with the
following error message:
Error in .Call("RS_MySQL_newConnection", drvId, con.params, groups, PACKAGE = .MySQLPkgName) :
RS-DBI driver: (could not connect mylogin@mydatabase on dbname "myDB"
2004 Dec 12
2
errors when trying to rename data frame columns
Dear R users,
I need to rename the columns of a series of data frames. The names of
the data frames and those of the columns need to be pulled from some
vectors. I tried a couple of things but only got errors. What am I
missing?
#---create data frame
dframes <- c("a","b","c")
assign(dframes[2],data.frame(11:20,21:30))
#---rename the columns
cols <-
2005 Mar 18
6
Basic questions about RMySQL
Hello,
Please forget me if I am asking something that is well documented. I have read documentation but there are points that are not clear for me. I am not expert in R nor Databases, but if someone direct me to a tutorial, I will appreciate it..
1. In my understanding, I can install and use RMySQL withouth having to install MySQL in my PC, to have access to and to create new tables . Is this
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
2005 Feb 10
3
question about sorting POSIXt vector
Dear useRs,
How come the first attempt to sort a POSIXt vector fails (Error:
non-atomic type in greater), while the second succeeds? (Code inserted
below.) The documentation says that POSIXt is used to allow operations
such as subtraction, so I'd expect sorting to work. Is this perhaps an
OS issue? (I run R 2.0.1 on Win xp.)
Thank you,
b.
#------------code
test <- c("2005-02-08
2005 Jun 08
2
get level combinations from "by" list
Dear useRs,
Given this code I end up with a list of class "by":
a <- sample(1:5,200,replace=TRUE)
b <- sample(c("v1","v2","v3"),200,replace=TRUE)
c <- sample(c(11,22,33),200,replace=TRUE)
data <- runif(200)
grouped <- by(data,list(a,b,c),function(x) {c(min=min(x),max=max(x),
median=round(median(x),digits=2),mean=round(mean(x),digits=2))})
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
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
2001 Apr 09
4
fastest R platform
Hello, everyone! I picked up R several months ago and have adopted it
as my choice for statistical programming. Coming from a Java
background, I can honestly say that R is not only free, it is better
tha S-plus: the lexical scope in R makes it very simple to simulate
Java's object model. For this, I encourage everyone to read the artcle:
Robert Gentleman and Ross Ihaka (2000) "Lexical
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)) ==
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
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 values
for fuzz than others. How should
2005 Sep 01
4
Linux Standalone Server Suggestions for R
Hi All,
My group is looking for any suggestions on what to purchase to
achieve the most powerful number crunching system that $50k can buy.
The main application that will be used is R so input on what hardware
benefits R most will be appreciated. The requirements are that it be
a single standalone server (i.e. not a cluster solution), and it that
must be able to run unix/linux. If
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 clarifies what I'm trying to do:
obj1 <-
2005 Oct 10
1
decreasing performance of for() loop
Dear useRs,
I'm wondering why the for() loop below runs slower as it progresses.
On a Win XP box, the iterations at the beginning run much faster than
those at the end:
1%, iteration 2000, 10:10:16
2%, iteration 4000, 10:10:17
3%, iteration 6000, 10:10:17
98%, iteration 196000, 10:24:04
99%, iteration 198000, 10:24:24
100%, iteration 200000, 10:24:38
Is there something that can be done about
2008 Dec 23
1
.C and 'temporaries'
Hello,
Before I get into troubles I ask here:
I make a call to a 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",