Re: [R] generate variable y to produce excess zero in ZIP analysis

2013-02-21 Thread Jagat.K.Sheth
Also something like ## generate zero-inflated Poisson data n - 100 x1 - rnorm(n) x2 - rnorm(n) ind - rbinom(n,1,1/(1+exp(-1-0.1*x1))) y - ifelse(ind,rpois(n,lambda=exp(1+0.2*x2)),0) There is at least zeroinfl in the CRAN package pscl and fmr in Lindsey's non-CRAN package gnlm for fitting

Re: [R] Generating sequences of dates

2012-11-30 Thread Jagat.K.Sheth
?seq.Date seq(as.Date(2000-01-01), len=5, by=1 mon) [1] 2000-01-01 2000-02-01 2000-03-01 2000-04-01 2000-05-01 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Vasilchenko Aleksander Sent: Friday, November 30, 2012 6:27 AM

Re: [R] Can R be embedded in html?

2012-11-29 Thread Jagat.K.Sheth
Try R package 'brew'? From its package description Description:brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server

Re: [R] write out list of lists with names

2012-11-28 Thread Jagat.K.Sheth
Here is one way using capture.output and regular expressions cc - capture.output(ll) ## ll is your list object kk - cc[cc!= ] ## remove blank lines kk - gsub(\\$, , kk) ## remove '$' from names writeLines(kk) MU10 MU.16 MU.19 MU.21 meansd 0.8052791 0.4350489

Re: [R] R strange behaviour when building huge concatenation

2012-11-28 Thread Jagat.K.Sheth
to work just fine. I have no idea what is happening unless jagat.k.sheth is correct and we are hitting a buffer limit of some kind. I'd suggest getting a decent editor and going with it. Working directly in an R terminal is enough to drive most people crazy. Any of the editiors

Re: [R] Conditional model in R

2012-11-28 Thread Jagat.K.Sheth
Sounds like a finite mixture model. I haven't read your references but an overall model for such an approach could be f(Y=0; pi, kappa) = 1- pi + pi*f(Y=0|Z=1; kappa) where pi=Pr(Z=1) is the probability of an event, z, and y is the value observed when the event occurs and f is the probability

Re: [R] R strange behaviour when building huge concatenation

2012-11-27 Thread Jagat.K.Sheth
You probably hit a buffer limit in X11/xterm on your ubuntu machine with copy and paste. I get that behavior with Putty using your vector or when pasting (long) commands into Putty. If you really prefer copy and paste for this vector then try something like eval(parse(text=scan(clipboard,

Re: [R] how to create duplicated ID in multi-records per subject dataset

2008-12-15 Thread Jagat.K.Sheth
You can also try ?rep and something like dat - read.table(textConnection(ID record 120 . 30 . 25 2 26 . 15 3 21 ),header=TRUE,na.strings=.) ind - !is.na(dat$ID) id - dat$ID[ind] reps - diff(c(seq_len(nrow(dat))[ind],nrow(dat)+1)) dat$new.id -

Re: [R] loop with dates

2008-12-12 Thread Jagat.K.Sheth
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Fernando Bizuet Sent: Friday, December 12, 2008 12:55 PM To: r-help@r-project.org Subject: [R] loop with dates Hello, I am trying to do a loop with dates, but when I try

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Jagat.K.Sheth
This is almost a macro problem. It could be done in SAS language using the WPS product (660 USD) I think. ... OUCH! Why do it the complicated way??? Check out ?dir, ?list.files, and then ?lapply for a simple start. Don't give up so soon! When it comes to R there is no need to punt - you can

Re: [R] Writing a list help

2008-12-04 Thread Jagat.K.Sheth
You can get all the rownames by calling write.table once on something like # if all list elements have equal length t(data.frame(MyList)) # otherwise, let NA extend where needed t(do.call(cbind, lapply(MyList, ts))) You can take care of NAs as needed on your end. HTH -Original

Re: [R] Error: subscript out of bounds

2008-12-01 Thread Jagat.K.Sheth
Note that length(m) = 16, but your m is only 4x4. Try this m[is.na(m)] - 0 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alex99 Sent: Monday, December 01, 2008 9:06 AM To: r-help@r-project.org Subject: [R] Error: subscript out of bounds Hi All, I

Re: [R] Parameters of exponential power density

2008-12-01 Thread Jagat.K.Sheth
Maybe you can try one of Jim Lindsey's libraries available at http://popgen.unimaas.nl/~jlindsey/rcode.html If I recall, there is a function 'elliptic' in his 'growth' package that may help you. Otherwise, you can use one of R's nonlinear optimization functions, e.g. 'nlm', 'optim', etc.

Re: [R] How to split DF into a list and avoid NULL elements in this list

2008-11-25 Thread Jagat.K.Sheth
Here's one way x - sapply(seq(1,ncol(DF),by=2), function(i) DF[,i:(i+1)], simplify=F) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lauri Nikkinen Sent: Tuesday, November 25, 2008 9:00 AM To: [EMAIL PROTECTED] Subject: [R] How to split DF into a list

Re: [R] optimization problem

2008-11-24 Thread Jagat.K.Sheth
On the help page for nlm (type ?nlm) check out the 'See Also' section. It mentions other functions such as 'optim' and 'nlminb' which can do constrained optimizations. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiang Peng Sent: Monday, November 24,

Re: [R] Calculating sum of letter values

2008-11-24 Thread Jagat.K.Sheth
You can use Mark's code by giving levels to the factor, e.g. as.numeric(factor(unlist(strsplit(ABCDAXYZ, )), levels=LETTERS)) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, November 24, 2008 9:15 AM To: [EMAIL

Re: [R] matching matrix columns to a vector

2008-11-24 Thread Jagat.K.Sheth
How about which(colSums(t-v) == 0) ? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Salas, Andria Kay Sent: Monday, November 24, 2008 10:04 AM To: r-help@r-project.org Subject: [R] matching matrix columns to a vector I need help with (hopefully) just

Re: [R] matching matrix columns to a vector

2008-11-24 Thread Jagat.K.Sheth
Yes! my oversight ... thank you -Original Message- From: David Winsemius [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2008 11:48 AM To: Sheth, Jagat K Cc: [EMAIL PROTECTED]; r-help@r-project.org Subject: Re: [R] matching matrix columns to a vector Since negative values could

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-23 Thread Jagat.K.Sheth
bEST is up to you to define. Here is one simple way y.new - c(t(model.matrix(~factor(y)-1))) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zerfetzen Sent: Saturday, November 22, 2008 12:00 PM To: r-help@r-project.org Subject: [R] What's the BEST way

Re: [R] write every element of a variable into a separate text-file

2008-11-21 Thread Jagat.K.Sheth
Your code isn't changing the filename Try this for(i in seq_along(wull)) write(wull[i], paste(C://Users//zuber//Documents//wull(,i,),.txt,sep=)) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, November 21, 2008 7:39 AM

Re: [R] Breakdown of Vector

2008-11-21 Thread Jagat.K.Sheth
No need to use a for loop. Try something like this dim(EXAM1) - c(20,7420/20) test.breakdown.list - as.list(data.frame(EXAM1)) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rajasekaramya Sent: Friday, November 21, 2008 9:48 AM To:

Re: [R] list of list objects

2008-11-21 Thread Jagat.K.Sheth
?unlist -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rajasekaramya Sent: Friday, November 21, 2008 2:14 PM To: r-help@r-project.org Subject: [R] list of list objects hi there, I have a list of list objects i need to remove the top layer [[1]]

Re: [R] list of list objects

2008-11-21 Thread Jagat.K.Sheth
?unlist -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rajasekaramya Sent: Friday, November 21, 2008 2:14 PM To: r-help@r-project.org Subject: [R] list of list objects hi there, I have a list of list objects i need to remove the top layer [[1]]