Re: [R] foreach: how to create array (of lists) as result?

2011-05-19 Thread mhofert
okay, I should have remembered... Gabor suggested a pretty nice solution, see: http://r.789695.n4.nabble.com/How-to-create-an-array-of-lists-of-multiple-components-td3167576.html -- View this message in context: http://r.789695.n4.nabble.com/foreach-how-to-create-array-of-lists-as-result-tp35353

Re: [R] identical function names from 2 packages

2011-05-19 Thread Jari Oksanen
Duncan Murdoch gmail.com> writes: > > On 18/05/2011 10:02 PM, Nick Matzke wrote: > > Hi, > > > > If I load 2 packages that have a function with the same > > name, how do I tell R to run one or the other? > > > > If you are using a package without a namespace, expect problems. Having > the na

Re: [R] R-help Digest, Vol 99, Issue 17

2011-05-19 Thread Vikas Garud
> -- > > Message: 15 > Date: Tue, 17 May 2011 13:03:57 +0100 > From: Timothy Bates > To: R list > Subject: Re: [R] Box Plot under GUI (R Commander/RKward) > Message-ID: <9ca34005-9076-439f-aec2-1931e1472...@gmail.com> > Content-Type: text/plain; charset=windows-1252 >

Re: [R] How to do covariate adjustment in R

2011-05-19 Thread karena
Thank you so much for this reply, Peter. It helps. I know this is one way to adjust for covariates. However, if what I want is to get the 'remaining values' after adjustment. For example, say, 'gene expression' value is denoted as 'ge', and for each gene, ge=a*age+b*sex+c*per_se My question is:

[R] Which package to use when fit Mixture regression model with ......................

2011-05-19 Thread cori.shen
I'm pretty new in R... try to learn ASAP for a project, I wonder if anyone can provide some advice on which package to use when fit Mixture regression model with both categorical(more than two levels) and continuous variables. I tried to use Flexmix... and transposed the multi-level variables as s

Re: [R] How to do covariate adjustment in R

2011-05-19 Thread Peter Langfelder
On Thu, May 19, 2011 at 7:21 PM, karena wrote: > Hi, I have a question about how to do covariate adjustment. > > I have two sets of 'gene expression' data. They are from two different > tissue types, 'liver' and 'brain', respectively. > The purpose of my analysis is to compare the pattern of the w

Re: [R] Adding a numeric to all values in the dataframe

2011-05-19 Thread Bill.Venables
For that kind of operation (unusual as it is) work with numeric matrices. When you are finished, if you still want a data frame, make it then, not before. If your data starts off as data frame to begin with, turn it into a matrix first. E.g. myMatrix <- data.frame(myData) myMatrix2 <- myMatr

Re: [R] Adding a numeric to all values in the dataframe

2011-05-19 Thread Jorge Ivan Velez
Hi, Does the following work for you? set.seed(123) d <- data.frame(x = rpois(10, 4), y = rnorm(10)) d d + 2 See ?within for one more option. HTH, Jorge On Thu, May 19, 2011 at 11:54 PM, Ramya <> wrote: > Hi there > > I just want to add 2 to all the values in dataframe. > > I tried using sapp

Re: [R] extraction of mean square value from ANOVA

2011-05-19 Thread Cheryl Johnson
Thanks for your help. How would I extract each of the 3 values in the vector individually? Thanks again On Thu, May 19, 2011 at 10:40 PM, Rolf Turner wrote: > On 20/05/11 13:46, Cheryl Johnson wrote: > >> Hello, >> >> I am randomly generating values and then using an ANOVA table to find the >> m

[R] Adding a numeric to all values in the dataframe

2011-05-19 Thread Ramya
Hi there I just want to add 2 to all the values in dataframe. I tried using sapply but it seem to die all the time. Any help would be appreciated. Thanks Ramya -- View this message in context: http://r.789695.n4.nabble.com/Adding-a-numeric-to-all-values-in-the-dataframe-tp3537594p3537594.htm

[R] How to do covariate adjustment in R

2011-05-19 Thread karena
Hi, I have a question about how to do covariate adjustment. I have two sets of 'gene expression' data. They are from two different tissue types, 'liver' and 'brain', respectively. The purpose of my analysis is to compare the pattern of the whole genome 'gene expression' between the two tissue typ

Re: [R] Converting the graphics window to a data matrix

2011-05-19 Thread Beutel, Terry S
Thanks Barry. I have now got as far as creating the png (or gif or tiff) images (as per your suggestions). But I am unable to work out how to convert each to a 2 dimensionional numeric matrix showing the spatial distribution of occupied/unoccupied pixels in R. Any suggestions anybody? Thanks T

Re: [R] extraction of mean square value from ANOVA

2011-05-19 Thread Bill.Venables
That only applies if you have the same factors a and b each time. If this is the case you can do things in a much more slick way. u <- matrix(rnorm(5000), nrow = 10) ## NB, nrow AB <- expand.grid(a = letters[1:2], b = letters[1:5]) M <- lm(u ~ a+b, AB) rmsq <- colSums(resid(M)^2)/M$df.resid an

Re: [R] extraction of mean square value from ANOVA

2011-05-19 Thread Dennis Murphy
Hi: It's easier to use an apply family function than a loop for this type of problem, as illustrated below: # Generate 30 random samples of size 10 from a standard # normal distribution and put them into a matrix u <- matrix(rnorm(300), ncol = 10) a <- factor(rep(1:5, each = 2)) b <- factor(rep(1

Re: [R] extraction of mean square value from ANOVA

2011-05-19 Thread Rolf Turner
On 20/05/11 14:51, Cheryl Johnson wrote: Thanks for your help. How would I extract each of the 3 values in the vector individually? If you are going to use R, it would pay you to learn a little bit about it. Like, e.g., vector indexing. In your example anova(mylm)[["Mean Sq"]][3] would g

Re: [R] extraction of mean square value from ANOVA

2011-05-19 Thread Rolf Turner
On 20/05/11 13:46, Cheryl Johnson wrote: Hello, I am randomly generating values and then using an ANOVA table to find the mean square value. I would like to form a loop that extracts the mean square value from ANOVA in each iteration. Below is an example of what I am doing. a<-rnorm(10) b<-fact

[R] extraction of mean square value from ANOVA

2011-05-19 Thread Cheryl Johnson
Hello, I am randomly generating values and then using an ANOVA table to find the mean square value. I would like to form a loop that extracts the mean square value from ANOVA in each iteration. Below is an example of what I am doing. a<-rnorm(10) b<-factor(c(1,1,2,2,3,3,4,4,5,5)) c<-factor(c(1,2,

Re: [R] Anyone successfully install Rgraphviz on windows with R 2.13?

2011-05-19 Thread Gabor Grothendieck
On Thu, May 19, 2011 at 4:28 PM, Michael Conklin wrote: > I have been trying to get Rgraphviz to work (I know it is from Bioconductor) > unsuccessfully. Since I have no experience with Bioconductor I thought I > would ask here if anyone has advice. I have installed Graphviz 2.20.3 as is > recom

Re: [R] A better way to do this

2011-05-19 Thread Dennis Murphy
Hi: Could you post a small, reproducible data set that illustrates what you want to do? It sounds like you're creating 'spaghetti plots', which can be done with a minimal amount of pain in ggplot2. Dennis On Thu, May 19, 2011 at 11:29 AM, 1Rnwb wrote: > Hello gurus, > > I have a dataframe conta

Re: [R] Anyone successfully install Rgraphviz on windows with R 2.13?

2011-05-19 Thread Paul Murrell
Hi In addition to getting the graphviz version EXACTLY right (as per the README file), and ensuring that the right paths are set up, I also seemed to need to install graphviz in a path WITHOUT spaces (but that may just have been superstition) Paul On 20/05/2011 8:28 a.m., Michael Conklin wr

Re: [R] changes in coxph in "survival" from older version?

2011-05-19 Thread Frank Harrell
Hi Tao, For you situation (and even MUCH larger number of events), multivariable modeling will be unreliable unless you use shrinkage, variable selection will select the wrong variables, and univariable screening leads to massive bias in later stages. Terry converted me from SAS to S-Plus in 1991

Re: [R] changes in coxph in "survival" from older version?

2011-05-19 Thread Shi, Tao
Thank you, Frank and Terry, for all your answers! I'll upgrade my "survival" package for sure! It seems to me that you two are pointing to two different issues: 1) Is stepwise model selection a good approach (for any data)? 2) Whether the data I have has enough information that even worth to

Re: [R] lmer with 2 random effects with only two levels

2011-05-19 Thread Daniel Malter
What you should and can do depends on the expectations you have regarding the correlation structure of the data and is limited by your degrees of freedom. For example, what is wrong about: reg<-lmer(response~femaleset+treatment+(1|group)) ? This assumes that there are constant group effects on

Re: [R] *not* using attach() *but* in one case ....

2011-05-19 Thread Bill.Venables
>>> Martin Maechler writes: > > Well, then you don't know *THE ONE* case where modern users of > R should use attach() ... as I have been teaching for a while, > but seem not have got enought students listening ;-) ... > > --- Use it instead of load() {for save()d R objects} --- > > Th

Re: [R] K-M probability for each subject

2011-05-19 Thread David Winsemius
On May 19, 2011, at 5:20 PM, hsu ya-hui wrote: Dear R-user, I would like to get the survival probability (surv) for each subject id. That is, I want to have additional column surv as follows: The survival probability for each subject is 1 until death and 0 thereafter. id OS OS_DUR

Re: [R] Converting Variable Name into String

2011-05-19 Thread Paolo Rossi
Hi Bert, thanks for your advice on lapply which I am still not very familair with. With regard from the issue of the names I realised that I can simply call names on the data.frame and then join them with other strings through paste and add them to the data.frame by using the [] syntax rather than

Re: [R] Separating boot results

2011-05-19 Thread Jorge Ivan Velez
Hmmm... I am sorry Patrick, it should have been * a <- codboot[c(4)] round(a$bca[4:5], 2) # note I replaced "," by ":" Best, Jorge * > > On Thu, May 19, 2011 at 3:08 PM, Patrick Santoso <> wrote: > >> Thanks for the suggestion Jorge! >> >> - that gives me subscript out of bounds error.

Re: [R] recursive function

2011-05-19 Thread Robert Baer
Perhaps this is useful: x=c(-2,0,2) sign(x)*abs(x) [1] -2 0 2 -- Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A. T. Still University of Health Sciences 800 W. Jefferson St. Kirksville, MO 63501 660-626-2322 F

Re: [R] recursive function

2011-05-19 Thread Rolf Turner
(1) What has this to do with recursion? (2) You probably need to use ifelse(). I believe that this is (in effect) an FAQ. cheers, Rolf Turner On 20/05/11 07:42, Tremblay, Pierre-Olivier wrote: Hi, I created a function for obtaining the normal cumulative distribution (I know all

Re: [R] How to get rid of the index in result file

2011-05-19 Thread Jorge Ivan Velez
Hi Yighua, Try > m <- 2.35343 > m [1] 2.35343 > cat(m) 2.35343 HTH, Jorge On Thu, May 19, 2011 at 2:35 PM, Hu, Yinghua <> wrote: > Hi, > > I am running some function in Ubuntu command line and get some problem. I > used some command like below > > $ R --slave -vanilla < my_infile > my_outfile

[R] How to get rid of the index in result file

2011-05-19 Thread Hu, Yinghua
Hi, I am running some function in Ubuntu command line and get some problem. I used some command like below $ R --slave -vanilla < my_infile > my_outfile The return should be one number in the my_outfile. In the my_infile, I call one extra function and it has code like "return x". However, in

Re: [R] mediation

2011-05-19 Thread Андрей Гончар
You can see the whole function by printing its name in console. Example: > plot function (x, y, ...) { if (is.function(x) && is.null(attr(x, "class"))) { if (missing(y)) y <- NULL hasylab <- function(...) !all(is.na(pmatch(names(list(...)), "ylab")))

[R] K-M probability for each subject

2011-05-19 Thread hsu ya-hui
Dear R-user, I would like to get the survival probability (surv) for each subject id. That is, I want to have additional column surv as follows: id OS OS_DUR surv eg: fitKM<-survfit(Surv(OS_DUR,OS)~1,data=data) fitKM$surv # this will only give me survival probability and

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Luma R
Thank you all for the help and solutions presented! Luisa On Thu, May 19, 2011 at 9:33 PM, Dennis Murphy wrote: > Oops, didn't see Marc's reply. His solution is much more compact. For > R 2.11.0 and above, aggregate() now has a formula interface that > usually works nicely: > > aggregate(Var3 ~

[R] A better way to do this

2011-05-19 Thread 1Rnwb
Hello gurus, I have a dataframe containing two groups viz., 'control' and 'case', each of these groups contains longitudinal data for 100 subjects. I have to plot all these subjects on a single chart and then put a regression line for each of the group for all the subjects. I have written a functi

[R] recursive function

2011-05-19 Thread Tremblay, Pierre-Olivier
Hi, I created a function for obtaining the normal cumulative distribution (I know all this already exists in R, I just wanted to verify my understanding of it). below is the code I came up with. cdf<-function(x) { erf<-function(x) { # approximation to the error function

Re: [R] Separating boot results

2011-05-19 Thread Patrick Santoso
Thanks for the suggestion Jorge! - that gives me subscript out of bounds error. perhaps I can tweak the parameters? I've never worked with that command. Pat On Thu, May 19, 2011 at 2:12 PM, Jorge Ivan Velez wrote: > Hi Patrick, > > How about this (untested)? > > a <- codboot[c(4)] > round(a$bca

[R] lmer with 2 random effects with only two levels

2011-05-19 Thread gmd
Dear all, I am analysing a data set based on 6 groups of individuals. Each group is observed for 10 days. 5 days with one manipulation 5 days with another manipulation. I therefore have 6 replicate groups (n=6) each with one mean measurement for manipulation A and manipulation B. Each group con

Re: [R] svytable and na's

2011-05-19 Thread Thomas Lumley
On Thu, May 19, 2011 at 11:41 PM, Manderscheid Katharina wrote: > hi, > > i am trying to work with the survey package in order to apply survey design > weights. the data set i am using - ess - contains missing values. > my question: when using svytable(~variable1+variable2, > design=my.svydesign

Re: [R] R Style Guide -- Was Post-hoc tests in MASS using glm.nb

2011-05-19 Thread Kevin Wright
John Chambers is also very widely quoted describing the aim of S as "to turn ideas into software, quickly and faithfully." Perhaps S3 is for people wanting to do things "quickly" and S4 is for those wanting to do things "faithfully". Kevin On Wed, May 18, 2011 at 7:39 PM, wrote: > I used to th

[R] Flattening lists and environments (was: "how to flatten a list to the same level?")

2011-05-19 Thread Janko Thyson
Dear list, I came up with a two functions that flatten arbitrary deeply nested lists (as long as they're named; not tested for unnamed) and environments (see attachment; 'flatten_examples.txt' contains some examples). The paradigm is somewhat similar to that implemented in 'unlist()', yet e

Re: [R] Shrink file size of pdf graphics

2011-05-19 Thread Layman123
Thank you all for the quick answers! I googled first instead of having the idea to search this forum... I'm using R 2.12.2 on a 32-bit Computer with windows installed. Up to this point I was trying to get the image the way I would like to have it, but didn't get fully satisfactory results. I trie

[R] Anyone successfully install Rgraphviz on windows with R 2.13?

2011-05-19 Thread Michael Conklin
I have been trying to get Rgraphviz to work (I know it is from Bioconductor) unsuccessfully. Since I have no experience with Bioconductor I thought I would ask here if anyone has advice. I have installed Graphviz 2.20.3 as is recommended on the Bioconductor site but basically R cannot seem to fi

Re: [R] vectorial search for elements with certain attributes

2011-05-19 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Dennis Murphy > Sent: Thursday, May 19, 2011 11:38 AM > To: infoc...@gmx.net > Cc: r-help@r-project.org > Subject: Re: [R] vectorial search for elements with certain attributes >

Re: [R] Email out of R (code)

2011-05-19 Thread Bos, Roger
I took a look at sendmailR when I was trying to figure out how to send email a few years ago. I ended up using my SQL Server dbmail facility, which I can easily access from R using the RODBC package. In case my scenario applies to anyone else, I will paste the simple function I wrote to serve as

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Dennis Murphy
Oops, didn't see Marc's reply. His solution is much more compact. For R 2.11.0 and above, aggregate() now has a formula interface that usually works nicely: aggregate(Var3 ~ Var1 + Var2, data = d, FUN = table) Var1 Var2 Var3.D Var3.I 1 S1 T1 2 2 2 S2 T1 2 2 3 S1 T

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Dennis Murphy
Hi: The dummy column really isn't necessary. Here's another way to get the result you want. Let d be the name of your example data frame. d <- d[, 1:3] (dtable <- as.data.frame(ftable(d, row.vars = c(1, 2 Var1 Var2 Var3 Freq 1 S1 T1D2 2 S2 T1D2 3 S1 T2D2

[R] mediation

2011-05-19 Thread Mervi Virtanen
Hi! I try to find out how bootstrap mediation work! How I coud see the whole function or algorithm? (rather whole bootstrap). t.Mete __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gui

Re: [R] Problem with Princurve

2011-05-19 Thread David Winsemius
On May 19, 2011, at 9:43 AM, guy33 wrote: Hey all, I can't seem to get the princurve package to produce correct results, even in the simplest cases. For example, if you just generate a 1 period noiseless sine wave, and ask for the principal curve and plot, the returned curve is clearly w

[R] a tool for indirect solving of systems of equations

2011-05-19 Thread Carl Witthoft
I wrote this goody a while back, and thought I'd post it in case anyone can find a use for it. I'm mentioning it here because I'm not convinced it warrants a full package release. The function is named "ktsolve," and is available at http://witthoft.com/rtools.html or directly at http://witt

Re: [R] vectorial search for elements with certain attributes

2011-05-19 Thread Dennis Murphy
Hi: Here's one possible approach: A <- c(1,3,7,8,10) B <- c(5,8) apply(outer(A, B, '-'), 2, function(x) min(which(x >= 0))) [1] 3 4 HTH, Dennis On Thu, May 19, 2011 at 2:58 AM, wrote: > I have 2 vectors A and B. For each element of B I'd like to find the index of > the next higher or equal e

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Marc Schwartz
Another approach, using aggregate(), presuming that the data is in a data frame called 'DF': > with(DF, aggregate(Var3, list(Var1 = Var1, Var2 = Var2), table)) Var1 Var2 x.D x.I 1 S1 T1 2 2 2 S2 T1 2 2 3 S1 T2 2 2 4 S2 T2 0 4 HTH, Marc Schwartz On May 19, 20

Re: [R] Separating boot results

2011-05-19 Thread Jorge Ivan Velez
Hi Patrick, How about this (untested)? a <- codboot[c(4)] round(a$bca[4, 5], 2) HTH, Jorge On Thu, May 19, 2011 at 7:20 AM, Patrick Santoso <> wrote: > Good Morning, > > I'm having what I hope to be a simple problem. I am generating bootstrap > confidence intervals using package (boot) - whic

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Phil Spector
Luma - If I understand you correctly, I think the easiest way to get what you want is to use the reshape function on the output from aggregate: reshape(Count.Cells,idvar=c('Var1','Var2'),timevar='Var3',direction='wide') Var1 Var2 dummy.D dummy.I 1 S1 T1 2 2 2 S2 T1

Re: [R] Email out of R (code)

2011-05-19 Thread Daniel Malter
As I (thought I) understood from the sendmailR manual, the package does currently not support server authentication, or does it? Daniel -- View this message in context: http://r.789695.n4.nabble.com/Email-out-of-R-code-tp3530671p3536512.html Sent from the R help mailing list archive at Nabble.c

[R] Border-Layout by multiple Plots

2011-05-19 Thread Stuber Thomas TA.I_BB_BS.0701
Hello R-Community I did a lot of research, but i found no answer for my issue. I try to plot multiple Plots. I do this with the layout() function. The following two pictures show the defined layout: http://www.stuber.info/layout_1.jpg http://www.stuber.info/layout_2.jpg The final plots looks lik

[R] FW: problem with optim()

2011-05-19 Thread chirine wolley
From: wolley.chir...@hotmail.com To: biomathjda...@gmail.com Subject: RE: [R] problem with optim() Date: Thu, 19 May 2011 15:45:15 +0200 First, thank you for ur response... Actually I didn't write the entire code ...X, Y and p_tilde are of course all defined at the beginning of my code.

[R] Pie chart

2011-05-19 Thread Silvano
I made a pie chart and the names of the levels are outside the circle. How do I put the names of the levels within each sector? names(tab13) = paste(c('Regular', 'Bom', 'Excelente'), round(100*prop.table(tab13), dig=1), "%") pie(tab13, col=c("LightYellow", "lightgreen", 'lightblue', 'white'),

[R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Luma R
Dear all, I am having trouble creating summary tables using aggregate function. given the following table: Var1 Var2Var3 dummy S1 T1 I 1 S1 T1 I 1 S1 T1 D1 S1 T1 D1 S1 T2 I 1 S1

[R] Heteroskedastic regression model

2011-05-19 Thread Tomas Klepsys
Dear all, Can some please help me to estimate heteroskedastic regression model in R. I know that in Stata reghv function (regh package) can be used. Waht are their equivalents in R? Thanks in advance. Best, Tomas [[alternative HTML version deleted]]

[R] Separating boot results

2011-05-19 Thread Patrick Santoso
Good Morning, I'm having what I hope to be a simple problem. I am generating bootstrap confidence intervals using package (boot) - which works perfectly. The issue I am having is getting the results into a format which I can write out to a database. To be clear I am having no problems generating t

Re: [R] Help, please

2011-05-19 Thread Mike Marchywka
> From: dwinsem...@comcast.net > To: julio.flo...@spss.com.mx > Date: Thu, 19 May 2011 10:40:08 -0400 > CC: r-help@r-project.org > Subject: Re: [R] Help, please > > > On May 18, 2011, at 6:29 PM, Julio César Flores Castro wrote: > > > Hi, > > > > I am

[R] vectorial search for elements with certain attributes

2011-05-19 Thread infochat
I have 2 vectors A and B. For each element of B I'd like to find the index of the next higher or equal element in A. And I'd like to store it effectiv. E.g.: A <- c(1,3,7,8,10) B <- c(5,8) result: 3, 4 I have a possibility but for long vectors it works not very effectiv: ans <- sapply(B, functi

[R] Problem with Princurve

2011-05-19 Thread guy33
Hey all, I can't seem to get the princurve package to produce correct results, even in the simplest cases. For example, if you just generate a 1 period noiseless sine wave, and ask for the principal curve and plot, the returned curve is clearly wrong (doesn't follow the sine wave). Here's my cod

Re: [R] set x11 as default plot

2011-05-19 Thread cande
Hi, have the same question. did you manage to make x11 your default ploting device? - Chriss -- View this message in context: http://r.789695.n4.nabble.com/set-x11-as-default-plot-tp2248427p3535824.html Sent from the R help mailing list archive at Nabble.com. _

[R] read.csv and FileEncoding in Windows version of R 2.13.0

2011-05-19 Thread Alexander Peterhansl
Dear Help List: read.csv() seems to have changed in R version 2.13.0 as compared to version 2.12.2 when reading in simple CSV files. In reading a 2-column CSV file ("test.csv"), say 1, a 2, b If file is encoded as UTF-8 (on Windows 7), then under R 2.13.0 read.csv("test.csv",fileEncoding="UTF-8

Re: [R] Shrink file size of pdf graphics

2011-05-19 Thread Aaron Mackey
You can try something like this, at the command line: gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf evidently, the new compactPDF() function in R 2.13 does something very similar. -Aaron On Thu, May 19, 2011 at

Re: [R] dbetagen function in mc2d package

2011-05-19 Thread Ben Bolker
krusty the klown libero.it> writes: > I found this useful package for generalized beta, yet the function that > calculates its density leaves me puzzled, especially when I plotted it: > > plot(function(y) dbetagen(y,4,1.2,min=0,max=40),xlim=c(0,40)) > > The area between the density curve and th

Re: [R] matrix help (first occurrence of variable in column)

2011-05-19 Thread jim holtman
Is this what you are looking for: > mdat3 sp.1 sp.2 sp.3 sp.4 sp.5 T110010 T210010 T311100 T410111 > > # create a matrix of when species first appeared > first <- apply(mdat3, 2, function(x) (cumsum(x == 1) > 0) + 0

Re: [R] Creating a "shifted" month (one that starts not on the first of each month but on another date)

2011-05-19 Thread Dimitri Liakhovitski
Thanks a lot, Jim. This is exactly what I was looking for! Dimitri On Thu, May 19, 2011 at 12:11 PM, jim holtman wrote: > try this: > > mydf<-data.frame(mydate=seq(as.Date("2011-01-01"), length = 92, by = "day")) > # add 'day' to the dataframe > mydf$day <- format(mydf$mydate, "%d") > mydf$newfac

[R] dbetagen function in mc2d package

2011-05-19 Thread krusty the klown
Hi all, I found this useful package for generalized beta, yet the function that calculates its density leaves me puzzled, especially when I plotted it: plot(function(y) dbetagen(y,4,1.2,min=0,max=40),xlim=c(0,40)) The area between the density curve and the x axis does not seem to measure 1!!! --

Re: [R] Creating a "shifted" month (one that starts not on the first of each month but on another date)

2011-05-19 Thread jim holtman
try this: mydf<-data.frame(mydate=seq(as.Date("2011-01-01"), length = 92, by = "day")) # add 'day' to the dataframe mydf$day <- format(mydf$mydate, "%d") mydf$newfactor <- cumsum(mydf$day == '20') mydf On Thu, May 19, 2011 at 10:51 AM, Dimitri Liakhovitski wrote: > Hello! > I have a data frame w

Re: [R] Converting Variable Name into String

2011-05-19 Thread Bert Gunter
1. This won't work. The lagged variables have length one less than the originals. 2. How about: lagged_Q <- data.frame( lapply( QuarterlyData,diff)) You can then change the names in lagged_Q to something like lagged_originalName via paste() if you like. 3. I strongly suspect that none of this i

Re: [R] *not* using attach() *but* in one case ....

2011-05-19 Thread Prof Brian Ripley
On Thu, 19 May 2011, Liaw, Andy wrote: From: Prof Brian Ripley Hmm, load() does have an 'envir' argument. So you could simply use that and with() (which is pretty much what attach() does internally). If people really wanted a lazy approach, with() could be extended to allow file names (as at

Re: [R] Shrink file size of pdf graphics

2011-05-19 Thread Duncan Murdoch
On 19/05/2011 11:14 AM, Layman123 wrote: Hi everyone, My data consists of a system of nearly 75000 roads, available as a shapefile. When I plot the road system, by adding the individual roads with 'lines' and store it as a pdf-file with 'pdf' I get a file of size 13 MB. This is way too large to

Re: [R] Shrink file size of pdf graphics

2011-05-19 Thread Prof Brian Ripley
This was answered on this list a few days ago. See https://stat.ethz.ch/pipermail/r-help/2011-May/278029.html On Thu, 19 May 2011, Layman123 wrote: Hi everyone, My data consists of a system of nearly 75000 roads, available as a shapefile. When I plot the road system, by adding the individual

Re: [R] *not* using attach() *but* in one case ....

2011-05-19 Thread Duncan Murdoch
On 19/05/2011 10:34 AM, Liaw, Andy wrote: From: Prof Brian Ripley > > Hmm, load() does have an 'envir' argument. So you could simply use > that and with() (which is pretty much what attach() does internally). > > If people really wanted a lazy approach, with() could be extended to > allow fi

Re: [R] within()

2011-05-19 Thread David Winsemius
On May 19, 2011, at 9:32 AM, Timothy Bates wrote: Likewise it would help reduce confusion when plot(~Source, data=Df) # works # but boxplot(~Source, data=Df) # Error in boxplot.formula(~Source, data = Df) : # 'formula' missing or incorrect The formula isn’t missing or illformed, it’s that bo

[R] Shrink file size of pdf graphics

2011-05-19 Thread Layman123
Hi everyone, My data consists of a system of nearly 75000 roads, available as a shapefile. When I plot the road system, by adding the individual roads with 'lines' and store it as a pdf-file with 'pdf' I get a file of size 13 MB. This is way too large to add it in my LaTeX-document, because there

Re: [R] R Style Guide -- Was Post-hoc tests in MASS using glm.nb

2011-05-19 Thread Spencer Graves
Is a list like Henrik's (below) available someplace on r-project.org or on your local CRAN mirror? If no, where do you think it might most conveniently fit? What about "www.r-project.org/other-docs.html"? Perhaps add a bullet right under the link to "DevCheatSheet has a collection of R Refere

[R] Converting Variable Name into String

2011-05-19 Thread Paolo Rossi
Hello, I would like to create lagged and delta variables from a set of variables and then add them to a dataframe Suppose that GDPPcSa is a variable. I would like to be able to do this QuarterlyData$D1GdpPcSa = diff(GDPPcSa , 1) in an automated fashion so that I loop over Quartely data to compu

[R] Creating a "shifted" month (one that starts not on the first of each month but on another date)

2011-05-19 Thread Dimitri Liakhovitski
Hello! I have a data frame with dates. I need to create a new "month" that starts on the 20th of each month - because I'll need to aggregate my data later by that "shifted" month. I wrote the code below and it works. However, I was wondering if there is some ready-made function in some package - th

Re: [R] Help, please

2011-05-19 Thread David Winsemius
On May 18, 2011, at 6:29 PM, Julio César Flores Castro wrote: Hi, I am using R 2.10.1 and I have a doubt. Do you know how many cases can R handle? I was able to handle (meaning do Cox proportional hazards work with the 'rms' package which adds extra memory overhead with a datadist obj

Re: [R] within()

2011-05-19 Thread Duncan Murdoch
On 19/05/2011 9:32 AM, Timothy Bates wrote: The most interesting thing in this thread for me was "within()" - that is what I want 99% of the time, but I had only ever heard of with() A real boon! Thanks Bill V! The help for within gives this example for with(), which seems unnecessary, as glm

Re: [R] *not* using attach() *but* in one case ....

2011-05-19 Thread Liaw, Andy
From: Prof Brian Ripley > > Hmm, load() does have an 'envir' argument. So you could simply use > that and with() (which is pretty much what attach() does internally). > > If people really wanted a lazy approach, with() could be extended to > allow file names (as attach does). I'm not sure if

Re: [R] Does a data frame have indexes for columns?

2011-05-19 Thread Santosh Srinivas
Check data.table ... It benefits a lot from indexing data in data frames On Thu, May 19, 2011 at 7:41 PM, xiagao1982 wrote: > Hi all, > > I wonder if I can create indexes for columns in a data frame to speed up data > selection by matching column values, just like indexes for large tables in a

[R] Does a data frame have indexes for columns?

2011-05-19 Thread xiagao1982
Hi all, I wonder if I can create indexes for columns in a data frame to speed up data selection by matching column values, just like indexes for large tables in a relational database? Thank you! xiagao1982 2011-05-19 [[alternative HTML version deleted]]

Re: [R] R Style Guide -- Was Post-hoc tests in MASS using glm.nb

2011-05-19 Thread Bert Gunter
Thanks Martin, Your points are, of course, well taken. Nevertheless, I still think it might be useful to put a link or links to one or more style guides in the FAQ with a comment to the effect that these are various recommended ways to help write better, more readable code. Something like: --

[R] McKinsey Global Institute Report on Big Data has potential implications for R

2011-05-19 Thread Dimitri Liakhovitski
Thought I'd share with the community: A very interesting (free) report by McKinsey Global Institute about the importance of Big Data for the present/future economy: http://www.mckinsey.com/mgi/publications/big_data/index.asp Hoping R will be an important player in this area. -- Dimitri Liakhovi

Re: [R] problem with optim()

2011-05-19 Thread Jonathan Daily
I cc'd r-help to get this message back on the board. Again, you haven't really answered my questions. Comments inline. On Thu, May 19, 2011 at 9:45 AM, chirine wolley wrote: > First, thank you for ur response... > Actually I didn't write the entire code ...X, Y and p_tilde are of > course all de

Re: [R] balanced panel data

2011-05-19 Thread Cecilia Carmo
It works! Thank you. Cecília De: Scott Chamberlain [mailto:scttchamberla...@gmail.com] Enviada: quinta-feira, 19 de Maio de 2011 13:40 Para: Cecilia Carmo Cc: r-help@r-project.org Assunto: Re: [R] balanced panel data # If you know how many years are needed you could do this maken

Re: [R] matrix help (first occurrence of variable in column)

2011-05-19 Thread Michael Denslow
On Wed, May 18, 2011 at 9:49 PM, jim holtman wrote: > Is this what you were after: > >> mdat <- matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE, > +               dimnames = list(c("T1", "T2"), > +                               c("sp.1", "sp.2", "sp.3"))) >> >> mdat >   sp.1 sp.2 sp.3 > T1    

[R] within()

2011-05-19 Thread Timothy Bates
The most interesting thing in this thread for me was "within()" - that is what I want 99% of the time, but I had only ever heard of with() A real boon! Thanks Bill V! The help for within gives this example for with(), which seems unnecessary, as glm supports data= with(anorexia, { anorex.1

Re: [R] problem with optim()

2011-05-19 Thread Jonathan Daily
What do you mean when you say "wrong results"? What do you expect for the output? Your code doesn't work for me because it references X in places and X is not defined. Have you tested your functions to make sure they return reasonable values? On Thu, May 19, 2011 at 9:17 AM, chirine wolley wrote

[R] problem with optim()

2011-05-19 Thread chirine wolley
Dear R-users, I would like to maximize the function g above which depends on 4 parameters (2 vectors, 1 real number, and 1 matrix) using optim() and BFGS method. Here is my code: # fonction to maximize g=function(x) { x1 = x[1:ncol(X)] x2 = x[(ncol(X)+1)] x3 = matrix(x[(ncol(X)+2):(ncol(

[R] Specifying Splits WhenUusing rpart

2011-05-19 Thread Bruce Johnson
I am using the package rpart to explore various classification structures. The call looks like: seekhi1<-rpart(pvol~spec+a1+psize+eppres+numpt+icds+bivalcrt+stents+ppshare+ nhosp+nyrs,data=dat,method="class", control=rpart.control(minsplit=30,xval=10)) The output is 1)

Re: [R] Problems with unsplit()

2011-05-19 Thread Scott Chamberlain
You generally aren't allowed to have duplicate row names in a data frame in R. If you want to keep your rownames you can make them a column in the data frame before unsplitting. Scott On Thursday, May 19, 2011 at 5:27 AM, Cecilia Carmo wrote: > Hi everyone, > > > > I have already used split

Re: [R] balanced panel data

2011-05-19 Thread Scott Chamberlain
# If you know how many years are needed you could do this makenewtable <- function(x, years) { xlist <- split(x, x$firm) new <- list() dat <- lapply(xlist, function(z) if(length(unique(z$year)) == years) {new <- z} ) dat_ <- do.call(rbind, dat) return(dat_) } makenewtable(finaldata, 5) Scott On

Re: [R] identical function names from 2 packages

2011-05-19 Thread Duncan Murdoch
On 18/05/2011 10:02 PM, Nick Matzke wrote: Hi, If I load 2 packages that have a function with the same name, how do I tell R to run one or the other? (Instead of having R automatically use the first- or last-loaded one, whichever it is. (Which is it, by the way.)) Cheers! Nick It is the m

[R] Hi my best freinds

2011-05-19 Thread arsalan fathi
Hi. No tired. I need the Quasi-Newton and Nelder-Mead algorithm for estimate the 3parameters function. I need really. please help me. Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/ma

  1   2   >