Displaying 20 results from an estimated 100 matches similar to: "problem accumulating array within a function over loops"
2003 Oct 31
1
strange sprintf() behaviour ?
This is quite strange behaviour - at least for R-novice as myself....
Consider this:
> testf <- function() { x <-2; sprintf("%s %f", "x =", x); return(x) }
> result <- testf()
> testf <- function() { x <-2; sprintf("%s %f", "x =", x) }
> result <- testf()
> testf()
[1] "x = 2.000000"
Apparently adding return()
2004 Dec 22
4
ordering levels
Hello!
I would like to know if there is a simple way to reorder levels of a given factor.Let's say that the vector
testf<-factor(c("red","red","red","blue","blue","white"))
levels(testf) : blue red white
should have reordered levels such as
levels(testf) : red blue white
(this is for presentation purposes)
I guess
2008 Oct 20
1
[LLVMdev] mixed bc file
I have a question with llvm-gcc and llvm-gfortran.
Is it possible that llvm-ld can combine different bc files compiled from C programme and Fortran Programme together?
For example:
Compile a c program into llvm bc file by the task:
# llvm-gcc -emit-llvm test.c -c -o test.bc
and then compile a fortran program into llvm bc file by the task:
# llvm-gfortran -emit-llvm testf.f -c -o testf.bc
And
2012 Apr 17
4
parallel processing with multiple directories
Hello,
I would like to run some code in parallel with each cluster reading/writing to a different working directory. I've tried the following code without success. The error I get is: "Error in setwd(x) : cannot change working directory"
library(parallel)
dirs <- list("out1","out2","out3") # these directories are located within the current
2004 Dec 22
2
RE ordering levels
Sorry, sorry....
of course
levels(testf)[c(2,1,3)]
will do the job
My excuses to all
Anne
PS I will meditate the following saying
"la parole est d'argent et le silence est d'or"
BONNES FETES A TOUS
SEASONAL GREETINGS
----------------------------------------------------
Anne Piotet
Tel: +41 79 359 83 32 (mobile)
Email: anne.piotet@m-td.com
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 <-
2012 Jan 13
2
question: how to select a column from a dataframe in a function
Hi,
I am creating a function and ran into the problem of selecting a column
from a dataset. It seems as though the $ function (as in data$columnname)
does not apply in the function. In simplified version:
This works:
testf2<-function(data,columnnumber){print(data[,columnnumber])}
But this doesn't:
testf<-function(data,column){print(data$column)}
Even though the first solution works,
2012 Jan 06
6
cbind alternate
I have two one dimensional list of elements and want to perform cbind and
then write into a file. The number of entries are more than a million in
both lists. R is taking a lot of time performing this operation.
Is there any alternate way to perform cbind?
x = table1[1:1000000,1]
y = table2[1:1000000,5]
z = cbind(x,y) //hanging the machine
write.table(z,'out.txt)
--
-------------
2007 Jan 31
7
features of save and save.image (unexpected file sizes)
Hi,
Today I came upon unexpected R behaviour. I did some modelling and the
result was R object, about 28MB size (nested list, with matrixes as
list elements). When I was saving the session with save.image, the
resulting .RData file was 300MB. There were no other large objects:
>
2008 Oct 15
0
[LLVMdev] LLVM 2.4 problem? (resend)
Tatu Vaajalahti wrote:
> With this program llvm-gcc -O2 optimizes test2 away even though it's
> address is taken in program (gcc-4.2 does not, neither does llvm-gcc
> with -O or -O0):
>
>
> #include <stdio.h>
>
> static const char test1 = 'x';
> static const char test2 = 'x';
>
> int main(int argc, char **argv)
> {
>
2008 Oct 15
4
[LLVMdev] LLVM 2.4 problem? (resend)
On 15.10.2008, at 3.42, Chris Lattner wrote:
>
> On Oct 14, 2008, at 12:52 PM, Tatu Vaajalahti wrote:
>
>>
>> Hi,
>>
>> I don't know enough C to know for certain if this is a programmer or
>> compiler error:
>
> Hi Tatu,
>
> With this information it is impossible to tell if it is your fault or
> llvm's fault. Please file a bug with a
2006 Dec 13
2
persp() problem
Dear list,
I have a problem on persp()
x <- u1data #first coloum in attached data
y <- u2data #second coloum in attached data
f <- function(x,y){qgev(pnorm(rhoF*qnorm(pnorm((qnorm(y)-rho2*qnorm(x)/sqrt(1-rho2^2))))
+sqrt(1-rhoF^2)*qnorm(0.95)),-0.3935119, 0.4227890,
0.2701648)}
z <- outer(x,y,f)
persp(x,y,z)
The R will display:
"Error in persp.default(x, y,
2003 Apr 17
4
A function as argument of another function
Dear all,
I would like to write a function like:
myfun<-function(x,fn) {xx<-exp(x); x*fn(xx)}
where fn is a symbolic description of any function with its argument to be
specified. Therefore
myfun(5,"2+0.3*y^2")
should return 5*(2+0.3*exp(5)^2),
myfun(5,"log(y)") should return 5*log(exp(5)) and so on.
I tried with "expression" and others, but without success.
2008 Mar 27
2
assistance with RDAtest beta version application
Pierre Legendre has developed a beta version of a new redundancy analysis package called RdaTest that is available on his web page at the Universit® de Montréal. The test example that is included with the package is based on the example provided in his book (Numerical Ecology, Chapter 11 (Legendre & Legendre 1998))
I have downloaded the package and am attempting to run it so that I might
2004 Dec 22
0
ordering levels: I was wrong
I was wrong about needing the Relevel from the Lexis package.
The default verson of relevel does the job of reshuffling levels
in any desired order, albeit with a warning (which comes from the
fact that apparently only a single number had been anticipated by
the designer):
> testf <- factor( sample( letters[1:4], 100, replace=T ) )
> table( testf, newf=relevel( testf, ref=c(3,2,1,4) )
2009 Apr 29
0
combine_factor to empty level
ID: T8dfe471e360ac80264c6c
Dear,
I'm using R 2.8.1 with the package reshape version 0.8.2 .
It seems that the combine_factor function has problems with combining levels to
an empty level:
#EXAMPLE WORKING
test<-sample(c(1:10),1000,replace=T)
testf<-factor(test, c(1:10), LETTERS[1:10])
table(testf,exclude=NULL)
testc<-combine_factor(testf, c(1,1,1,1,1,2,2,2,2,2))
2004 Dec 22
0
relevel expansion suggestion
To the R developers,
The discussion below reminded me that I think it might be a good idea
to take the Relevel function from the Lexis package and replace relevel
in stats with it. This is really nothing special for epidemiology.
It is fully compatible with the existing relevel (it actually contains
the
relevel code almost verbatim as a subset), but it has the extra
functionality
of combining
2004 Oct 13
4
incomplete function output
Dear R users,
I have a function (below) which encompasses several tests.
However, when I run it, only the output of the last test is
displayed. How can I ensure that the function root(var)
will run and display the output from all tests, and not
just the last one?
Thank you,
b.
root <- function(var)
{
#---Phillips-Perron
PP.test(var, lshort = TRUE)
PP.test(var, lshort = FALSE)
2008 Oct 15
6
[LLVMdev] LLVM 2.4 problem? (resend)
On 15.10.2008, at 14.01, Pertti Kellomäki wrote:
> Tatu Vaajalahti wrote:
>> With this program llvm-gcc -O2 optimizes test2 away even though it's
>> address is taken in program (gcc-4.2 does not, neither does llvm-gcc
>> with -O or -O0):
>>
>>
>> #include <stdio.h>
>>
>> static const char test1 = 'x';
>> static const char
2006 Aug 24
1
make - perl - broken
Could you help me trouble shoot this? I am a bit of a rookie and
probably screwed something up.
I am trying to "make" imapsync, but there is a complaint regarding some
Perl problem that I cannot figure out.
[root at testmail imapsync-1.182]# make
Use of uninitialized value in concatenation (.) or string at
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/Scalar/Util.pm line 30.
is