Displaying 20 results from an estimated 10000 matches similar to: "how to append new data to saved data on disk efficiently"
2009 Dec 11
4
get the enclosing function name
Hi,
Is there a way to get the enclosing function name within a function?
For example, I would like to have a function getEnclosingFunctionName().
It works like below
f = function(){
print(getEnclosingFunctionName())
}
f() # will print "f"
Thanks
Jeff
2009 Nov 16
8
extracting the last row of each group in a data frame
Hi,
I would like to extract the last row of each group in a data frame.
The data frame is as follows
Name Value
A 1
A 2
A 3
B 4
B 8
C 2
D 3
I would like to get a data frame as
Name Value
A 3
B 8
C 2
D 3
Thank you for your suggestions in advance
Jeff
2009 Dec 02
4
sort a data frame by a vector
Hi,
I have a a vector and a data frame with two columns
vec = c("C", "A", "B")
dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3))
I would like to sort the data frame by column A1 such that the order of
elements in A1 is as the same as in vec.
After the ordering, the data frame would be
A1 A2
C
2009 Dec 29
2
pass functions and arguments to function
Hi,
I wonder how to pass several functions and their arguments as arguments to
a function. For example, the main function is
f = function(X ) {
process1(X)
...
process2(X)
}
I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2),
g3(X, par3). par1, par2 and par3 are parameters and of different types. I
would like to pass g1, g2, g3 and their arguments to f and g1,
2009 Dec 29
1
(no subject)
Hi,
I wonder how to pass several functions and their arguments as arguments to
a function. For example, the main function is
f = function(X ) {
process(X)
...
process(X)
}
I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2),
g3(X, par3). par1, par2 and par3 are parameters and of different types.
2009 Nov 24
1
ow to have R automatically print traceback upon errors
Hi,
I wonder how to have R automatically print stack trace produced by
traceback upon errors during interactive uses. I tried the suggestions on
http://old.nabble.com/Automatically-execute-traceback-when-execution-of-script-causes-error--td22368483.html#a22368775
and used options(error = recover)
options(showErrorCalls = T)
It just produces an extra message like "recover called
2009 Nov 25
3
questions on the ff package
Hi,
I have two questions on using the ff package and wonder if anyone who used
ff can share some thoughts.
I need to save a matrix as a memory-mapped file and load it back later. To
save the matrix, I use
mat = matrix(1:20, 4, 5)
matFF = ff(mat, dim=dim(mat), filename="~/a.mat", overwrite=TRUE, dimnames
= dimnames(mat))
To load it back, I use
matFF2 = ff(vmode = "double",
2008 Nov 17
5
how to calculate another vector based on the data from a combination of two factors
Hi,
I have a data set similar to the following
State Gender Quantity
TX Male 1
NY Female 2
TX Male 3
NY Female 4
I need to calculate cumulative sum of the quantity by State and Gender. The
expected output is
State Gender Quantity CumQuantity
TX Male 1 1
TX Male 3 4
NY Female 2 2
NY Female 4 6
I highly appreciate if someone can give me some hints on solving that in R.
Hao
--
View this
2010 Jan 08
2
how to organize a lot of R source files
Hi,
I wonder what is a better way to organize a lot of R source files. I have
a lot of utility functions written and store them in several source files
(e.g util1.R, util2.R,..utilN.R). I also have a master file in which the
source command is used to load all the util.R files. When I need to use
the utility functions in a new project, I create a new R file (e.g main.R)
in which I
2009 Nov 02
2
save an object by dynamicly created name
Hi,
I would like to save a few dynamically created objects to disk. The
following is the basic flow of the code segment
for(i = 1:10) {
m = i:5
save(m, file = ...) ## ???
}
To distinguish different objects to be saved, I would like to save m as m1,
m2, m3 ..., to file /home/data/m1, /home/data/m2, home/data/m3, ...
I tried a couple of methods on translating between object names and
2009 Dec 24
2
how to do multiple responses in a linear regression
Hi,
I have multiple responses y1, y2, .., yn, and would like to do linear
regression for each of them with x1, x2, ..., xm. Instead of doing
regression n times, it it possible to do it all at once?
I tried lm(y1+y2 ~ x1 + x2 + x3) and lm added y1 y2 and then did the
regression.
thanks
Jeff
2006 Mar 10
2
appending objects to a file created by save()
Hi,
I've been slowly transitioning to saving sets of objects for a project
using save() rather than cluttering my workspace and then doing
save.image()
However, sometimes after I have done say:
save(x,y,z, file='work.Rda')
and I reload it a little later and I see that I also want to save
object p. Currently I need to do:
save(x,y,z,p, file='work.Rda')
Is there any way
2010 Feb 01
2
how to write a function that remembers its state across its calls
Hi,
I wonder how to write a function that remembers its state across its
calls. For example, I would like to compute the average of the pass three
values the function has seen
f(1) # NA
f(2) # NA
f(3) # 2
f(4) # 3
This would require f to keep track of the values it has seen. In other
languages like c++ or java it is easy to do by having a member variable. I
am not sure how to do similar
2008 Aug 22
1
save() should not overwrite a file if an error occurs (PR#12583)
If save() fails because an object is not found,
it should not overwrite an existing file.
> a <- 1:9
> save(a, file = "a.rda")
> rm(a)
> load("a.rda")
> a
[1] 1 2 3 4 5 6 7 8 9
> rm(a)
> save(a, file = "a.rda")
Error in save(a, file = "a.rda") : object 'a' not found
> load("a.rda")
Error in
2010 Oct 05
2
[LLVMdev] gold-plugin build errors
I tried to build the gold plugin and receive the errors posted below. I
checked out the gold plugin using "cvs -z 9 -d
:pserver:anoncvs at sourceware.org:/cvs/src co src," as documented on
llvm.org. Is that version bleeding edge and perhaps not stable?
The first errors have to do with the libtool version. I have libtool
2.2.6 on my system, which is what the README-maintainer-mode
2011 Sep 09
2
get and save
I have a data frame 'tmp' and a vector 'name' containing 'd2'.
I want to save 'tmp' under the name hidden in 'name', and the file must have
the same name, plus the extension '.rda'.
So I try
> tmp
x y
1 1 3
2 2 4
> name
[1] "d2"
> assign(name, tmp)
> summary(get(name))
x y
Min. :1.00 Min. :3.00
1st
2003 Nov 05
1
save(iris,file=
I tried it using file and it seems to work for saving:
> data(iris)
> con <- file("clipboard","w")
> save(iris,ascii=T,file=con)
> close(con)
> readLines("clipboard")
... lengthy output follows which seems correct ...
but not for loading:
> con <- file("clipboard","r")
> load(con)
Error in load(con) : loading from
2007 Aug 11
1
LDA and RDA: different training errors
Hello
I try to fit a LDA and RDA model to the same data, which has two classes.
The problem now is that the training errors of the LDA model and the
training error of the RDA model with alpha=0 are not the same. In my
understanding this should be the case. Am I wrong? Can someone explain what
the reason for this difference could be?
Here my code:
LDA model:
===========
% x is a dataframe
tmp =
2006 Mar 24
2
[PATCH] qemu pcnet emulation fixes
The attached patch to the qemu emulation of the pcnet hardware fixes
several problems. It will now only read and write a transmit or receive
descriptor once. It will correctly handle transmitting frames with more
than two fragments. It will discard oversize frames instead of
corrupting memory. I have tested all the changes I have made and even
seen an improvement in receive performance from
2007 Oct 10
2
slow load() in R2.6.0
I'm encountering excruciatingly slow load times for character vectors in
R 2.6.0-- up to 30sec for a 15K file that contains a no-attributes
character vector of length ~1e4 and object size ~0.5MB. In R 2.5.1,
repeated loads of the same set of files are near-instantaneous.
The problem is proving tricky to reproduce consistently from scratch, so
I have attached the 3 files used in the examples