[R] construct a list that consists of lists

2010-03-11 Thread Zhongyi Yuan
Dear R users: I am hoping that someone can help with constructing a list that consists of list with the number of lists variable. i.e. to find a convenient express(or loop sentences) to realize the following: list( list(para1=p1, para2=p2), list(para1=p1, para2=p2), , list(para1=p1,para2=p2) )

Re: [R] construct a list that consists of lists

2010-03-12 Thread Zhongyi Yuan
[1] 5 6 7 8 9 [[5]] [[5]]$para1 [1] 1 2 3 4 5 [[5]]$para2 [1] 5 6 7 8 9 [[6]] [[6]]$para1 [1] 1 2 3 4 5 [[6]]$para2 [1] 5 6 7 8 9 On Fri, Mar 12, 2010 at 3:06 AM, Jim Lemon wrote: > On 03/12/2010 05:13 PM, Zhongyi Yuan wrote: > >> Dear R users: >> >> I am hoping th

Re: [R] construct a list that consists of lists

2010-03-12 Thread Zhongyi Yuan
ing replicate: > > replicate(6, list(para1 = 1:5, para2 = 5:9), simplify = FALSE) > > On Fri, Mar 12, 2010 at 2:51 PM, Zhongyi Yuan > wrote: > > Hi Jim, > > > > Dennis Murphy solved my problem by the following code. > > Thank you for you suggestion. Will check out

[R] labels gone

2010-03-15 Thread Zhongyi Yuan
Dear R users: I am drawing a graph with the following code: Tau<-seq(0.05,0.95,0.05); Pi <- seq(0.19,0.01,-0.01); par(cex.axis=0.8,ps=9,mar=c(1.5,1,0.5,1), oma=c(1,1,0.2,1) ,tck=-0.01); plot(Tau,Pi, type='l', xlab="Tau",ylab="Pi",col=4); I want to make the graph take as little space as possible.

Re: [R] labels gone

2010-03-16 Thread Zhongyi Yuan
t="n", yaxt="n"); > axis(1,labels=F) > axis(1,line=-1, lwd=0) > axis(2,labels=F) > axis(2,line=-0.5, lwd=0) > mtext("x_txt",side=1, line=0.5) > mtext("y_txt",side=2, line=1.2) > > cheers > > milton > On Tue, Mar 16, 2010 at 12

[R] format

2010-01-30 Thread Zhongyi Yuan
Hi, Could anybody please help me with this? In the following function, I try to return a good format of x, i.e. if my x[1] is 800, I don't want it to give me 800.0. I tried format(x, trim = TRUE), but didn't work. If my x has only first three components, which are all integers, I don't run into th

[R] append something to an xls file

2010-02-09 Thread Zhongyi Yuan
Hi everyone, I run into this problem and hope somebody can help. Thank you in advance. I have an excel file with the first column being a list of names. What I want is to add values that I compute for each person to the right of the corresponding names. Can someone help me with this? Thanks. Bes

[R] sample exponential r.v. by MCMC

2010-09-29 Thread Zhongyi Yuan
Dear R users, I am leaning MCMC sampling, and have a problem while trying to sample exponential r.v.'s via the following code: samp <- MCMCmetrop1R(dexp, theta.init=1, rate=2, mcmc=5000, burnin=500, thin=10, verbose=500, logfun=FALSE) I tried o

Re: [R] sample exponential r.v. by MCMC

2010-09-29 Thread Zhongyi Yuan
nt to cc the > package maintainer in case this happens to be a bug: > > maintainer('MCMCpack') > [1] "Andrew D. Martin " > > I don't know enough about the package to help you, but providing this > information to the list will increase the probability of a s

[R] roundoff error in recursion

2011-06-19 Thread Zhongyi Yuan
Dear R users, I run into the following problem and hope someone can help me out. Thank you in advance for your time. I have a function defined recursively as follows: recFun = function(k,x){ #i is less than 10. x can be any real number. I need the value of recFun(k=1,2,3,4, x=0.12). if(k==1) i

[R] color of math annotation in legend

2011-07-28 Thread Zhongyi Yuan
ion(paste(alpha," = ", 1)), expression(paste(alpha," = ", 2))),col=c('black','red')) Is it possible to make it red? Thanks in advance for your help. Best, Zhongyi Yuan [[alternative HTML version deleted]] _

Re: [R] color of math annotation in legend

2011-07-28 Thread Zhongyi Yuan
me a black "alpha = 2". > > > > x=y=1:100 > > z=seq(0.5,50,by=0.5) > > plot(x,y,type='l',col='black') > > lines(x,z,col='red') > > legend('topleft',c(expression(paste(alpha," = ", 1)), > > expression(pa

[R] Remove rows that have repeated items in a particular column

2012-07-25 Thread Zhongyi Yuan
hat is, the first column is numerically grouped and only the first item in each group is wanted. The second column is in increasing order within each group. My actual data will be of size 10^6 by 100 so I am hoping to solve this by a simple function. Thank you very much for your help. Best, Zhongy

Re: [R] Remove rows that have repeated items in a particular column

2012-07-25 Thread Zhongyi Yuan
Worked like a charm. Thanks. Zhongyi On Wed, Jul 25, 2012 at 11:58 PM, MK wrote: > Very simple > > mat[!duplicated(mat[, 1]), ] > > M [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/lis