[R] as.numeric in data.frame, but only where it is possible

2008-11-26 Thread Kinoko
Hi, I would like to convert my "character" sequences in my matrix/ data.frame into "numeric" where it is possible. I would also like to retain my alphabetic character strings in their original forms. "5.1" > 5.1 "hm" > "hm" k<-matrix(c("aa", "bb", 1,2, 4.3, 0), nrow=2) mode(k) <- "nume

Re: [R] how to pause between graphics

2008-11-25 Thread Kinoko
Thanks for the answer. Surely, without popping windows it is a lot more convenient. This piece of code seems to work for me. def.par <- par(no.readonly = TRUE) png(file="thisPlot.png", width = 1200, height = 800, units = "px", pointsize = 12) plot(blah-blah... dev.off() par(def.par) best g

[R] how to plot and save plots in batch mode

2008-11-25 Thread Kinoko
Dear list, This is not a question but a rather short note how to save a plot if it was created in batch mode. It took me like 2 hours to figure it out, I hope it can save time for those who - like me - are not really fast in picking up diosyncrasies of R. (as far as I remember I had no problems wh

Re: [R] invoking user-defined function

2008-11-25 Thread Kinoko
Philipp, thanks for the tip. source("path-to-my-script") did the trick. On Nov 25, 5:25 pm, Philipp Pagel <[EMAIL PROTECTED]> wrote: > On Mon, Nov 24, 2008 at 11:35:37PM -0800, Kinoko wrote: > > Can somebody tell me how to invoke user-defined functions from script

[R] invoking user-defined function

2008-11-24 Thread Kinoko
Dear list, Can somebody tell me how to invoke user-defined functions from script files during run-time? Basically I have (almost) one function per script file. I am thinking of something like #include in C++ import in Java/Python use in Perl No, I don't need my functions every t

Re: [R] any alternatives for complex for-loops?

2008-11-12 Thread Kinoko
Gentlemen, Thank you for all your help. This list is really amazing. Following Erik's hint I have managed to find the answer: complexFn <- function(a,b){ c <- (a+b)/2 return(c) } x <- zoo(1:10) rollapply(x,width=2, function(xx) complexFn(xx[1],xx[2])) _

Re: [R] any alternatives for complex for-loops?

2008-11-12 Thread Kinoko
Dear Erik, Thank you very much. Probably it is exactly "zoo" what I have beenlooking for. Actually "rollapply" looks like something I could use, but... For some reasons beyond me, the following attempts in which I tried to apply my home-made 'fun' to rollaply miserable failed. complexFn <- funct

Re: [R] any alternatives for complex for-loops?

2008-11-11 Thread Kinoko
Thanks for the replies Sorry for being unclear. I am asking if there is a way to process a vector in a way that uses references to other elements of the same vector. And doing this without a for-loop. Here is a running code: complexFn <- function(a,b){ c <- (a+b)/2 return(c) } x <- 1:10 y

Re: [R] Citing R in journal articles (or the failure to)

2008-11-11 Thread Kinoko
Achim, thank you. My careless mistake. citation("tweedie") __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, se

[R] any alternatives for complex for-loops?

2008-11-11 Thread Kinoko
Dear list, Is there a way to do something like the following pseudo-code - without for loop? complexFn <- function(a,b){ ... return(c) } x[i] = complexFn(x[i-1], x[i-2]) I have found "filter" but would like to do something more complicated than multiplication with x[i-1] and x[i-2]. Thank

Re: [R] multiple "next" in for loops?

2008-11-11 Thread Kinoko
from the top of my head (ugly but works). jumps 5 if i==2 or i==8 j = 0 for(i in 1:15){ if((i==2)||(i==8)){ print(i) j=i+5 next } if (i>=j){ print(i) }else{ next } } __ R-help@r-project.org ma

Re: [R] Citing R in journal articles (or the failure to)

2008-11-11 Thread Kinoko
Just a few words... I usually cite softwares, especially if they are opensource (and encourage everyone to do so). Of course I would not append references for rkward or kile to my bib (neither word or excel). While the response of the researcher using your software is not convincing, you can easi