[R] FW: multivariate regression

2011-02-06 Thread Deniz SIGIRLI
#I have got 3 dependent variables: Y<-matrix(c(3,5,6,3,4,2,4,5,3,2,3,5,6,3,4,2,4,5,3,2,3,5,6,3,4,2,4,5,3,2), nrow = 10, ncol=3, byrow=TRUE) #I've got one independent variable: X<-matrix(c(42,54,67,76,45,76,54,87,34,65), nrow = 10, ncol=1, byrow=TRUE) summary(lm(Y~X)) and the result is as bel

Re: [R] Subsampling out of site*abundance matrix

2011-02-06 Thread B77S
hehe... very true sir; I apologize, that was very straightforward. Thank you for your time. -- View this message in context: http://r.789695.n4.nabble.com/Subsampling-out-of-site-abundance-matrix-tp3263148p3263598.html Sent from the R help mailing list archive at Nabble.com. ___

[R] lattice: Synchronizing key and lines; or: why is lty used as lwd in legend?

2011-02-06 Thread Dieter Menne
Dear latticists, Getting legend and graph line types synchronized has been a challenge in lattice; the last example below that works looks ridiculously ugly for such a simple job, I am sure there is a more elegant solution. When trying this out, I found a feature which I found confusing: why are

[R] Image to plot

2011-02-06 Thread Alaios
Dear all I would like to plot the contents of a matrix as an Image. I found this code here http://www.phaget4.org/R/image_matrix.html but this is not only what I want. Instead of having inside every cell the color of the cell it would be nice to have also the arithmetic value over the background

Re: [R] Fortran and long integers

2011-02-06 Thread Tsjerk Wassenaar
Yes, thnx... Typo :$ On Mon, Feb 7, 2011 at 8:23 AM, Berend Hasselman wrote: > > > Tsjerk Wassenaar wrote: >> >> Hi, >> >> Does it alleviate things if you rewrite the sums to avoid large products? >> >> For I even: >> J+I*(N-I/2)-(N-I/2) >> > > Shouldn't that be > > J+I*(N-I/2)-(N+I/2)  ? > > Ber

Re: [R] Fortran and long integers

2011-02-06 Thread Berend Hasselman
Tsjerk Wassenaar wrote: > > Hi, > > Does it alleviate things if you rewrite the sums to avoid large products? > > For I even: > J+I*(N-I/2)-(N-I/2) > Shouldn't that be J+I*(N-I/2)-(N+I/2) ? Berend -- View this message in context: http://r.789695.n4.nabble.com/Fortran-and-long-integers-

Re: [R] Fortran and long integers

2011-02-06 Thread Tsjerk Wassenaar
Hi, Does it alleviate things if you rewrite the sums to avoid large products? For I even: J+I*(N-I/2)-(N-I/2) For I odd: J+I*(N-(I+1)/2)-(N-(I+1)/2)+(I+1)/2 Hope it helps, Tsjerk On Mon, Feb 7, 2011 at 7:21 AM, Berend Hasselman wrote: > > > Earl F Glynn wrote: >> >> >> 2-byte (16 bit) signe

Re: [R] Fortran and long integers

2011-02-06 Thread Berend Hasselman
Earl F Glynn wrote: > > > 2-byte (16 bit) signed integers would have a range from -32768 to > +37267. So, it looks like you may be using 2-byte integers and 46,300 > would definitely cause an overflow with 16-bit integers. > > I haven't used Fortran for a long time, but there could be a com

[R] Giving vector of colors to line in plots

2011-02-06 Thread statmobile
Hey all, I can't for the life of me figure out what I'm missing here. I'm trying to change the color of the line in a time series type plot. I can change the point colors and symbols no problem, but for some reason the colors do not get passed to the lines, regardless of if I do type="b" or

Re: [R] Fortran and long integers

2011-02-06 Thread Earl F Glynn
Peter Langfelder wrote: Hi all, I'm hoping someone more knowledgeable in Fortran than I can chime in with opinion. I'm the maintainer of the flashClust package that implements fast hierarchical clustering. The fortran code fails when the number of clustered objects is larger than about 46300.

Re: [R] Subsampling out of site*abundance matrix

2011-02-06 Thread David Winsemius
On Feb 6, 2011, at 9:35 PM, B77S wrote: I figured there would be an even more straightforward way, but that works David, thanks. I am rather puzzled. What prior experience with computing would lead you to believe that one line of code was not a straightforward method to do multinomial

Re: [R] delete rows

2011-02-06 Thread Bert Gunter
On Sun, Feb 6, 2011 at 6:16 PM, Christopher Porter wrote: > Hello. I came across your response in an R forum and could use your help. I > have a data set with 472 rows. I want to delete rows 416 through 472. The > name of my data set is MERGE. > > I am an extreme R novice. How do I write a script

Re: [R] delete rows

2011-02-06 Thread Santosh Srinivas
?subset On Mon, Feb 7, 2011 at 7:46 AM, Christopher Porter wrote: > Hello. I came across your response in an R forum and could use your help. I > have a data set with 472 rows. I want to delete rows 416 through 472. The > name of my data set is MERGE. > > I am an extreme R novice. How do I writ

Re: [R] delete rows

2011-02-06 Thread Joshua Wiley
Hi, On Sun, Feb 6, 2011 at 6:16 PM, Christopher Porter wrote: > Hello. I came across your response in an R forum and could use your help. I > have a data set with 472 rows. I want to delete rows 416 through 472. The > name of my data set is MERGE. Try this: MERGE2 <- MERGE[-c(416:472), ] Che

Re: [R] Subsampling out of site*abundance matrix

2011-02-06 Thread B77S
I figured there would be an even more straightforward way, but that works David, thanks. There has to be a way to get the output I want/need (see below). I tried to bind or merge the elements of "apply(samptbl, 2, table)" but with no success. I could probably make a for loop with a merge stat

[R] delete rows

2011-02-06 Thread Christopher Porter
Hello. I came across your response in an R forum and could use your help. I have a data set with 472 rows. I want to delete rows 416 through 472. The name of my data set is MERGE. I am an extreme R novice. How do I write a script to accomplish this? Thank you. --- Christopher H. Porter, M.A

Re: [R] Finding non-normal distributions per row of data frame?

2011-02-06 Thread DB1984
Hugo - thanks for the link, but that's a bit beyond me right now. I have ideas of the distribution for some 'nuggets', but others might be new. I hope that there's an easier way to pick them out than going after pre-defined patterns... Greg - I use bioconductor for a lot of processing, but I'm no

Re: [R] questions about counting numbers

2011-02-06 Thread jim holtman
?ave > a [1] 2 3 3 4 > cbind(a, ave(a, a, FUN=length)) a [1,] 2 1 [2,] 3 2 [3,] 3 2 [4,] 4 1 > On Sun, Feb 6, 2011 at 8:21 PM, Carrie Li wrote: > Hello R-helpers, > > I have a question about counting numbers. > Here is a simple example. > > a=c(2, 3, 3,4) >> table(a) > a > 2 3 4 > 1 2 1 >

Re: [R] questions about counting numbers

2011-02-06 Thread Carrie Li
Many thanks! all methods work well! thanks again! On Sun, Feb 6, 2011 at 8:42 PM, Ray Brownrigg wrote: > It's not quite clear what the OP really wanted. A more general solution > may be: > > > a=c(4, 3, 2, 3) > > ta <- table(a) > > ta > a > 2 3 4 > 1 2 1 > > ta[as.character(a)] > a > 4 3 2 3 > 1

Re: [R] aggregate function - na.action

2011-02-06 Thread David Winsemius
On Feb 6, 2011, at 7:41 PM, Hadley Wickham wrote: There's definitely something amiss with aggregate() here since similar functions from other packages can reproduce your 'control' sum. I expect ddply() will have some timing issues because of all the subgrouping in your data frame, but data

Re: [R] questions about counting numbers

2011-02-06 Thread Ray Brownrigg
It's not quite clear what the OP really wanted. A more general solution may be: > a=c(4, 3, 2, 3) > ta <- table(a) > ta a 2 3 4 1 2 1 > ta[as.character(a)] a 4 3 2 3 1 2 1 2 > HTH Ray Brownrigg On Mon, 07 Feb 2011, Jorge Ivan Velez wrote: > Hi

Re: [R] questions about counting numbers

2011-02-06 Thread Jorge Ivan Velez
Hi Carrie, Try > x <- rle(a) > rep(x$lengths, x$lengths) [1] 1 2 2 1 HTH, Jorge On Sun, Feb 6, 2011 at 8:21 PM, Carrie Li <> wrote: > Hello R-helpers, > > I have a question about counting numbers. > Here is a simple example. > > a=c(2, 3, 3,4) > > table(a) > a > 2 3 4 > 1 2 1 > > so, I can to

[R] questions about counting numbers

2011-02-06 Thread Carrie Li
Hello R-helpers, I have a question about counting numbers. Here is a simple example. a=c(2, 3, 3,4) > table(a) a 2 3 4 1 2 1 so, I can to create another variables that has the corresponding counting numbers. In this case, I want to have: b=c(1,2,2,1) Is there any way coding for this ? Thanks

Re: [R] aggregate function - na.action

2011-02-06 Thread Hadley Wickham
> There's definitely something amiss with aggregate() here since similar > functions from other packages can reproduce your 'control' sum. I expect > ddply() will have some timing issues because of all the subgrouping in your > data frame, but data.table did very well and the summaryBy() function i

Re: [R] aggregate function - na.action

2011-02-06 Thread Dennis Murphy
Hi: There's definitely something amiss with aggregate() here since similar functions from other packages can reproduce your 'control' sum. I expect ddply() will have some timing issues because of all the subgrouping in your data frame, but data.table did very well and the summaryBy() function in t

Re: [R] Legend outside the plot? xpd?

2011-02-06 Thread Jim Holtman
you can use layout to setup 4 plot areas; 3 for the graphs and then along one on the right for the legend Sent from my iPad On Feb 6, 2011, at 2:41, Matt Cooper wrote: > Hi All, > > BG: Will try be brief. I'd like 3 graphs on a page (below each other > mfrow=c(3,1)), saved to pdf. The three p

Re: [R] Applying 'cbind/rbind' among different list object

2011-02-06 Thread Phil Spector
Another possibility is mapply(rbind,list1,list2,SIMPLIFY=FALSE) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Fund style categorizing

2011-02-06 Thread Jim Holtman
?aggregate ?tapply data.table package example data and output would have been useful Sent from my iPad On Feb 6, 2011, at 15:02, Ning Cheng wrote: > I've got a fund performance report for the last year,in which one > column states their management style,i.e. long/short,market neutral. I > want

Re: [R] Subsampling out of site*abundance matrix

2011-02-06 Thread David Winsemius
On Feb 6, 2011, at 3:25 PM, B77S wrote: Hello, How can I randomly sample individuals within a sites from a site (row) X species abundance (column) data frame or matrix? As an example, the matrix "abund2" made below. # (sorry, Im a newbie and this is the only way I know to get an e

Re: [R] aggregate function - na.action

2011-02-06 Thread jim holtman
Try 'data.table' package. It took 3 seconds to aggregate the 500K levels: Is this what you were after? > # note the characters are converted to factors that 'data.table' likes > dat=data.frame( +x1=sample(c(NA,'m','f'), 2e6, replace=TRUE), +x2=sample(c(NA, 1:10), 2e6, replace=TRU

Re: [R] function optimization

2011-02-06 Thread Ben Bolker
garciap usal.es> writes: > this is my first time, and just begin to use R. But I've a question about > optimization using optimx library. It could sound stupid by I'm a bit > affraid with the problem, because anything I try, anything Error. > The procedure was: > optimx(par="10,71,1",fn=(Prey*P

[R] function optimization

2011-02-06 Thread garciap
Dear all, this is my first time, and just begin to use R. But I've a question about optimization using optimx library. It could sound stupid by I'm a bit affraid with the problem, because anything I try, anything Error. The procedure was: optimx(par="10,71,1",fn=(Prey*Provisioning)/Risk, control

Re: [R] aggregate function - na.action

2011-02-06 Thread Gene Leynes
By the way, thanks for sending that formula, it's quite thoughtful of you to send an answer with an actual working line of code! When I experimented with ddply earlier last week I couldn't figure out the syntax for a single line aggregation, so it's good to have this example. I will likely use it

[R] Fund style categorizing

2011-02-06 Thread Ning Cheng
I've got a fund performance report for the last year,in which one column states their management style,i.e. long/short,market neutral. I want to categorize all the fund into subgroups by their management style.How can I do that? __ R-help@r-project.org m

[R] Subsampling out of site*abundance matrix

2011-02-06 Thread B77S
Hello, How can I randomly sample individuals within a sites from a site (row) X species abundance (column) data frame or matrix? As an example, the matrix "abund2" made below. # (sorry, Im a newbie and this is the only way I know to get an example on here) abund1 <-c(150, 300, 0, 36

Re: [R] aggregate function - na.action

2011-02-06 Thread Denis Kazakiewicz
Try to use formula notation and use na.action=na.pass It is all described in the help(aggregate) У Няд, 06/02/2011 у 14:54 -0600, Gene Leynes піша: > On Fri, Feb 4, 2011 at 6:54 PM, Ista Zahn wrote: > > > > > > > However, I don't think you've told us what you're actually trying to > > > accompl

Re: [R] very basic HLM question

2011-02-06 Thread Sebastián Daza
Thank you for your reply and sorry for my ambiguity. I computed: summary(anova1 <- aov(math ~ as.factor(schoolid), data=nels88)) ICC1(anova1) ICC1 comes from the multilevel package. I have found an article where it is pointed out that with this formula: > 34.011/(34.011+72.256) [1] 0.320052

Re: [R] aggregate function - na.action

2011-02-06 Thread Gene Leynes
On Fri, Feb 4, 2011 at 6:54 PM, Ista Zahn wrote: > > > > However, I don't think you've told us what you're actually trying to > > accomplish... > > > I'm trying to aggregate the y value of a big data set which has several x's and a y. I'm using an abstracted example for many reasons. Partially,

Re: [R] How to use a value of an aboject in a line command?

2011-02-06 Thread Petr Savicky
On Sun, Feb 06, 2011 at 04:31:43PM -0200, Leandro Colli wrote: > This is my first time here at R Forum! > > I am a new user of R. I am very happy with this fabulous software! > > I know how to use greps, fors, seeds, %in%, paste, etc. > > But I need to know how to use a value of an

Re: [R] Help with integrating R and c/c++

2011-02-06 Thread Ravi Varadhan
Hi Rohit, It is fine if you are using the Newton's method just as an excuse to learn Rcpp. If, however, your main goal is to develop a package to implement Newton's method, then you need to stop and look at the numerous optimization packages available in R. A good place to start would be the

[R] using character vector as input argument to setkey (data.table pakcage)

2011-02-06 Thread Sean Zhang
Dear R helpers, I wonder how to use a character vector as an input argument to setkey (data.table package). The following works: library(data.table) test.dt <- data.table(expand.grid(a=1:30,b=LETTERS),c=seq(30*26)) setkey(test.dt,a,b) I like a similar function, but can accept c('a','b') as an in

[R] Fortran and long integers

2011-02-06 Thread Peter Langfelder
Hi all, I'm hoping someone more knowledgeable in Fortran than I can chime in with opinion. I'm the maintainer of the flashClust package that implements fast hierarchical clustering. The fortran code fails when the number of clustered objects is larger than about 46300. My guess is that this is be

Re: [R] Applying 'cbind/rbind' among different list object

2011-02-06 Thread jim holtman
will this do it for you: > lapply(seq(length(list1)), function(i)rbind(list1[[i]], list2[[i]])) [[1]] [,1] [,2] [,3] [,4] [,5] [1,]16 11 16 21 [2,]27 12 17 22 [3,]38 13 18 23 [4,]49 14 19 24 [5,]5 10 15 20 25 [6,] 10 11

[R] Applying 'cbind/rbind' among different list object

2011-02-06 Thread B. Jonathan B. Jonathan
Hi, I am wondering whether we can apply 'cbind/rbind' on many **equivalent** list objects. For example please consider following: > list1 <- list2 <- vector("list", length=2); names(list1) <- names(list2) <- c("a", "b") > list1[[1]] <- matrix(1:25, 5) > list1[[2]] <- matrix(2:26, 5) > list2[[1]] <

[R] How to use a value of an aboject in a line command?

2011-02-06 Thread Leandro Colli
This is my first time here at R Forum! I am a new user of R. I am very happy with this fabulous software! I know how to use greps, fors, seeds, %in%, paste, etc. But I need to know how to use a value of an aboject in a line command? Example: > i [1] "TP53" > TP53 V1 V2 V3

Re: [R] Help with integrating R and c/c++

2011-02-06 Thread Dirk Eddelbuettel
On 6 February 2011 at 20:58, Rohit Pandey wrote: | Hi, | | I have been using R for close to two years now and have grown quite | comfortable with the language. I am presently trying to implement an | optimization routine in R (Newton Rhapson). I have some R functions that | calculate the gradient

Re: [R] Help with integrating R and c/c++

2011-02-06 Thread Martin Morgan
On 02/06/2011 07:28 AM, Rohit Pandey wrote: > Hi, > > I have been using R for close to two years now and have grown quite > comfortable with the language. I am presently trying to implement an > optimization routine in R (Newton Rhapson). I have some R functions that > calculate the gradient and h

Re: [R] Help with integrating R and c/c++

2011-02-06 Thread Douglas Bates
On Sun, Feb 6, 2011 at 10:56 AM, David Winsemius wrote: > > On Feb 6, 2011, at 10:28 AM, Rohit Pandey wrote: > >> Hi, >> >> I have been using R for close to two years now and have grown quite >> comfortable with the language. I am presently trying to implement an >> optimization routine in R (Newt

Re: [R] Help with integrating R and c/c++

2011-02-06 Thread David Winsemius
On Feb 6, 2011, at 10:28 AM, Rohit Pandey wrote: Hi, I have been using R for close to two years now and have grown quite comfortable with the language. I am presently trying to implement an optimization routine in R (Newton Rhapson). I have some R functions that calculate the gradient and h

Re: [R] random interaction effect in lmer

2011-02-06 Thread Jason Morgan
Hello Federico, You should try sending this to the mixed models mailing list (link below). Also, it would probably help to know what the data looks like. With the information you provide, it's hard to say what the problem could be. r-sig-mixed-mod...@r-project.org Best, ~Jason On 2011.02.06, Fe

[R] Help with integrating R and c/c++

2011-02-06 Thread Rohit Pandey
Hi, I have been using R for close to two years now and have grown quite comfortable with the language. I am presently trying to implement an optimization routine in R (Newton Rhapson). I have some R functions that calculate the gradient and hessian (pre requisite matrices) fairly efficiently. Now,

Re: [R] Multiplying elements of vectors

2011-02-06 Thread Mariana Martinez-Morales
Super Phil!! Thank you very much!! Mariana On Sat, Feb 5, 2011 at 8:54 PM, Phil Spector wrote: > If the seq(5,205) was a typo, and should have been > seq(5,20,5), then what you're looking for is the outer > product of x and y: > >> x = seq(5,20,5) >> y = seq(5,20,5) >> x %o% y > >     [,1] [,2]

[R] random interaction effect in lmer

2011-02-06 Thread Federico Bonofiglio
Hi dears while modeling an interaction random effect in lmer i receive the instantaneous error message > ldlM4<-lmer(ldl~rt*cd4+age+rf+pharmac+factor(hcv)+ + hivdur+(rt:cd4|id),na.action=na.omit,REML=F) *Warning message: In mer_finalize(ans) : false convergence (8) * I think the matter lies in syn

Re: [R] anova() interpretation and error message

2011-02-06 Thread Peter Ehlers
See comments inline. On 2011-02-06 03:17, Jinsong Zhao wrote: Hi there, I have a data frame as listed below: > Ca.P.Biomass.A P Biomass 1 334.5567 0.287 2 737.5400 0.571 3 894.5300 0.639 4 782.3800 0.5836667 5 857.5900 0.600 6 829.2700 0.588 I have fit the

Re: [R] manipulate dataframe

2011-02-06 Thread Victor F Seabra
another option is to use reshape() x<-data.frame(x1=rep(1:3,each=3),x2=letters[1:9]) x$id<-rep(1:3,3) dur<-reshape(x,timevar="x1",idvar="id",direction="wide") dur<-dur[,-1] colnames(dur) <- paste("d", unique(x$x1), sep="") dur cheers, Victor ___

Re: [R] Confidence interval based on MLE

2011-02-06 Thread Ben Bolker
Jinsong Zhao yeah.net> writes: > > Hi there, > > I have fitted a sample (with size 20) to a normal and/or logistic > distribution using fitdistr() in MASS or fitdist() in fitdistrplus > package. It's easy to get the parameter estimates. Now, I hope to report > the confidence interval for tho

Re: [R] manipulate dataframe

2011-02-06 Thread Patrick Hausmann
Hi André, try this: df1 <- data.frame(x1 = rep(1:3, each=3), x2=letters[1:9]) dfs <- split(df1, df1$x1) df2 <- data.frame(sapply(dfs, FUN="[[", "x2")) colnames(df2) <- paste("d", unique(df1$x1), sep="") df2 HTH Patrick Am 06.02.2011 12:13, schrieb André de Boer: Hello, Can someone give me

Re: [R] manipulate dataframe

2011-02-06 Thread jim holtman
Here is one way of doing it: > x x1 x2 row 1 1 a 1 2 1 b 2 3 1 c 3 4 2 d 1 5 2 e 2 6 2 f 3 7 3 g 1 8 3 h 2 9 3 i 3 > # create indices for new table > x$row <- ave(x$x1, x$x1, FUN=seq_along) > # create output matrix > result <- matrix('', max(x$row), max(x$x1))

Re: [R] boot() versus loop, and statistics option

2011-02-06 Thread Prof Brian Ripley
Package boot is support software for a book: have you consulted it? It answers all your questions, and has copious examples. On Sun, 6 Feb 2011, Sascha Vieweg wrote: Hello R users I am quite new to bootstrapping. Now, having some data x, R: set.seed(1234) R: x <- runif(300) I want to

[R] Confidence interval based on MLE

2011-02-06 Thread Jinsong Zhao
Hi there, I have fitted a sample (with size 20) to a normal and/or logistic distribution using fitdistr() in MASS or fitdist() in fitdistrplus package. It's easy to get the parameter estimates. Now, I hope to report the confidence interval for those parameter estimates. However, I don't find

[R] boot() versus loop, and statistics option

2011-02-06 Thread Sascha Vieweg
Hello R users I am quite new to bootstrapping. Now, having some data x, R: set.seed(1234) R: x <- runif(300) I want to bootstrap simple statistics, mean and quantiles (.025, .975). Currently, I run a loop R: res <- as.data.frame(matrix(ncol = 3, dimnames = list(NULL, ...c("M"

[R] anova() interpretation and error message

2011-02-06 Thread Jinsong Zhao
Hi there, I have a data frame as listed below: > Ca.P.Biomass.A P Biomass 1 334.5567 0.287 2 737.5400 0.571 3 894.5300 0.639 4 782.3800 0.5836667 5 857.5900 0.600 6 829.2700 0.588 I have fit the data using logistic, Michaelis–Menten, and linear model, they all gi

[R] manipulate dataframe

2011-02-06 Thread André de Boer
Hello, Can someone give me hint to change a data.frame. I want to split a column in more columns depending on the value of a other column. Thanks for the reaction, Andre Example: > dat x1 x2 1 1 a 2 1 b 3 1 c 4 2 d 5 2 e 6 2 f 7 3 g 8 3 h 9 3 i in > dur d1 d2 d3 1 a d g

Re: [R] Legend outside the plot? xpd?

2011-02-06 Thread Matt Cooper
On Sun, Feb 6, 2011 at 3:56 PM, David Winsemius wrote: > > Why not just use xpd=T inside legend()? > > > David Winsemius, MD > West Hartford, CT > > I had a feeling I'd look stupid after sending that. Thanks, works great. For some reason I thought if xpd would have to be set to T at the par() leve

Re: [R] Legend outside the plot? xpd?

2011-02-06 Thread David Winsemius
On Feb 6, 2011, at 2:41 AM, Matt Cooper wrote: Hi All, BG: Will try be brief. I'd like 3 graphs on a page (below each other mfrow=c(3,1)), saved to pdf. The three plot data on the same subject so I'm having one legend, to the right of the center graph. I'm using mar=c(5,15,4,15) to bring th

Re: [R] different results in MASS's mca and SAS's corresp

2011-02-06 Thread Mark Difford
>> When I came to David's comment, I understood the theory, but not the >> numbers in his answer. I wanted to see the MASS mca answers "match >> up" with SAS, and the example did not (yet). I am inclined to write, "O yea of little faith." David showed perfectly well that when the results of th