[R] Is there any function can perform "outer lapply" ?

2010-12-06 Thread Julian TszKin Chan
I built my own "outer lapply " as attached code. Is there any R build-in function can do the same jobs ? Thanks oapply<-function(X,Y,FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE){ x=rep(X,each=length(X)) y=rep(Y,times=length(Y)) mapply(FUN,x,y, MoreArgs =

[R] How can i select a set of element in a list ?

2010-12-08 Thread Julian TszKin Chan
How can i select a set of element in a list ? x<-list(1,2,3,4,5) How can I create a new list which only have the last 4 elements of x. I can do it with a loop, but I want to avoid that. Thanks! example : y<-vector("list",4) for ( i in 1:length(y) ) y[[i]] <- x[[ i + length(x) - length(y) ]]

[R] Resource for learning C/R interface

2010-12-18 Thread Julian TszKin Chan
Hi all, Is there any tutorial for learning C/R interface ? Thanks Regards, Julian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://w

[R] Question about ggplot2

2011-05-26 Thread Julian TszKin Chan
Hi all, Is there any way for me to to string in the argument of qplot or ggplot? for example qplot(x='carat',y='price',data=diamonds,geom=c('point','smooth')) instead of qplot(x=carat,y=price,data=diamonds,geom=c('point','smooth')) Thanks!! Regards, TszKin Julian [[alternative HTML ve

[R] Question about foreach (with doSNOW), is that a bug?

2011-02-24 Thread Julian TszKin Chan
Hi all, Within a foreach loop with doSNOW, we cant call functions which come from the non-default package. We need to load(require/library) the package once more within the foreach loop. Anyone knows why would happen like this? Is it caused by the snow package and something happened when "snow" pa

[R] txtProgressBar and parallelized foreach

2011-06-14 Thread Julian TszKin Chan
Hi all, I can create a text-progress bar in a foreach loop by the following code : n=10 foreach( i = 1:n ,.combine=c) %do%{ setTxtProgressBar(pb, i) Sys.sleep(0.1) } However, once i use the parallelized foreach, the text-progress bar disappear. Any solution to this problem? How

[R] transforming a matrix of logical to 0 and 1 while keeping the dim of matrix

2011-07-20 Thread Julian TszKin Chan
Hi all, Suppose I have a matrix of logical value: x<-matrix(c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE),nrow=3) I would like to change the value of FALSE to 0 and TRUE to 1. An obvious way to do it is : y<-as.numeric(x) However this method doesn't keep the dim of x. I also need to copy

[R] is there any IV probit estimator in R?

2009-02-23 Thread Julian TszKin Chan
Hi Is there any package in R that allow me to do IV probit, just like the ivprobit command in stata. or do i have to carry out the newey's two-step estimator myself? Regards, Julian [[alternative HTML version deleted]] __ R-help@r-project.or