Displaying 20 results from an estimated 22 matches for "hcen".
Did you mean:
chen
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
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
2008 Nov 20
2
how to replace NA with previous numbers
Hi,
I have a vector with lots of NAs. e.g.
vec = c(NA, NA, 2, NA, NA, 5, NA, 6, NA)
> vec
[1] NA NA 2 NA NA 5 NA 6 NA
I would like to replace NAs with their immediately previous non NA number.
After replacement, the above vector will become
> vec
[1] 0 0 2 2 2 5 5 6 6.
I understand how to do that with a loop but the actual vector is very long
and the loop takes too much time in R.
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
2010 Jan 25
1
ff package: ff objects don't reload completely on NFS drives from a different machine
Try to close the file on the first nfs client before reopening it on the second nfs client. NFS has something called "close-to-open cache consistency".
This means that two clients which have the same nfs file open, cannot rely on seeing the updates from the respective other client. If one clients closes, and the other client opens thereafter, it should see the changes. If you want
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 Dec 29
1
how to append new data to saved data on disk efficiently
Hi,
I currently combine multiple processed data (data frame) into a list and
save the list as ".rda" using the save command. When new data come, I load
the rda file, process the new data into a data frame, append the data
frame to the end of the list, and save the whole list to the disk. The
loading and saving steps are quite time consuming. Since I don't need to
change the old data
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.
2010 Nov 22
2
R package "kernlab" can not be properly loaded
Hi,
I tried to load the package "kernlab" under R-v11 and R-v10, however it gave error message:
Error in library.dynam(lib, package, package.lib) :
shared library 'kernlab' not found
In addition: Warning message:
package 'kernlab' was built under R version 2.12.0
Error: package/namespace load failed for 'kernlab'
Has anybody loaded this successfully before?
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 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,
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 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",
2010 Nov 24
0
4. Rexcel (Luis Felipe Parra)-how to run a code from excel
...t;
> Has anybody loaded this successfully before? Thanks,
Yes, if it was built for R-2.11.x we were using R-2.11.x.
I guess you are under Windows (unstated) where some infrastructure was
changed form R-2.11.x to R-2.12.x and packages compiled for the latter
won't work foer the former.
hcen please run
install.packages("kernlab") in order to get a version that fits to your
R or even better upgrade your version of R.
Uwe Ligges
> Xiaoqi
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailm...
2009 Nov 07
0
solution design for a large scale (> 50G) R computing problem
Hi,
I am tackling a computing problem in R that involves large data. Both time
and memory issues need to be seriously considered. Below is the problem
description and my tentative approach. I would appreciate if any one can
share thoughts on how to solve this problem more efficiently.
I have 1001 multidimensional arrays -- A, B1, ..., B1000. A takes about
500MB in memory and B_i takes 100MB. I
2010 Jan 02
0
filehash - multiple indices via '[' not allowed when using RDS format
Hi,
I have been using filehash for a while. It has performed very well.
However, recently I found filehash gives an error when I need to do
something like db[c("a", "b")] when the db is in RDS format. Does any one
know a way to get around that?
The code below reproduces the error
thanks
Jeff
filehashOption(defaultType = "DB1")
dbCreate("mydb3", type =
2010 Jan 13
1
"select: bad file descriptor" in the multicore package
Hi,
I wonder anyone knows what causes the error message "select: bad file
descriptor" in the multicore package. This error sometimes occurs and
sometimes doesn't. I couldn't find any documentation on this error about
this package.
thanks
Jeff
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
2009 Nov 20
1
how to link C code with gsl from R CMD and dyn.load
Hi,
I am writing a function in C that is meant to be called by R. In the C
function, I used a gsl function gsl_stats_mean. The code is as simple as
below
void gsl(double *m, int *dim){
int r, c;
r = dim[0];
c = dim[1];
double mean = gsl_stats_mean(&m[0], 1, r);
Rprintf("mean = %f\n", mean);
}
The C code is succesfully compiled and the output is as follows.
$ R CMD SHLIB