[R] density function cannot work well on UNIX R version 2.13.

2011-08-31 Thread alex46015
Hi, there, I found density function cannot work well on UNIX.R version 2.13.1 (2011-07-08), Platform: i386-pc-solaris2.10 (32-bit) Here is an example from R doucments which can work well on other version. plot(density(c(-20,rep(0,98),20)), xlim = c(-4,4))# But right now the estimated probab

[R] Can merge function pick up mismatch part of two data set?

2010-04-22 Thread alex46015
SAS can merge two data set A, B in different way, A or B, A and B, A not B, Can R merge function do the same way? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Can-merge-function-pick-up-mismatch-part-of-two-data-set-tp2021024p2021024.html Sent from the R help mailing

Re: [R] How to use "ifelse" to generate random value from a distribution

2010-03-17 Thread alex46015
Thanks for all you guys'  help above.   Actually my question is for Multivariate Normal   m1<-c(2.5,3.5,4.5) m2<-c(-3,-4,-5) m3<-c(100,120,130) n1<-length(data$x) sigma1<-matrix(c(1,0.3,0.4,0.3,1,0.2,0.4,0.2,1),nrow=3,byrow=T)   trait1<-ifelse(data$x==1,list(rmvnorm(n1,mean=m11,sigma=sigma1)

Re: [R] How to use "ifelse" to generate random value from a distribution

2010-03-17 Thread alex46015
I think I figure it out. ifelse(data1$x==1,rnorm(12,2,1),ifelse(data1$x==2,rnorm(12,-2,1),rnorm(12,110,1))) Please correct me if I am wrong. Thanks -- View this message in context: http://n4.nabble.com/How-to-use-ifelse-to-generate-random-value-from-a-distribution-tp1597064p1597102.html Se

[R] How to use "ifelse" to generate random value from a distribution

2010-03-17 Thread alex46015
I need use different parameters of distribution for different case to generate random value, but I use ifelse, the generated value is fixed without change. Here is example data1 y x 1 1 2 2 2 1 3 3 2 4 4 3 5 5 3 6 6 1 7 7 2 8 8 1 9 9 1 10 10 3 11 11 3 12 12 2 ifelse(data1$x

[R] for help on building a R package with several R function and a bunch of c, c++

2010-03-05 Thread alex46015
Hope I can get quick help from here, I have a bunch of c, c++ included main function and makefile. It works well on both UNIX and windows. I tried to build R package which include this C++ program and several other R functions. R function here are independent c++ code. I prefer to define one R