[R] Date conversion problem using "as.Date"
Hello! My problem is that the Julian date "behind" my dates seems to be wrong. I will examplify my problem. t1 <- "1998-11-20" t2 <- as.Date(t1) # Here t2 is correctly "1998-11-20", but date.mdy(t2) $month [1] 11 $day [1] 19 $year [1] 1988 And indeed, if I write: fix(t2) then I get : structure(10550, class = "Date"). So the Julian date is 10550, which is "1988-11-19", not the correct "1998-11-20" If I instead of "as.Date" use "as.date", then things work ok. But I have not found out how to instruct "as.date" to handle dates from the 21st century. I hope that someone can help me, thanks in advance! -- Best regards, Vegard Andersen Institute of Community Medicine University of Tromso Tromso, Norway [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] multiple graphs
Dear all, I would like to plot multiple graphs in the same window. For this I used: par(mfcol=c(5,2) ) and then I use plot(x,y) to fill the cells of the window with the graphs. This results in multiple graphs with a lot of space around each graph. But I would like the 5 graphs in each column to be 'connected' (i.e., no space around them) and to specify values and label on the x-axis only for the lowest graph in each column. Does anyone know how I can do this? I considered xyplot(y~x|z) from the lattice package, but I have different variables on the y-axis in each graph, so this does not seem to work? Thanks in advance for any suggestions, Marleen de Moor Dept. of Biological Psychology Free University Amsterdam [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] creating functions in R
I am trying to learn how to create my own function in R. I want to create a function that can plot the polygons/regions/map given the coordinates of each region. The function should be able to colour the poplygons according to the data supplied ,for examples the means or rates of disease at a region/polygon. your advise will be highly appreciated. Thanks in advance for your help. Oarabile __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple graphs
Moor MHM.de wrote: Dear all, I would like to plot multiple graphs in the same window. For this I used: par(mfcol=c(5,2) ) and then I use plot(x,y) to fill the cells of the window with the graphs. This results in multiple graphs with a lot of space around each graph. But I would like the 5 graphs in each column to be 'connected' (i.e., no space around them) and to specify values and label on the x-axis only for the lowest graph in each column. See ?par, e.g. set par(mar = rep(0,4)) for the inner plots. Uwe Ligges Does anyone know how I can do this? I considered xyplot(y~x|z) from the lattice package, but I have different variables on the y-axis in each graph, so this does not seem to work? Thanks in advance for any suggestions, Marleen de Moor Dept. of Biological Psychology Free University Amsterdam [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple graphs
You can use par(mai=_yourValues_) For instance: > par(mfcol=c(5,2) ) > par(mai=c(0,0,0,0)) > replicate(10,plot(1:10)) Modify the mai parameter and arguments in the plot() function to get better results, hope this helps, vito Moor MHM.de wrote: Dear all, I would like to plot multiple graphs in the same window. For this I used: par(mfcol=c(5,2) ) and then I use plot(x,y) to fill the cells of the window with the graphs. This results in multiple graphs with a lot of space around each graph. But I would like the 5 graphs in each column to be 'connected' (i.e., no space around them) and to specify values and label on the x-axis only for the lowest graph in each column. Does anyone know how I can do this? I considered xyplot(y~x|z) from the lattice package, but I have different variables on the y-axis in each graph, so this does not seem to work? Thanks in advance for any suggestions, Marleen de Moor Dept. of Biological Psychology Free University Amsterdam [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90121 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Optimization of constrained linear least-squares problem
Thanx Dimitris, Patrick and Berwin! For other people interested in this problem, here are two valid solutions that work. 1) Re-parameterize e.g., EM <- c(100,0,0,0,100,0,0,0,100) W <- array(EM, c(3,3)) d <- c(10, 20, 70) fn <- function(x){ x <- exp(x) / sum(exp(x)) r <- W%*%x - d crossprod(r, r)[1,1] } opt <- optim(rnorm(3), fn) res <- exp(opt$par) / sum(exp(opt$par)) res "The first line of the `fn()' function is just a re-pameterization of your problem, i.e., if `y' is a vector of real numbers, then it is straightforward to see that `x = exp(y) / sum(exp(y))' will be real numbers in (0, 1) for which `sum(y)=1'. So instead of finding xs that minimize your function under the constraint (which is more difficult) you just find the ys using the above transformation." (I owe you a drink Dimitris !!!) 2) Or minimize it as a quadratic function under a linear constraint: EM <- c(100,0,0,0,100,0,0,0,100) W <- array(EM, c(3,3)) d <- c(10, 20, 70) library(quadprog) Dmat <- crossprod(W,W) dvec <- crossprod(d,W) A <-matrix(c(1,1,1),ncol=1) bvec <- 1 solve.QP(Dmat, dvec, A, bvec, meq=1) This is based on the objective function (i.e. the thing you want to minimise) : min x'C'Cx - 2 d'Cx + d'd where sum(x) = 1 (Thanx Berwin!!) Kind regards, Stef __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] creating functions in R
Oarabile Ruth Molaodi wrote: I am trying to learn how to create my own function in R. I want to create a function that can plot the polygons/regions/map given the coordinates of each region. The function should be able to colour the poplygons according to the data supplied ,for examples the means or rates of disease at a region/polygon. You might want to take a look at package "maps". Uwe Ligges your advise will be highly appreciated. Thanks in advance for your help. Oarabile __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Installation problem MacOS X
R gurus I have tried to install the R 2.0.1 binary for OS X and although the installation was successful I can get the application going. When I double click the icon R tries to load (R window shows briefly) and it quits immediately. This behavior was described in this list before and nobody found the answer to the problem. If you try to load the x11 version by typing "R" at the command line it loads up with no problem. This means that the app is partially working and there are no permissions issue. The most interesting thing is if I log to a different account (Dummy) and I double click the application it loads with no problem. This makes me think that there has to be some type of user specific file or directory that is causing the gui to quit. Any suggestions on what file(s) could be affecting R? Thanks Hector ** Héctor L. Ayala-del-Río, Ph.D. Assistant Professor Department of Biology University of Puerto Rico at Humacao CUH postal station 100 road 908 Humacao, PR 00791 Ph: 787-850- x 9001 Fax: 787-850-9439 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] passing arguments to FUN in lapply
Suppose I have a nx2 matrix of data, X, the following code generate density estimation for each column and plot them denlist <- apply(X, 2, density) par(mfrow=c(1,2)) lapply(denlist, plot) Does anyone know how to change the main title of each density plot to "var 1", "var 2" by passing optional argument "main"? I've tried lapply(denlist, plot, main=c("var 1", "var 2")) which generates two same titles "var 1/var 2" and "var 1/var 2" lapply(denlist, plot, main=list("var 1", "var 2")) which generates two same titles "var 1" Both are not I want. -- Pingping Zheng Department of Mathematics and Statistics Fylde College Lancaster University Lancaster LA1 4YF UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] creating functions in R
On Fri, 18 Mar 2005, Uwe Ligges wrote: > Oarabile Ruth Molaodi wrote: > > > I am trying to learn how to create my own function in R. I want to > > create a function that can plot the polygons/regions/map given the > > coordinates of each region. The function should be able to colour the > > poplygons according to the data supplied ,for examples the means or > > rates of disease at a region/polygon. > > > You might want to take a look at package "maps". Or others mentioned on http://www.R-project.org/Rgeo, for example, see how the DCluster package plots disease rates, or look at plot.polylist() in the maptools package. The maps package does depend on the user building a geographical database first, rather than taking an arbitrary ring of coordinates as a polygon. Colouring is a class interval problem, which has to be done separately anyway - see the examples on the help pages for the relevant functions (hint - findInterval() is good at setting the colour vector for the polygons). Roger Bivand > > Uwe Ligges > > > > your advise will be highly appreciated. > > > > Thanks in advance for your help. > > > > Oarabile > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing arguments to FUN in lapply
Pingping Zheng wrote: Suppose I have a nx2 matrix of data, X, the following code generate density estimation for each column and plot them denlist <- apply(X, 2, density) par(mfrow=c(1,2)) lapply(denlist, plot) Does anyone know how to change the main title of each density plot to "var 1", "var 2" by passing optional argument "main"? I've tried lapply(denlist, plot, main=c("var 1", "var 2")) which generates two same titles "var 1/var 2" and "var 1/var 2" lapply(denlist, plot, main=list("var 1", "var 2")) which generates two same titles "var 1" Both are not I want. If the title is contained in denlist, you can specify a anonymous function, if not, use mapply or simply a for() loop. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Installation problem MacOS X
Hector L. Ayala-del-Rio wrote: R gurus I have tried to install the R 2.0.1 binary for OS X and although the installation was successful I can get the application going. When I double click the icon R tries to load (R window shows briefly) and it quits immediately. This behavior was described in this list before and nobody found the answer to the problem. If you try to load the x11 version by typing "R" at the command line it loads up with no problem. This means that the app is partially working and there are no permissions issue. The most interesting thing is if I log to a different account (Dummy) and I double click the application it loads with no problem. This makes me think that there has to be some type of user specific file or directory that is causing the gui to quit. Any suggestions on what file(s) could be affecting R? Thanks Hector ** Héctor L. Ayala-del-Río, Ph.D. Assistant Professor Department of Biology University of Puerto Rico at Humacao CUH postal station 100 road 908 Humacao, PR 00791 Ph: 787-850- x 9001 Fax: 787-850-9439 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html you have moved the R app already to it's final destination (instead of starting it from the mounted disk image)? I would try the "Console" utility (in /Applications/Utilities) to have a look at console.log and system.log (or inspect the logs directly: /private/var/log/system.log and /Library/Logs/Console/vdh/console.log) immediately _after_ an attempt to start the R app. probably it's a permission problem all the same. regards joerg ps: there is a R mailing list exclusively for OS X users: https://stat.ethz.ch/mailman/listinfo/r-sig-mac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing arguments to FUN in lapply
an indirect solution is the following: lapply(seq(along=denlist), function(i) plot(denlist[[i]], main=paste("var", i))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: "Pingping Zheng" <[EMAIL PROTECTED]> To: Sent: Friday, March 18, 2005 12:40 PM Subject: [R] passing arguments to FUN in lapply Suppose I have a nx2 matrix of data, X, the following code generate density estimation for each column and plot them denlist <- apply(X, 2, density) par(mfrow=c(1,2)) lapply(denlist, plot) Does anyone know how to change the main title of each density plot to "var 1", "var 2" by passing optional argument "main"? I've tried lapply(denlist, plot, main=c("var 1", "var 2")) which generates two same titles "var 1/var 2" and "var 1/var 2" lapply(denlist, plot, main=list("var 1", "var 2")) which generates two same titles "var 1" Both are not I want. -- Pingping Zheng Department of Mathematics and Statistics Fylde College Lancaster University Lancaster LA1 4YF UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Constrained Nelder-Mead
All, In looking at `optim', it doesn't appear that it is possible to impose nonlinear constraints on Nelder- Mead. I am sufficiently motivated to try to code something in C from scratch and try to call it from R Does anyone have some good references to barrier and/or penalization methods for Nelder-Mead? I would ideally like some papers with pseudocode for method(s) that are in some sense optimal for continuous functions. Thanks, Greg http://plato.la.asu.edu/topics/problems/nlores.html and look for COBYLA (Fortran 77, 90 and C code is available) best Adrian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE: problem with Dates
It seems that you have load the "survival" package date.mdy is a function from this one. In this function the "origin" of the time is the first day of 1970 in the base package the origin is the first day of 1960 it's very curious... Benjamin Esterni France From: "Vegard Andersen" <[EMAIL PROTECTED]> Subject: [R] Date conversion problem using "as.Date" To: "[EMAIL PROTECTED]" Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 Hello! My problem is that the Julian date "behind" my dates seems to be wrong. I will examplify my problem. t1 <- "1998-11-20" t2 <- as.Date(t1) # Here t2 is correctly "1998-11-20", but date.mdy(t2) $month [1] 11 $day [1] 19 $year [1] 1988 And indeed, if I write: fix(t2) then I get : structure(10550, class = "Date"). So the Julian date is 10550, which is "1988-11-19", not the correct "1998-11-20" If I instead of "as.Date" use "as.date", then things work ok. But I have not found out how to instruct "as.date" to handle dates from the 21st century. I hope that someone can help me, thanks in advance! -- Best regards, Vegard Andersen Institute of Community Medicine University of Tromso Tromso, Norway [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Convex hull line coordinates..
Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with "approx" to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the "yleft" or "yright" doesnt seem to help.. Any suggestions? Thank you in advance Achilleas. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing arguments to FUN in lapply
Pingping Zheng lancaster.ac.uk> writes: : : Suppose I have a nx2 matrix of data, X, the following code generate : density estimation for each column and plot them : : denlist <- apply(X, 2, density) : par(mfrow=c(1,2)) : lapply(denlist, plot) : : Does anyone know how to change the main title of each density plot : to "var 1", "var 2" by passing optional argument "main"? I've tried : : lapply(denlist, plot, main=c("var 1", "var 2")) : which generates two same titles "var 1/var 2" and "var 1/var 2" : : lapply(denlist, plot, main=list("var 1", "var 2")) : which generates two same titles "var 1" : : Both are not I want. : Try mapply instead of lapply: mapply(plot, denlist, main = paste("var", 1:2)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Changing label size in plot.dendrogram
Dear R friends, I have constructed an object of class 'dendrogram' using an own function, and I'm using the R function plot.dendrogram for visualizing it. It works fine, but I could not find out how to change the font size of edge and leaf labels. ?plot.dendrogram has shown me that the coloring of the edge labels can be changed using plot(my.dendrogram, edgePar=list(t.col='green')), but something like 't.cex' doesn't seem to exist. Any hints greatly appreciated. Best regards, Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing arguments to FUN in lapply
See Andy Liaw's and my suggestion to this post http://files.protsuggest.org/biocond/html/7818.html On Fri, 2005-03-18 at 11:40 +, Pingping Zheng wrote: > Suppose I have a nx2 matrix of data, X, the following code generate > density estimation for each column and plot them > > denlist <- apply(X, 2, density) > par(mfrow=c(1,2)) > lapply(denlist, plot) > > Does anyone know how to change the main title of each density plot > to "var 1", "var 2" by passing optional argument "main"? I've tried > > lapply(denlist, plot, main=c("var 1", "var 2")) > which generates two same titles "var 1/var 2" and "var 1/var 2" > > lapply(denlist, plot, main=list("var 1", "var 2")) > which generates two same titles "var 1" > > Both are not I want. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Non linear modeling
Hi, is there a way in R to fit a non linear model like y=x+exp(a*x)*eps where a is the parameter and eps is the error term? Thanks Angelo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Date conversion problem using "as.Date"
Vegard Andersen ism.uit.no> writes: : : Hello! : : My problem is that the Julian date "behind" my dates seems to be wrong. I : will examplify my problem. : : t1 <- "1998-11-20" : t2 <- as.Date(t1) : # Here t2 is correctly "1998-11-20", but : date.mdy(t2) : $month : [1] 11 : $day : [1] 19 : $year : [1] 1988 : : And indeed, if I write: fix(t2) then I get : structure(10550, class = : "Date"). So the Julian date is 10550, which is "1988-11-19", not the : correct "1998-11-20" : : If I instead of "as.Date" use "as.date", then things work ok. But I have : not found out how to instruct "as.date" to handle dates from the 21st : century. : : I hope that someone can help me, thanks in advance! : As already mentioned the "date" class in survival uses 1960 as its origin: R> as.date(0) [1] 1Jan60 whereas the "Date" class uses 1970: R> structure(0, class = "Date") [1] "1970-01-01" Regarding your other question you can use a 4 digit year: R> as.date("2Jan2001") [1] 2Jan2001 or: R> as.date.Date <- function(x) as.date(format(x), order = "ymd") R> as.date.Date(t2) [1] 20Nov98 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Non linear modeling
AFAIK most model fitting techniques will only deal with additive errors, not multiplicative ones. You might want to try fitting: log(y-x) = a*x + e which is linear. Andy > From: Angelo Secchi > > Hi, > is there a way in R to fit a non linear model like > > y=x+exp(a*x)*eps > > where a is the parameter and eps is the error term? > Thanks > Angelo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: non-linear model
if a and eps are parameters to be fitted X<-nls(y~x+exp(a*x)*eps, data=,start=list(a=,eps=)) Découvrez nos promotions exclusives "destination de la Tunisie, du Maroc, des Baléares et la Rép. Dominicaine sur Yahoo! Voyages : __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Ideal Computer and Software (A bit off topic)
I'd like to mention that if using the desktop applications such as MS Word, Excel, Powerpoint, email software, Acrobat Reader, etc. is important to you, then the Mac may be a better choice than a Linux box. Mac OS X lets you use all of those, and also work at the unix level, side by side and simultaneously, on the same machine. On a Mac you can run R either with a GUI analagous to that of R for Windows, or you can run it as a command line app, as on Linux. I can't help with performance comparison questions, or the 64 bit issue, I'm sorry to say. -Don At 11:41 AM -0800 3/17/05, [EMAIL PROTECTED] wrote: Hello everyone. This question might be a bit off topic, but I thought that (a) there couldn't be a better group to address my questions and (b) that others might find it useful too; It also might start an interesting discussion thread. I use R often for simulation purposes (which generally involve a lot of for() loops) and for most of my general work. I will be purchasing a new computing system soon, and I'm wondering the best way to go. I'm a Windows user now, and from what I know and have read about Linux, it is what I should be using (or possibly a Unix machine). I'm not wedded to a Windows system and I'm willing to put in the time to learn Linux if it would truly be beneficial. Is it the case that Linux offers so much more than Windows that it is definitely worth the switch? For the hardware issue, is it generally better to run R on a server and then connect to the server or on a stand alone computer (Obviously the performance would be related to the specific hardware, but if the hardware was essentially equal, would there be any advantage to either?). A server might have other users using competing with you for cpu cycles. A server might have a more reliable backup policy (or might not!). A server might or might not have security patches and OS upgrades done more promptly. If you need to transfer content from R (text output or graphics files) into reports or presentations, it might be easier with a local machine, depending on whether the server shares file systems. What seems to be better for using R on, an Intel, AMD, Unix, or Mac (which I suppose is now a Unix) processor? In terms of speed, again given the analogous hardware, is there an advantage to one of these? Does it make sense to get a 64 bit AMD processor, or is that just an overkill? Would R even make use of the 64 bit processing power? I'm very interested on any thoughts people have on this. I'm a big user of computers, but I'm not overly knowledgeable about their inner workings. Thanks and have a nice day, Ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to create a 'fit' plot
Dear List, As someone who is in the process of trying to migrate from Excel, I'd appreciate any help on this question: I have a data set and want to fit, say, three distributions to it. I would like to create a plot that shows my data points against all three fitted curves (estimated d.f.). Basically, I lookint to creat a plot that looks like the one presented in the attached paper (Figure 5, page 12): http://www.math.ethz.ch/~mcneil/ftp/astin.pdf Could you please show me, or point me to example code showing, how that can be done? Thanks, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RE: problem with Dates
On Fri, 18 Mar 2005, Benjamin Esterni wrote: It seems that you have load the "survival" package date.mdy is a function from this one. In this function the "origin" of the time is the first day of 1970 in the base package the origin is the first day of 1960 it's very curious... Well, it would be very curious if they defined the same class, but the base package defines "Date" and the survival package defines "date". There's no reason why they should use the same origin, but it will cause problems if you mix them up. -thomas Benjamin Esterni France From: "Vegard Andersen" <[EMAIL PROTECTED]> Subject: [R] Date conversion problem using "as.Date" To: "[EMAIL PROTECTED]" Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 Hello! My problem is that the Julian date "behind" my dates seems to be wrong. I will examplify my problem. t1 <- "1998-11-20" t2 <- as.Date(t1) # Here t2 is correctly "1998-11-20", but date.mdy(t2) $month [1] 11 $day [1] 19 $year [1] 1988 And indeed, if I write: fix(t2) then I get : structure(10550, class = "Date"). So the Julian date is 10550, which is "1988-11-19", not the correct "1998-11-20" If I instead of "as.Date" use "as.date", then things work ok. But I have not found out how to instruct "as.date" to handle dates from the 21st century. I hope that someone can help me, thanks in advance! -- Best regards, Vegard Andersen Institute of Community Medicine University of Tromso Tromso, Norway [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Installation problem MacOS X
Hector, By application, you mean R or the R + GUI (R.app)? Please check if you have an existing .RData file in the directory where you start R. If it's R.app and X11 was used when .RData was saved, X11 needs to run when the restore takes place. Mac OS issues might be better raised on R-SIG-Mac ([EMAIL PROTECTED]). Regards, Rob On Mar 18, 2005, at 3:16 AM, Hector L. Ayala-del-Rio wrote: R gurus I have tried to install the R 2.0.1 binary for OS X and although the installation was successful I can get the application going. When I double click the icon R tries to load (R window shows briefly) and it quits immediately. This behavior was described in this list before and nobody found the answer to the problem. If you try to load the x11 version by typing "R" at the command line it loads up with no problem. This means that the app is partially working and there are no permissions issue. The most interesting thing is if I log to a different account (Dummy) and I double click the application it loads with no problem. This makes me think that there has to be some type of user specific file or directory that is causing the gui to quit. Any suggestions on what file(s) could be affecting R? Thanks Hector ** Héctor L. Ayala-del-Río, Ph.D. Assistant Professor Department of Biology University of Puerto Rico at Humacao CUH postal station 100 road 908 Humacao, PR 00791 Ph: 787-850- x 9001 Fax: 787-850-9439 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] slow computation of mixed ANOVA using aov
Dear R-help list, I am trying to do a mixed ANOVA on a 8960 x 5 dataframe. I have 3 factors for which I want to test all main effects and interactions : f1 (40 levels), f2 (7 levels), and f3 (4 levels). I also have a subject factor, subject, and a dependent variable, dv. Some more information about the factors: f2 is a between-subject factor. That is, for each level of f2 there are 8 nested levels of the subject factor. For example, levels 1-8 of subject are nested in level 1 of f2. Levels 9-16 of subject are nested in level 2 of f2. In other words, the subjects that participated in any level of f2 are different from the subjects that participated in any other level of f2. In contrast, f1 and f3 are within-subject factors. That is, for any one of the 56 subjects, we have a 160 medians corresponding to each condition from a complete crossing of factors f1 and f2. While it is true that we do have replicate observations for any subject in each of these conditions, we take the median of those values and operate as if there is only a single observation for each subject in each of the 160 within-subject conditions. Below is code that will generate dataframe d, which is just like the one I am working with: f1<-gl(40,1,8960,ordered=T) f2<-gl(7,1280,8960,ordered=T) f3<-gl(4,40,8960,ordered=T) subject<-gl(56,160,8960,ordered=T) dv<-rnorm(8960,mean=500,sd=50) d <- data.frame(f1,f2,f3,f4,dv) To run the mixed ANOVA I use the following call (modeled after J. Baron): aov(dv~f1*f2*f3+Error(subject/(f1*f2)),data=d) WARNING: Exert caution when running the aov command. I have run the exact same command on Windows and Unix machines (each with 1GB of RAM; allocated up to 3 or 4GB of memory for the analysis ) and it has taken many, many hours to finish. That said, this is not a new problem posted on the R-help list. There are several posts where analysts have run into similar problems. My general impression of these posts, and correct me if I am wrong, is that because aov is a wrapper around lm, the extra time is required to build and manipulate a design matrix (via qr decomposition) that is 8960 x several thousand columns large! Is that so? It seems fitting because if I call aov with only a single factor, then it returns in a few seconds. In order to test if the computational slowness was something unique to R, I ran the same analysis, including all 3 factors, in SPSS. To my surprise SPSS returned almost instantaneously. I do not know much about the algorithm in SPSS, but I suspect it may be calculating condition means and sums of squares rather than generating a design matrix. Does that sound plausible? At this point I am a dedicated R user. However, I do the kind of analysis described above quite often. It is important that my statistical package be able to handle it more efficiently than what I have been able to get R to do at this point. Am I doing anything obviously wrong? Is there a method in R that more closely resembles the algorithm used in SPSS? If not, are there any other methods R has to do these kind of analyses? Could I split up the analysis in some principled way to ease the processing demand on R? Thanks in advanvce for any further insight into this issue, Steve Lacey [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non linear modeling
then is the nls function can deal the problem as Guillaume STORCHI mentioned in the last post? [X<-nls(y~x+exp(a*x)*eps, data=,start=list(a=,eps=))] or just can solve the problem as:log(y-x) = a*x + e? On Fri, 18 Mar 2005 08:56:38 -0500 "Liaw, Andy" <[EMAIL PROTECTED]> wrote: > AFAIK most model fitting techniques will only deal with additive errors, not > multiplicative ones. You might want to try fitting: > > log(y-x) = a*x + e > > which is linear. > > Andy > > > From: Angelo Secchi > > > > Hi, > > is there a way in R to fit a non linear model like > > > > y=x+exp(a*x)*eps > > > > where a is the parameter and eps is the error term? > > Thanks > > Angelo > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Non linear modeling
That's treating eps as a parameter in the model. If I read your question right, that's not what you want. Andy > From: ronggui [mailto:[EMAIL PROTECTED] > > then is the nls function can deal the problem as Guillaume > STORCHI mentioned in the last post? [X<-nls(y~x+exp(a*x)*eps, > data=,start=list(a=,eps=))] > or just can solve the problem as:log(y-x) = a*x + e? > > > > On Fri, 18 Mar 2005 08:56:38 -0500 > "Liaw, Andy" <[EMAIL PROTECTED]> wrote: > > > AFAIK most model fitting techniques will only deal with > additive errors, not > > multiplicative ones. You might want to try fitting: > > > > log(y-x) = a*x + e > > > > which is linear. > > > > Andy > > > > > From: Angelo Secchi > > > > > > Hi, > > > is there a way in R to fit a non linear model like > > > > > > y=x+exp(a*x)*eps > > > > > > where a is the parameter and eps is the error term? > > > Thanks > > > Angelo > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > > http://www.R-project.org/posting-guide.html > > > > > > > > > > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] How to create a 'fit' plot
On 18-Mar-05 R_xprt_wannabe wrote: > Dear List, > > As someone who is in the process of trying to migrate > from Excel, I'd appreciate any help on this question: > > I have a data set and want to fit, say, three > distributions to it. I would like to create a plot > that shows my data points against all three fitted > curves (estimated d.f.). Basically, I lookint to > creat a plot that looks like the one presented in the > attached paper (Figure 5, page 12): > > http://www.math.ethz.ch/~mcneil/ftp/astin.pdf > > > Could you please show me, or point me to example code > showing, how that can be done? You can do something on the lines of: plot(x,empDF,pch=".") ## for the empirical plot of x lines(x0,GPD,lty="solid") ## for the GPD curve lines(x0,Pareto,lty="dashed") ## for the Pareto curve lines(x0,LogNormal,lty="dotdash") ## for the LogNormal curve where x0 is a vector of (fairly finely spaced) x-values, and LogNormal, Pareto and GPD are the corresponding y-values (at each x0) for the corresponding curves. Or the latter could be functions which computed the y-values, given the x-values, in which case you might use lines(x0,GPD(x0),lty="solid") ## for the GPD curve etc. Since you're apparently beginning with R, you've encountered one of the more deeply buried (yet commonly required) aspects of R, namely how the details of a plot are set up. You can consult the help on 'plot' and 'lines' with ?plot ?lines but it takes a bit of poking around to find that you need to look up ?par to find the details of things like 'lty' as used above. You may also need to make sure that you get the axes spanning over good ranges by making your first command plot(x,estDF,pch=".",xlim=c(a,b),ylim=c(c,d)) where a and b are the lower and upper limits for x, and c and d are those for y, since otherwise 'plot' will choose these limits in its own way depending on the ranges of values in x and in empDF, which may not be suitable for proper display of the other graphs. You can omit either or both of 'xlim' and 'ylim'. Whatever you do about the limits, however, they will be fixed once and for all once the first plot has been drawn. Hoping this helps, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 18-Mar-05 Time: 16:17:12 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] glm - poisson
i think that is ok. "when a response count n(i) has index equal to t(i),the sample rate is n(i)/t(i),its expected value is u(i)/t(i)..a loglinear model for theexpeted rate has form log(u(i)/t(i))=a+bx"(agresti,2002) this model can use glm-poisson with a offset term to estimate On Thu, 17 Mar 2005 15:22:02 -0800 (PST) Oli <[EMAIL PROTECTED]> wrote: > Hello, > > I have a question on glm - poisson. I would like to > fit a model on proportion of counts with some factors, > and I decided to use glm - poisson because count data > is essentially related to poisson. However, since I > need to deal with proportion, and glm - poisson does > not allow non-integer responses, I am thinking of > adding an offset term = log(total). Is it the right > approach to it? or should I use quasi-poisson family, > or should I even use weights? > > Thanks for your help! > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Bivariate normal distribution and correlation
Suppose I know the value of cumulative bivariate standard normal distribution. How can I solve correlation between variables? Pekka - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Pb with ks.test pvalue
Hello, While doing test of normality under R and SAS, in order to prove the efficiency of R to my company, I notice that Anderson Darling, Cramer Van Mises and Shapiro-Wilk tests results are quite the same under the two environnements, but the Kolmogorov-smirnov p-value really is different. Here is what I do: > ks.test(w,pnorm,mean(w),sd(w)) One-sample Kolmogorov-Smirnov test data: w D = 0.2143, p-value = 0.3803 alternative hypothesis: two.sided > w [1] 3837 3334 2208 1745 2576 3208 3746 3523 3430 3480 3116 3428 2184 2383 3500 3866 3542 [18] 3278 SAS results: Kolmogorov-Smirnov D 0.214278 Pr > D 0.0271 Why is the p-value so high under R? Much higher than with other tests. Best regards, Anthony Landrevie (French Student) - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Basic questions about RMySQL
Hello, Please forget me if I am asking something that is well documented. I have read documentation but there are points that are not clear for me. I am not expert in R nor Databases, but if someone direct me to a tutorial, I will appreciate it.. 1. In my understanding, I can install and use RMySQL withouth having to install MySQL in my PC, to have access to and to create new tables . Is this right? 2. I have created a c:\my.cnf file to access a database I have, but withouth installing the server, where I can define the user, password and host to establish a connection? Thanks in advance --- Jorge de la Vega Gongora | Telefono: (525) 5268 8379 Investigador | Fax: (525) 5268 8481 Banco de Mexico | email: [EMAIL PROTECTED] Planeación y Programación de Emisión | web:http://www.stat.umn.edu/~jvega Calzada Legaria 691 Módulo IV| Col. Irrigación 11500| __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lme user-defined correlation structures??
Could somebody help with the definition of new correlation structure for use with a linear mixed-effects model (package nlme). Specifically, I want to define a Toeplitz type correlation structure, but due to my inexperience with programming in R, I feel a bit overwhelmed with the task at hand. I understand that you can start with a function like corAR1 as template, but I have no idea how I would define the methods (coef, corMatrix, and initialize) in this context. An example of code for a user-defined correlation structure would be very helpful. I did a search on Google and in the R-help archives, but have not found much in terms of hints and specific examples for user defined correlation structures. Thank you in advance! Michael Jerosch-Herold __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RSPython
Hi, where is the latest version of the RSPython library? Is it compatible with the current stable release of R? Thanks, Darren __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to show which variables include in plot of classification tree
Dear all For my research, I am learning classification now. I was trying some example about classification tree pakages, such as tree and rpart, for instance, in Pima.te dataset have 8 variables (include class=type): library(rpart) library(datasets) pima.rpart <- rpart(type ~ npreg+glu+bp+skin+bmi+ped+age,data=Pima.te, method='class') plot(pima.rpart, uniform=TRUE) text(pima.rpart) summary(pima.rpart) In the result I found only 5 variables: npreg, glu, bmi, ped, and age were showing in the plot. Now, I have 50 variables in my dataset. The result my classification tree very difficult to know which variables showing in the plot. Are there any trick which variables are showing in plot. Thanks for your help. Muhammad Subianto __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] extract rows in dataframe with duplicated column values
Thank you very much to Andy Liaw, Rob J Goedman and Marc Schwartz for taking their time to solve my problem. I've learned in many other occasions from useful tips coming from all 3 of them and it just happened once again. You got to love this mailing list... subset(x, a %in% a[duplicated(a)]) works in all cases and it's the simplest, but as always all the solutions made me understand a little better the R concepts and functions. I would suggest to include this in the help pages for duplicated. Also useful might be: subset(x, !a %in% a[duplicated(a)]) giving all rows that don't have any duplicated again thanks for all help in this mailing list Here's one more possibility: > subset(x, a %in% a[duplicated(a)]) a b 2 2 10 3 2 10 4 3 10 5 3 10 6 3 10 HTH, Marc Schwartz On Thu, 2005-03-17 at 22:25 -0500, Liaw, Andy wrote: OK, strike one... Here's my second try: > cnt <- table(x[,1]) > v <- as.numeric(names(cnt[cnt > 1])) > v [1] 2 3 > x[x[,1] %in% v, ] a b 2 2 10 3 2 10 4 3 10 5 3 10 6 3 10 Andy > From: Liaw, Andy > > Does this work for you? > > > x[table(x[,1]) > 1,] > a b > 2 2 10 > 3 2 10 > 5 3 10 > 6 3 10 > > Andy > > > From: Tiago R Magalhaes > > > > Hi > > > > I want to extract all the rows in a data frame that have duplicates > > for a given column. > > I would expect this question to come up pretty often but I have > > researched the archives and surprisingly couldn't find anything. > > The best I can come up with is: > > > > x <- data.frame(a=c(1,2,2,3,3,3), b=10) > > xdup1 <- duplicated(x[,1]) > > xdup2 <- duplicated(x[,1][nrow(x):1])[nrow(x):1] > > xAllDups <- x[(xdup1+xdup2)!=0,] > > > > This seems to work, but it's so convoluted that I'm sure there's a > > better method. > > Thanks for any help and enlightenment > > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Basic questions about RMySQL
1. No way. You must have MySQL installed on your computer. 2. You must install the server. For details, see http://dev.mysql.com/doc/mysql/en/index.html . For portability, I would suggest that you run MySQL in the shell (ignore the GUIs) and save the syntax for adding users, creating tables etc. This will likely take more time when you first do it, but if you have to move to another computer later on, you can setup the new MySQL installation very quickly and easily. hth, b. -Original Message- From: De la Vega Góngora Jorge [mailto:[EMAIL PROTECTED] Sent: Friday, March 18, 2005 11:58 AM To: r-help@stat.math.ethz.ch Subject: [R] Basic questions about RMySQL Hello, Please forget me if I am asking something that is well documented. I have read documentation but there are points that are not clear for me. I am not expert in R nor Databases, but if someone direct me to a tutorial, I will appreciate it.. 1. In my understanding, I can install and use RMySQL withouth having to install MySQL in my PC, to have access to and to create new tables . Is this right? 2. I have created a c:\my.cnf file to access a database I have, but withouth installing the server, where I can define the user, password and host to establish a connection? Thanks in advance --- Jorge de la Vega Gongora | Telefono: (525) 5268 8379 Investigador | Fax: (525) 5268 8481 Banco de Mexico | email: [EMAIL PROTECTED] Planeación y Programación de Emisión | web: http://www.stat.umn.edu/~jvega Calzada Legaria 691 Módulo IV| Col. Irrigación 11500| __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RSPython
Darren Weber wrote: Hi, where is the latest version of the RSPython library? Is it compatible with the current stable release of R? What about clicking the first item returned when Google'ing for "RSPython"? Uwe Ligges Thanks, Darren __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Basic questions about RMySQL
> 1. No way. You must have MySQL installed on your computer. In fact this is not true. You can use a MySQL server installed somewhere else on the network. --- bogdan romocea <[EMAIL PROTECTED]> wrote: > 1. No way. You must have MySQL installed on your computer. > > 2. You must install the server. For details, see > http://dev.mysql.com/doc/mysql/en/index.html . > For portability, I would suggest that you run MySQL in the shell > (ignore the GUIs) and save the syntax for adding users, creating > tables > etc. This will likely take more time when you first do it, but if you > have to move to another computer later on, you can setup the new > MySQL > installation very quickly and easily. > > hth, > b. > > > -Original Message- > From: De la Vega Góngora Jorge [mailto:[EMAIL PROTECTED] > Sent: Friday, March 18, 2005 11:58 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Basic questions about RMySQL > > > Hello, > > Please forget me if I am asking something that is well documented. I > have read documentation but there are points that are not clear for > me. > I am not expert in R nor Databases, but if someone direct me to a > tutorial, I will appreciate it.. > > 1. In my understanding, I can install and use RMySQL withouth having > to install MySQL in my PC, to have access to and to create new tables > . > Is this right? > > 2. I have created a c:\my.cnf file to access a database I have, but > withouth installing the server, where I can define the user, password > and host to establish a connection? > > Thanks in advance > > > --- > Jorge de la Vega Gongora | Telefono: (525) 5268 8379 > Investigador | Fax: (525) 5268 8481 > Banco de Mexico | email: [EMAIL PROTECTED] > Planeación y Programación de Emisión | web: > http://www.stat.umn.edu/~jvega > Calzada Legaria 691 Módulo IV| > Col. Irrigación 11500| > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > __ > Do you Yahoo!? > http://smallbusiness.yahoo.com/resources/ > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to show which variables include in plot of classification tree
Muhammad Subianto wrote: Dear all For my research, I am learning classification now. I was trying some example about classification tree pakages, such as tree and rpart, for instance, in Pima.te dataset have 8 variables (include class=type): library(rpart) library(datasets) pima.rpart <- rpart(type ~ npreg+glu+bp+skin+bmi+ped+age,data=Pima.te, method='class') plot(pima.rpart, uniform=TRUE) text(pima.rpart) summary(pima.rpart) In the result I found only 5 variables: npreg, glu, bmi, ped, and age were showing in the plot. Now, I have 50 variables in my dataset. The result my classification tree very difficult to know which variables showing in the plot. Are there any trick which variables are showing in plot. 1. Please read a good book on classification. Also, you might want to take a look into Breiman et al. (1984) cited in ?rpart. 2. rpart does variable selection when growing the tree, so you should not expect to find all 50 variables in the plot. See, e.g., ?rpart.control 3. You have specified the formula "type ~ npreg + glu + bp + skin + bmi + ped + age", so in particular you cannot expect to get more variables than "npreg + glu + bp + skin + bmi + ped + age" Uwe Ligges Thanks for your help. Muhammad Subianto __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Basic questions about RMySQL
bogdan romocea wrote: 1. No way. You must have MySQL installed on your computer. 2. You must install the server. For details, see http://dev.mysql.com/doc/mysql/en/index.html . For portability, I would suggest that you run MySQL in the shell (ignore the GUIs) and save the syntax for adding users, creating tables etc. This will likely take more time when you first do it, but if you have to move to another computer later on, you can setup the new MySQL installation very quickly and easily. Can you tell us any reason why the server should run on the same machine R is running on? Uwe Ligges hth, b. -Original Message- From: De la Vega Góngora Jorge [mailto:[EMAIL PROTECTED] Sent: Friday, March 18, 2005 11:58 AM To: r-help@stat.math.ethz.ch Subject: [R] Basic questions about RMySQL Hello, Please forget me if I am asking something that is well documented. I have read documentation but there are points that are not clear for me. I am not expert in R nor Databases, but if someone direct me to a tutorial, I will appreciate it.. 1. In my understanding, I can install and use RMySQL withouth having to install MySQL in my PC, to have access to and to create new tables . Is this right? 2. I have created a c:\my.cnf file to access a database I have, but withouth installing the server, where I can define the user, password and host to establish a connection? Thanks in advance --- Jorge de la Vega Gongora | Telefono: (525) 5268 8379 Investigador | Fax: (525) 5268 8481 Banco de Mexico | email: [EMAIL PROTECTED] Planeación y Programación de Emisión | web: http://www.stat.umn.edu/~jvega Calzada Legaria 691 Módulo IV| Col. Irrigación 11500| __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non linear modeling
You are right. eps in my model is not a parameter but the error term. Also the linearization doesn't solve the problem, since sometimes you cannot take logs. Any other ideas? Thanks On Fri, 18 Mar 2005 11:21:12 -0500 "Liaw, Andy" <[EMAIL PROTECTED]> wrote: > That's treating eps as a parameter in the model. If I read your question > right, that's not what you want. > > Andy > > > From: ronggui [mailto:[EMAIL PROTECTED] > > > > then is the nls function can deal the problem as Guillaume > > STORCHI mentioned in the last post? [X<-nls(y~x+exp(a*x)*eps, > > data=,start=list(a=,eps=))] > > or just can solve the problem as:log(y-x) = a*x + e? > > > > > > > > On Fri, 18 Mar 2005 08:56:38 -0500 > > "Liaw, Andy" <[EMAIL PROTECTED]> wrote: > > > > > AFAIK most model fitting techniques will only deal with > > additive errors, not > > > multiplicative ones. You might want to try fitting: > > > > > > log(y-x) = a*x + e > > > > > > which is linear. > > > > > > Andy > > > > > > > From: Angelo Secchi > > > > > > > > Hi, > > > > is there a way in R to fit a non linear model like > > > > > > > > y=x+exp(a*x)*eps > > > > > > > > where a is the parameter and eps is the error term? > > > > Thanks > > > > Angelo > > > > > > > > __ > > > > R-help@stat.math.ethz.ch mailing list > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > PLEASE do read the posting guide! > > > > http://www.R-project.org/posting-guide.html > > > > > > > > > > > > > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > > > > > > -- > Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Basic questions about RMySQL
I certainly can't; I initially misunderstood the question. If connecting to MySQL is the problem, then you need to know the user ID, the domain and the password. Ask your DB administrator for help. Here's an example that works for me (local MySQL installation): require(DBI) require(RMySQL) MySQL(max.con = 16, fetch.default.rec = 5000, force.reload = F) drv <- dbDriver("MySQL") con <- dbConnect(drv,username="userid",password="pswd",dbname="db") dbListTables(con) --- Uwe Ligges <[EMAIL PROTECTED]> wrote: > bogdan romocea wrote: > > > 1. No way. You must have MySQL installed on your computer. > > > > 2. You must install the server. For details, see > > http://dev.mysql.com/doc/mysql/en/index.html . > > For portability, I would suggest that you run MySQL in the shell > > (ignore the GUIs) and save the syntax for adding users, creating > tables > > etc. This will likely take more time when you first do it, but if > you > > have to move to another computer later on, you can setup the new > MySQL > > installation very quickly and easily. > > Can you tell us any reason why the server should run on the same > machine > R is running on? > > Uwe Ligges > > > > hth, > > b. > > > > > > -Original Message- > > From: De la Vega Góngora Jorge [mailto:[EMAIL PROTECTED] > > Sent: Friday, March 18, 2005 11:58 AM > > To: r-help@stat.math.ethz.ch > > Subject: [R] Basic questions about RMySQL > > > > > > Hello, > > > > Please forget me if I am asking something that is well documented. > I > > have read documentation but there are points that are not clear for > me. > > I am not expert in R nor Databases, but if someone direct me to a > > tutorial, I will appreciate it.. > > > > 1. In my understanding, I can install and use RMySQL withouth > having > > to install MySQL in my PC, to have access to and to create new > tables . > > Is this right? > > > > 2. I have created a c:\my.cnf file to access a database I have, > but > > withouth installing the server, where I can define the user, > password > > and host to establish a connection? > > > > Thanks in advance > > > > > > --- > > Jorge de la Vega Gongora | Telefono: (525) 5268 8379 > > Investigador | Fax: (525) 5268 8481 > > Banco de Mexico | email: [EMAIL PROTECTED] > > Planeación y Programación de Emisión | web: > > http://www.stat.umn.edu/~jvega > > Calzada Legaria 691 Módulo IV| > > Col. Irrigación 11500| > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Basic questions about RMySQL
Thanks for your help. having MySQL server locally (or in some other place) should solve the configuration problem. By the way, I should have written forgive, no forget. Forgive me. Jorge de la Vega -Mensaje original- De: bogdan romocea [mailto:[EMAIL PROTECTED] Enviado el: Viernes, 18 de Marzo de 2005 01:11 PM Para: Uwe Ligges; De la Vega Góngora Jorge CC: r-help@stat.math.ethz.ch Asunto: Re: [R] Basic questions about RMySQL I certainly can't; I initially misunderstood the question. If connecting to MySQL is the problem, then you need to know the user ID, the domain and the password. Ask your DB administrator for help. Here's an example that works for me (local MySQL installation): require(DBI) require(RMySQL) MySQL(max.con = 16, fetch.default.rec = 5000, force.reload = F) drv <- dbDriver("MySQL") con <- dbConnect(drv,username="userid",password="pswd",dbname="db") dbListTables(con) --- Uwe Ligges <[EMAIL PROTECTED]> wrote: > bogdan romocea wrote: > > > 1. No way. You must have MySQL installed on your computer. > > > > 2. You must install the server. For details, see > > http://dev.mysql.com/doc/mysql/en/index.html . For portability, I > > would suggest that you run MySQL in the shell (ignore the GUIs) and > > save the syntax for adding users, creating > tables > > etc. This will likely take more time when you first do it, but if > you > > have to move to another computer later on, you can setup the new > MySQL > > installation very quickly and easily. > > Can you tell us any reason why the server should run on the same > machine R is running on? > > Uwe Ligges > > > > hth, > > b. > > > > > > -Original Message- > > From: De la Vega Góngora Jorge [mailto:[EMAIL PROTECTED] > > Sent: Friday, March 18, 2005 11:58 AM > > To: r-help@stat.math.ethz.ch > > Subject: [R] Basic questions about RMySQL > > > > > > Hello, > > > > Please forget me if I am asking something that is well documented. > I > > have read documentation but there are points that are not clear for > me. > > I am not expert in R nor Databases, but if someone direct me to a > > tutorial, I will appreciate it.. > > > > 1. In my understanding, I can install and use RMySQL withouth > having > > to install MySQL in my PC, to have access to and to create new > tables . > > Is this right? > > > > 2. I have created a c:\my.cnf file to access a database I have, > but > > withouth installing the server, where I can define the user, > password > > and host to establish a connection? > > > > Thanks in advance > > > > > > --- > > Jorge de la Vega Gongora | Telefono: (525) 5268 8379 > > Investigador | Fax: (525) 5268 8481 > > Banco de Mexico | email: [EMAIL PROTECTED] > > Planeación y Programación de Emisión | web: > > http://www.stat.umn.edu/~jvega > > Calzada Legaria 691 Módulo IV| > > Col. Irrigación 11500| > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non linear modeling
What do you want to minimize? Can you write a function to compute eps given x, y, and a? Given that, you can then write another function to compute the objective function you want to minimize. If "a" is a scalar, compute the objective function for a range of values of "a" and plot. If you want numerical precision, read the help file for "optim", work the examples until you understand enough to see how to feed your objective function with a starting value to "optim". If you still can't figure it out, please make an attempt, then read the posting guide "http://www.R-project.org/posting-guide.html";, and prepare a follow-up question as needed. (In a discussion on and off this list earlier this week, several people confirmed that they had solved many problems following this posting guide. It may not be as good as Polya's famous "How to Solve It", but it's pretty good.) hope this helps. spencer graves Angelo Secchi wrote: You are right. eps in my model is not a parameter but the error term. Also the linearization doesn't solve the problem, since sometimes you cannot take logs. Any other ideas? Thanks On Fri, 18 Mar 2005 11:21:12 -0500 "Liaw, Andy" <[EMAIL PROTECTED]> wrote: That's treating eps as a parameter in the model. If I read your question right, that's not what you want. Andy From: ronggui [mailto:[EMAIL PROTECTED] then is the nls function can deal the problem as Guillaume STORCHI mentioned in the last post? [X<-nls(y~x+exp(a*x)*eps, data=,start=list(a=,eps=))] or just can solve the problem as:log(y-x) = a*x + e? On Fri, 18 Mar 2005 08:56:38 -0500 "Liaw, Andy" <[EMAIL PROTECTED]> wrote: AFAIK most model fitting techniques will only deal with additive errors, not multiplicative ones. You might want to try fitting: log(y-x) = a*x + e which is linear. Andy From: Angelo Secchi Hi, is there a way in R to fit a non linear model like y=x+exp(a*x)*eps where a is the parameter and eps is the error term? Thanks Angelo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Bivariate normal distribution and correlation
How about the following: Suppose you have the bivariate cumulative distribution function (cdf) for (X, Y). 1. From this first compute the marginal cdf for X. The median will give you EX, and you can get sigmaX = IQR/(2*qnorm(0.75)), where IQR = interquartile range = diff(quantile(..., c(0.25, 0.75))). Repeat to get EY and sigmaY. 2. Next compute the median of the conditional distribution for Y given X = (EX+sigmaX). This is E(Y|X=EX+sigmaX) = EY+rho*sigmaY. [The regression equation is E(Y|x) = EY + rho*(x-EX)*sigmaY/sigmaX, and (x-EX) = sigmaX by choice.] From this, you can now solve for rho. You may also wish to repeat this for EX-sigmaX as a check. If you have trouble translating this into R code, please make an attempt, then read the posting guide "http://www.R-project.org/posting-guide.html";, and prepare a follow-up question as needed. (In a discussion on and off this list earlier this week, several people confirmed that they had solved many problems following this posting guide. It may not be as good as Polya's famous "How to Solve It", but it's pretty good.) hope this helps. spencer Pekka Vimpari wrote: Suppose I know the value of cumulative bivariate standard normal distribution. How can I solve correlation between variables? Pekka - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to create a 'fit' plot
If you know the exact formulae for the distribution, replace it with 'f' function below. You may want to use the log="x" in the plot. f <- function(x) 1 - exp( -x/20 ); plot( f, xlim=c(0,100), ylim=c(0.5, 1) ) Otherwise generate sufficient realisations from it and fit a line as below x <- seq(-5,5,by=0.01) y <- dt(x, 5) plot( x, y, type="l", col=8 ) Now you can overlay the observations as points obs.x <- rnorm(50) obs.y <- runif(50) points( obs.x, obs.y, pch=18) You might want to see help("plot"), help("par") or demo(graphics) as well as http://www.r-project.org/other-docs.html Regards, Adai On Fri, 2005-03-18 at 07:18 -0800, R_xprt_wannabe wrote: > Dear List, > > As someone who is in the process of trying to migrate > from Excel, I'd appreciate any help on this question: > > I have a data set and want to fit, say, three > distributions to it. I would like to create a plot > that shows my data points against all three fitted > curves (estimated d.f.). Basically, I lookint to > creat a plot that looks like the one presented in the > attached paper (Figure 5, page 12): > > http://www.math.ethz.ch/~mcneil/ftp/astin.pdf > > > Could you please show me, or point me to example code > showing, how that can be done? > > Thanks, > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Hmisc & latex
Hmisc includes a latex function which typesets objects in latex. A great time saver. I am using it to create a large number of tables in a loop in conjuction with prettyNum to place '000s separators in the numbers (i.e. 1,000,000 not 100). This converts the numbers to strings. The Hmisc/latex default is to left justify characters - which doesn't work in this case. Hmisc/latex seems to have lots of options, but not one that I was expecting. I am having trouble specifying column justification. I can specify justification for column labels, column label groups, row labels, even table justification --- but not the justification of the data within the table. I am convinced that I am missing something. Am I? or this just a "yet to be coded" feature. Thanks in advance. Michaell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Quantiles of data in a contingency table
On Thu, 17 Mar 2005 10:29:16 +0200, Markus Jäntti <[EMAIL PROTECTED]> wrote: > Matt Mohebbi wrote: > > Hello, > > > > I have data of the following form: > > > > > >>data <- data.frame(type=c("c","d","e"), size=c(10,20,30), count=c(20,10,5)) > >>data > > > > type size count > > 1c 1020 > > 2d 2010 > > 3e 30 5 > > > > I would like to compute the quantiles of size given the counts. For > > instance, in this example, the median size would be 10. Is there an > > easy way of doing this? > > One at least is to the function wtd.median [and wtd.quantile] in package > Hmisc by Frank Harrell. > > install.packages("Hmisc") > library(Hmisc) > wtd.median(data$size, data$weights) > > is likely a route to get you what you want. Thanks. This worked great. I now would like to do a boxplot on a subset of this data. One way of doing this would be to create a repeated entry form of the above data frame. This would look like: type size 1c 10 2c 10 3c 10 4c 10 5c 10 6c 10 7c 10 8c 10 9c 10 10c 10 11c 10 12c 10 13c 10 14c 10 15c 10 16c 10 17c 10 18c 10 19c 10 20c 10 (and similarly for types d and e) I cannot seem to find this in R or Hmisc. Any ideas? Thanks, Matt > regards, > > markus > > > > Is there a good way to deal with data in this format in general? Much > > of R seems to center around having an entry for each item. This > > question (http://www.r-project.org/nocvs/mail/r-help/2000/0102.html) > > seems to be related but no one provided an answer. > > > > Thanks, > > Matt > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > -- > Markus Jantti > Abo Akademi University > [EMAIL PROTECTED] > http://www.iki.fi/~mjantti > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Basic questions about RMySQL
De la Vega Góngora Jorge wrote: Hello, Please forget me if I am asking something that is well documented. I have read documentation but there are points that are not clear for me. I am not expert in R nor Databases, but if someone direct me to a tutorial, I will appreciate it.. 1. In my understanding, I can install and use RMySQL withouth having to install MySQL in my PC, to have access to and to create new tables . Is this right? I doubt very mucg if RMySQP will be of any use without having MySQL installed! Kjetil 2. I have created a c:\my.cnf file to access a database I have, but withouth installing the server, where I can define the user, password and host to establish a connection? Thanks in advance --- Jorge de la Vega Gongora | Telefono: (525) 5268 8379 Investigador | Fax: (525) 5268 8481 Banco de Mexico | email: [EMAIL PROTECTED] Planeación y Programación de Emisión | web:http://www.stat.umn.edu/~jvega Calzada Legaria 691 Módulo IV| Col. Irrigación 11500| __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra -- No virus found in this outgoing message. Checked by AVG Anti-Virus. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Is there such a function that can sort a table according to one column?
when I sort one column, other columns will change with it. otherwise, I can get index from sort() and write a function. Better idea? Thanks, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Is a .R script file name available inside the script?
Hi, if we have a file called Rscript.R that contains the following, for example: x <- 1:100 outfile = "Rscript.Rout" sink(outfile) print(x) and then we run >> source("Rscript.R") we get an output file called Rscript.Rout - great! Is there an internal variable, something like .Platform, that holds the script name when it is being executed? I would like to use that variable to define the output file name. Best, Darren __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] plotmath question
R listers: I have been foiled by plotmath! (in R 2.01,Windows 2000) The task: Plot a normal density and label the ticks as mu - 3 sigma, mu - 2 sigma, , mu + 3 sigma, where the mu's and sigmas appear as Greek symbols, of course. The following code does this: x<-seq(-3,to=3,by=.01) y<-dnorm(x) plot(x,y,type='h',col='lightblue',axes=FALSE) lines(x,y,col='darkblue') axis(2) for(i in seq(-3,to=3)) axis(1,at=i, lab=switch(sign(i)+2, eval(substitute(expression(mu-j*sigma),list(j=-i))), expression(mu), eval(substitute(expression(mu+j*sigma),list(j=i) box() However, I think the code in the for loop is ugly and probably means that I'm doing it wrong. In particular: 1) Is there a neat way to use one axis() call and a vector (of expressions?) for the lab=argument? 2) The plotmath Help state that expressions can be used for axis labels, so I would have expected the above to work without the eval()call -- but it does not. Would someone kindly explain to me why not -- i.e., what I have misunderstood. That is, to be clear, why does the following not work: for(i in seq(-3,to=3)) axis(1,at=i, lab=switch(sign(i)+2, substitute(expression(mu-j*sigma),list(j=i)), expression(mu), substitute(expression(mu+j*sigma),list(j=i Any further ideas,insights, or pointers to reference materials would also be appreciated. Many thanks. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Is there such a function that can sort a table according to one column?
See ?order, which is pointed to in the `See Also' section of ?sort. Andy > From: Terry Mu > > when I sort one column, other columns will change with it. > > otherwise, I can get index from sort() and write a function. > > Better idea? Thanks, > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sweave/margin
Hi! I am currently using Sweave for writing my bachelor thesis - and I have a problem: I am using a LaTeX style (report) with quite big margin spaces. The Sweave generated LaTeX code "floats" into the margin - and it looks ugly. The text is blocked and fine... then there comes some flattering code running over the margin... and blocked text again. Considering the LaTeX output, I guess that Sweave puts the source code somehow in LaTeX-boxes and I suppose there is a place where I could change the width of the source code boxes (At a certain point, there is a break, closely before the text would drift out of the page. Then the code continues in new lines below.) Does anyone know where I could change or insert the box width? Or probably I am totally wrong and someone knows another solution... Hoping for help - and excuse if anyone asked this stupid question before, I did not find it in the archive, Katharina Hoff -- DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen! AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Sweave/margin
Try a code chunk like this: <>= options(width = 70) @ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Katharina Hoff Sent: Friday, March 18, 2005 4:50 PM To: r-help@stat.math.ethz.ch Subject: [R] Sweave/margin Hi! I am currently using Sweave for writing my bachelor thesis - and I have a problem: I am using a LaTeX style (report) with quite big margin spaces. The Sweave generated LaTeX code "floats" into the margin - and it looks ugly. The text is blocked and fine... then there comes some flattering code running over the margin... and blocked text again. Considering the LaTeX output, I guess that Sweave puts the source code somehow in LaTeX-boxes and I suppose there is a place where I could change the width of the source code boxes (At a certain point, there is a break, closely before the text would drift out of the page. Then the code continues in new lines below.) Does anyone know where I could change or insert the box width? Or probably I am totally wrong and someone knows another solution... Hoping for help - and excuse if anyone asked this stupid question before, I did not find it in the archive, Katharina Hoff -- DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen! AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plotmath question
Bert, This works fine and and seems a little simpler: x<-seq(-3,to=3,by=.01) y<-dnorm(x) plot(x,y,type='h',col='lightblue',axes=FALSE) lines(x,y,col='darkblue') axis(2) ll <- expression(mu-3*sigma, mu-2*sigma, mu-sigma, mu, mu+sigma, mu+2*sigma, mu+3*sigma) axis(1, at=-3:3, lab=ll) box() Cheers, Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 Berton Gunter <[EMAIL PROTECTED] ne.com>To Sent by: "'R-help'" [EMAIL PROTECTED] at.math.ethz.chcc Subject 03/18/2005 03:41 [R] plotmath question PM R listers: I have been foiled by plotmath! (in R 2.01,Windows 2000) The task: Plot a normal density and label the ticks as mu - 3 sigma, mu - 2 sigma, , mu + 3 sigma, where the mu's and sigmas appear as Greek symbols, of course. The following code does this: x<-seq(-3,to=3,by=.01) y<-dnorm(x) plot(x,y,type='h',col='lightblue',axes=FALSE) lines(x,y,col='darkblue') axis(2) for(i in seq(-3,to=3)) axis(1,at=i, lab=switch(sign(i)+2, eval(substitute(expression(mu-j*sigma),list(j=-i))), expression(mu), eval(substitute(expression(mu+j*sigma),list(j=i) box() However, I think the code in the for loop is ugly and probably means that I'm doing it wrong. In particular: 1) Is there a neat way to use one axis() call and a vector (of expressions?) for the lab=argument? 2) The plotmath Help state that expressions can be used for axis labels, so I would have expected the above to work without the eval()call -- but it does not. Would someone kindly explain to me why not -- i.e., what I have misunderstood. That is, to be clear, why does the following not work: for(i in seq(-3,to=3)) axis(1,at=i, lab=switch(sign(i)+2, substitute(expression(mu-j*sigma),list(j=i)), expression(mu), substitute(expression(mu+j*sigma),list(j=i Any further ideas,insights, or pointers to reference materials would also be appreciated. Many thanks. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sweave/margin
On Friday 18 March 2005 15:49, Katharina Hoff wrote: > Hi! > > I am currently using Sweave for writing my bachelor thesis - and I have a > problem: > > I am using a LaTeX style (report) with quite big margin spaces. The Sweave > generated LaTeX code "floats" into the margin - and it looks ugly. The text > is blocked and fine... then there comes some flattering code running over > the margin... and blocked text again. > > Considering the LaTeX output, I guess that Sweave puts the source code > somehow in LaTeX-boxes and I suppose there is a place where I could change > the width of the source code boxes (At a certain point, there is a break, > closely before the text would drift out of the page. Then the code > continues in new lines below.) > > Does anyone know where I could change or insert the box width? If I understand your problem correctly, you might want to try putting options(width = 40) at the top of your first chunk. > Or probably I am totally wrong and someone knows another solution... > > Hoping for help - and excuse if anyone asked this stupid question before, I > did not find it in the archive, It's in the Sweave FAQ: http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plotmath question
On Friday 18 March 2005 15:41, Berton Gunter wrote: > R listers: > > I have been foiled by plotmath! > > (in R 2.01,Windows 2000) > > The task: Plot a normal density and label the ticks as mu - 3 sigma, mu - 2 > sigma, , mu + 3 sigma, where the mu's and sigmas appear as Greek > symbols, of course. > > The following code does this: > > x<-seq(-3,to=3,by=.01) > y<-dnorm(x) > plot(x,y,type='h',col='lightblue',axes=FALSE) > lines(x,y,col='darkblue') > axis(2) > for(i in seq(-3,to=3)) > axis(1,at=i, lab=switch(sign(i)+2, >eval(substitute(expression(mu-j*sigma),list(j=-i))), >expression(mu), >eval(substitute(expression(mu+j*sigma),list(j=i) > box() > > However, I think the code in the for loop is ugly and probably means that > I'm doing it wrong. In particular: > > 1) Is there a neat way to use one axis() call and a vector (of > expressions?) for the lab=argument? Yes, expression objects can be vectors. e.g.: ## use switch as above for better formatting lab = do.call(expression, lapply(-3:3, function(i) { bquote(mu + .(i) * sigma) } )) axis(1, at = -3:3, lab = lab) > 2) The plotmath Help state that expressions can be used for axis labels, so > I would have expected the above to work without the eval()call -- but it > does not. Would someone kindly explain to me why not -- i.e., what I have > misunderstood. That is, to be clear, why does the following not work: > > for(i in seq(-3,to=3)) > axis(1,at=i, lab=switch(sign(i)+2, >substitute(expression(mu-j*sigma),list(j=i)), >expression(mu), >substitute(expression(mu+j*sigma),list(j=i > is.expression(substitute(expression(mu-j*sigma),list(j=1))) [1] FALSE > is.expression(eval(substitute(expression(mu-j*sigma),list(j=1 [1] TRUE ?substitute says Value: The 'mode' of the result is generally '"call"' ... which evidently have to be evaluated. Hth, Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Count all dataset
Dear all R member, I have a dataset which looks like: x1 x2 . . . x250 A A C A C C A A A A A B B B C B ... more 2000 rows. I need count all dataset at the following: A = sum of A B = sum of B C = sum of C = sum of What function can I use? I'm just a beginner in R programming. Best regards, Jan Sabee __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non linear modeling
Hi Angelo, have a look at the following example which uses 'gls' in the nlme package. library(nlme) x <- runif(100, 0, 1) y <- x + exp(4*x)*rnorm(100, 0, 2) gls(y~x, correlation = varExp(form=~x)) For details see ?gls and ?varExp. Christian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plotmath question
On Fri, 18 Mar 2005, Berton Gunter wrote: 2) The plotmath Help state that expressions can be used for axis labels, so I would have expected the above to work without the eval()call -- but it does not. Would someone kindly explain to me why not -- i.e., what I have misunderstood. That is, to be clear, why does the following not work: Because substitute() doesn't evaluate its argument: the result is not an expression but a call to the expression() function. An example where it is clearer what is going on substitute(log(x),list(x=1)) doesn't return a number, even though log() returns a number. It returns a call to log() that still has to be evaluated -thomas for(i in seq(-3,to=3)) axis(1,at=i, lab=switch(sign(i)+2, substitute(expression(mu-j*sigma),list(j=i)), expression(mu), substitute(expression(mu+j*sigma),list(j=i __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: Repeated Measures, groupedData and lme
Hello, I'm an R-newbie, but I've been learning to use lme for repeated measures experiments as well. If I understand correctly: Outcome variable: Mg (Kg/ha) Subject/grouping variable: block Condition/treatment: treatment (19 levels) Repeated factor: time (3 levels: 99, 02, 04) I think if you specify the model formula in the lme call, then the formula structure specified in the groupedData object is ignored. One suggestion for the model: Model1<-lme(mg~treatment + year + treatment:year, random=~1|block, data=magnesium) If the question of interest is the treatment:year interaction Or Model2 <- lme(mg~treatment, random=~1|block, data=magnesium) Hope this helps ... and hope the experts chime in at this point to give more guidance. Keith --quoting original post--- Hello I am trying to fit a REML to some soil mineral data which has been collected over the time period 1999 - 2004. I want to know if the 19 different treatments imposed, differ in terms of their soil mineral content. A tree model of the data has shown differences between the treatments can be attributed to the Magnesium, Potassium and organic matter content of the soil, with Magnesium being the primary separating variable. I am looking at soil mineral data were collected : 99, 02, 04. In the experiment, there are 19 different treatments (treatmentcontrol, treatment6TFYM, treatment 12TFYM etc), which are replicated in 3 blocks. For the magnesium soil data, I have created the following groupedData object: magnesium<-groupedData(Mg~year|treatment, inner=~block) Where mg=magnesium Kg/ha As it is a repeated measures I was going to use an lme. I have looked at Pinherio and Bates : Mixed-Effects models in S and S-plus and I am getting slightly confused. In order to fit the lme, should I specify the data to use in the model as the grouped structure model? If so is the following command correct: Model1<-lme(mg~treatment, random=block|year, data=magnesium)? I am slightly worried that it isn't, because in model summary, instead of listing the 19 different treatments in the fixed effects section, it writes intercept (as normal), then treatment^1, treatment^2 etc. However if I don't specify the groupedData object in the model, then in the fixed effects section, it names the treatments (i.e. intercept, treatmentcontrol, treatment6TFYM. Should I be fitting the model using the whole data set rather than the groupedData object? Thank you very much for your help Emma Pilgrim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Count all dataset
Here are two (pretty much the same) ways: > d x1 x2 x3 1 D DA 2 B DA 3 C A 4 D DA 5 A DC > table(sapply(d, as.character)) A B C D 5 1 2 6 > table(as.matrix(d)) A B C D 5 1 2 6 > sum(is.na(d)) [1] 1 HTH, Andy > From: Jan Sabee > > Dear all R member, > > I have a dataset which looks like: > > x1 x2 . . . x250 > A A C > A C C > A A A > A A > B B B > C B > ... > more 2000 rows. > > I need count all dataset at the following: > > A = sum of A > B = sum of B > C = sum of C > = sum of > > What function can I use? > I'm just a beginner in R programming. > > Best regards, > Jan Sabee > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is a .R script file name available inside the script?
Darren Weber gmail.com> writes: : : Hi, : : if we have a file called Rscript.R that contains the following, for example: : : x <- 1:100 : outfile = "Rscript.Rout" : sink(outfile) : print(x) : : and then we run : : >> source("Rscript.R") : : we get an output file called Rscript.Rout - great! : : Is there an internal variable, something like .Platform, that holds : the script name when it is being executed? I would like to use that : variable to define the output file name. : In R 2.0.1 try putting this in a file and sourcing it. script.description <- function() eval.parent(quote(file), n = 3) print(basename(script.description())) If you are using R 2.1.0 (devel) then use this instead: script.description <- function() showConnections() [as.character(eval.parent(quote(file), n = 3)), "description"] print((basename(script.description( __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] the number of cluster
hi, all, how to decide the number of cluster before you use kmeans and hclust? thank you in advance! best -xpsun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html