Re: [R] How to multiply all dataframe rows by another dataframe's columns

2007-08-29 Thread Anders Nielsen
matrix(Y[,2]%o%X[,2],ncol=1) On Wednesday 29 August 2007 03:21 pm, Luke Neraas wrote: > Hello, > > I have two data frames, X and Y, with two columns each and different numbers > of rows. > > # creation of data frame X > > Loc1.alleles <- c(1,5,6,7,8) > Loc1.Freq<- c(0.35, 0.15,

Re: [R] Looking for a cleaner way to implement a setting certain indices of a matrix to 1 function

2007-05-08 Thread Anders Nielsen
Hi Mark, Is this of any help? resMat<-function(K=6,lag=2,ncol=3*K){ X<-matrix(0,K,ncol) X[,1:(K*lag)]<-diag(K) return(X) } Cheers, Anders. On Tuesday 08 May 2007 11:21 am, Leeds, Mark (IED) wrote: > I wrote an ugly algorithm to set certain elements of a matrix to 1 > withou

Re: [R] is there a way to let R do smart matrix-vector operation?

2006-03-06 Thread Anders Nielsen
Hi Michael, Try: A-as.vector(B) Cheers, Anders. On Monday 06 March 2006 01:10 pm, Michael wrote: > Hi all, > > I want to substract vector B from A's each column... how can R do > that smartly without a loop? > > > A=matrix(c(2:7), 2, 3) > > A > > [,1] [,2] [,3] > [1,]246

Re: [R] Automatic differentiation (was: Re: D(dnorm...)?)

2006-01-26 Thread Anders Nielsen
I can confirm that AD Model Builder is used at the Danish Institute for Fisheries Research, and by fisheries people in and all around the Pacific. On a few occasions I have solved a likelihood optimization problem in AD Model Builder, and then wrapped the binary in an R-package, with data read

Re: [R] GLMs: Negative Binomial family in R?

2005-04-05 Thread Anders Nielsen
Hi, Also consider using the function supplied in the post: https://stat.ethz.ch/pipermail/r-help/2005-March/066752.html for fitting negative binomial mixed effects models. Cheers, Anders. On Tue, 5 Apr 2005, Achim Zeileis wrote: > On Tue, 5 Apr 2005 11:20:37 -0600 [EMAIL PROTECTED] wrote:

Re: [R] Negative binomial GLMMs in R

2005-03-27 Thread Anders Nielsen
Dear List, I have tried the program (Linux version) supplied to fit the negative binomial mixed model. It seems to work really well and converge fast. Since this is apparently a model that is difficult to fit with what is presently in R, and more difficult to fit with other standard tools, it wo

Re: [R] pasting results into Word/Excel

2004-04-11 Thread Anders Nielsen
Hi Graham, If you want it in excel I suggest you export it as a comma separated file, which can be done with something like: > data(airquality) > write.table(airquality, sep=",", row.names=FALSE, quote=FALSE, file="result.csv") This file will open nicely in excel. If you want it as tab separate

Re: [R] R: lags

2004-02-10 Thread Anders Nielsen
How about: y<-cumsum(c(0,rnorm(100))) On Tue, 10 Feb 2004, allan clark wrote: > hi all > > how does one simulate a random walk process? > > i.e > > y(0)=0 > > y(t)=y(t-1)+ e(t) > > where e(t) is normal(0,1) say. > > Regards > allan > __ [EMAIL PRO

Re: [R] runif and sample with reproducibility

2004-01-05 Thread Anders Nielsen
Hi Eric, How about: > set.seed(1234567) > sample(1:100,10) [1] 57 72 90 3 74 46 9 81 95 78 > set.seed(1234567) > sample(1:100,10) [1] 57 72 90 3 74 46 9 81 95 78 > Cheers, Anders. On Mon, 5 Jan 2004, Eric ESPOSITO wrote: > Hello, > I already sent such an email before Christmas, but nob

Re: [R] code efficiency, extr. info from list

2003-10-21 Thread Anders Nielsen
Try using lapply() For instance like: val<-unlist(lapply(test, function(x)x$value)) You can also extend this by having your function return everything you need from the list. Cheers, Anders. On Tue, 21 Oct 2003, Tord Snall wrote: > Dear all, > I try extracting information from a list with

Re: [R] Place a graphic into an R-plot

2003-09-18 Thread Anders Nielsen
Hi, You need to install the pixmap package to do that. After that is installed the following lines illustrate how to use it. > library(pixmap) > x <- read.pnm(system.file("pictures/logo.ppm", package = "pixmap")[1]) > layout(matrix(c(1,1,2,3),2,2)) > plot(rnorm(100)) > plot(rnorm(100)) > plot(