Re: [R] How to print landscape from script in Windows: dev.print(win.print, printer=local printer name, ...) does not accept horizontal=TRUE
Set width and height appropriately for a landscape plot, and set landscape in the options for the printer driver (if supported). Whereas the postscript device can rotate a plot by 90^o, no Windows device has that encoded. Why? Because the Windows print spooler gives you the option to rotate and Unix ones do not. Or use postscript() + a PostScript printer/printer utility (e.g. GSView on Windows). On Wed, 29 Sep 2004 [EMAIL PROTECTED] wrote: This is a windows-specific question. After generating a plot, I can print from scripts or the command line with dev.print(win.print,printer=local windows printer name) I would like to print in landscape mode. From the menus, I can accomplish this by changing the properties of the printer before clicking print. However, I tried adding horizontal=TRUE to the command, but it gives an error message: dev.print(win.print,horizontal=TRUE,printer=RhoSvr01\\HP LaserJet 8150 PCL 6) Error in device(...) : unused argument(s) (horizontal ...) I can see from ?device and then ?win.print that, sure enough, there is no 'horizontal' parameter in win.print. There are many examples like this on the help archives and in the docs, apparently for other devices, so I am puzzled how to accomplish what I want. BTW, This is on Windows XP SP2 and R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major1 minor9.1 year 2004 month09 day 22 language R Any help will be much appreciated! David L. Reiner Rho Trading 440 S. LaSalle St -- Suite 620 Chicago IL 60605 312-362-4963 (voice) 312-362-4941 (fax) [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] 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] RSXML - Parsing XML Documents on Internet
On Wed, 29 Sep 2004 [EMAIL PROTECTED] wrote: R Users - I asked about this a few months ago and never did quite figure it out, so with more information, allow me to try again. If I use the following code: library(xml) xmlTreeParse(http://home.comcast.net/~larsenmtl/xmlTestDoc.xml;, isURL = TRUE) I receive this error: Error in xmlTreeParse(http://home.comcast.net/~larsenmtl/xmlTestDoc.xml;, : error in creating parser for http://home.comcast.net/~larsenmtl/xmlTestDoc.xml; Now I know that xmlTreeParse uses the libxml facilities for downloading and parsing off the web. Along with one of our network people, I did some packet sniffing and it looks like libxml doesn't go through our proxy server (it tries to directly connect to the above URL), which is the reason for the error. Is there anyway to force it through the proxy? Am I missing some setting or option? If I download the xml file and parse it locally it works without error. Please Note that the URL is valid and I can open it in my browser. Also note that I must start R with the --internet2 option so it'll use our proxy server. That's your problem. You can use proxies without --internet2 (see ?download.file) and Details: Windows 2000 R1.9.1 RSXML 0.97-0 libxml2-2.4.13 distribution for Windows I also tried this on a Mandrake 9.2 box with R1.9.1, XML0.95-6, and libxml2 2.6.13. Results were the same but with the additional error message: I/O warning: falied to load external entity http://; Thanks, Mark Larsen __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] 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] RSXML - Parsing XML Documents on Internet
Sorry, my flaky connection (I am on a slow dialup) broke this up: here's the rest. On Thu, 30 Sep 2004, Prof Brian Ripley wrote: On Wed, 29 Sep 2004 [EMAIL PROTECTED] wrote: [...] Now I know that xmlTreeParse uses the libxml facilities for downloading and parsing off the web. Along with one of our network people, I did some packet sniffing and it looks like libxml doesn't go through our proxy server (it tries to directly connect to the above URL), which is the reason for the error. Is there anyway to force it through the proxy? Am I missing some setting or option? If I download the xml file and parse it locally it works without error. Please Note that the URL is valid and I can open it in my browser. Also note that I must start R with the --internet2 option so it'll use our proxy server. That's your problem. You *can* use proxies without --internet2 (see ?download.file) and the XML code uses the standard version of the code. The first issue is that you have not configured R to use your proxy, so please get that working. Issue two is that you may need to get an older version of XML compiled against an older libxml, as the current one has not been tested. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] 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: Vectorising and loop (was Re: [R] optim alog-likelihood function)
ok. You just simulate a 200 by 3 matrix z, all positive integers. The first column is i, the second column is j, and the third column is in fact the frequency of (i,j) combination, you can set the third column to be 1 for simplification. Notice that ij, and k=max of the second column. theta is a k dimension vector I want to maximize over. ll - function(theta) {t-0 for (ii in 1:k) {t-t+exp(theta[ii])} lll-0 x00-1/(1+t) x0-x00*exp(theta) for (m in 1:200) {i-z[m,1] j-z[m,2] a-z[m,3] l-i:(k-j+i) s-rep(0,k) s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) # we only define some of s to be non-zero, since dim(l) might be smaller than dim(s) ss-sum(s*x0) # ss is a weighted sum of x0 lll-lll+a*log(ss) } -lll # the negative sign is to find the maximum of the log-likelihood function. It can be omitted if we use the finscale option in optim. } Then I need to optim(b0,ll,hessian=T), where b0 is k dimension starting value. I have tried to use eval() and modify my function, it seems to be able to remove the m loop, however, optim() can not recognize it. So my main concern is to avoid the loop and optim() can works for my function. Thanks. Regards, Zhen __ [EMAIL PROTECTED] 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] Retrieving objects from functions...
I've written a program that involves a loop that creates a matrix. I'd like to be able to manipulate that matrix on my R desktop, but after I run the function, that matrix does not appear when I type ls(). How can I make that matrix become an object that I can manipulate? Thanks! __ [EMAIL PROTECTED] 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] biplot.princomp with loadings only
Hi is there a way to plot only the loadings in a biplot (with the nice arrows), and to skip the scores? thanks christoph __ [EMAIL PROTECTED] 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] Retrieving objects from functions...
Hi, On Thu, 30 Sep 2004, Jonathan Harris wrote: I've written a program that involves a loop that creates a matrix. I'd like to be able to manipulate that matrix on my R desktop, but after I run the function, that matrix does not appear when I type ls(). How can I make that matrix become an object that I can manipulate? If I understand you right, you want something like: foo - function() { goo - matrix(1:10, nrow = 5, ncol = 2) } then be able to call goo after running foo()? If this is what you want, then you need to do something like: foo - function() { goo - matrix(1:10, nrow = 5, ncol = 2) } to force goo to become a global variable, instead of a local variable to foo(). HTH, Kevin Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301 __ [EMAIL PROTECTED] 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] Retrieving objects from functions...
Jonathan Harris jharris at hss.caltech.edu writes: : I've written a program that involves a loop that creates a matrix. I'd : like to be able to manipulate that matrix on my R desktop, but after I : run the function, that matrix does not appear when I type ls(). How can : I make that matrix become an object that I can manipulate? Just return the matrix as the value of your function. If you are already returning something else as the value of the function return a list with that value and the matrix as the two components. Check out the builtin eigen function is an example of this as it returns both eigenvalues and eigenvectors. The aforementioned is probably the best strategy but if you must then you could alternately assign the matrix into the parent or global environment from within your function using assign: assign(mat, mat, parent.frame()) assign(mat, mat, .GlobalEnv) __ [EMAIL PROTECTED] 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] Retrieving objects from functions...
Jonathan Harris wrote: I've written a program that involves a loop that creates a matrix. I'd like to be able to manipulate that matrix on my R desktop, but after I run the function, that matrix does not appear when I type ls(). How can I make that matrix become an object that I can manipulate? Return it from the function and assign it outside: foo - function(anything){ TheMatrix - fun(anything) return(TheMatrix) } result - foo(something) Now, you have the resulting matrix assigned to an object called result. Please read An Introduction to R! Uwe Ligges Thanks! __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] Retrieving objects from functions...
Kevin Wang wrote: Hi, On Thu, 30 Sep 2004, Jonathan Harris wrote: I've written a program that involves a loop that creates a matrix. I'd like to be able to manipulate that matrix on my R desktop, but after I run the function, that matrix does not appear when I type ls(). How can I make that matrix become an object that I can manipulate? If I understand you right, you want something like: foo - function() { goo - matrix(1:10, nrow = 5, ncol = 2) } then be able to call goo after running foo()? If this is what you want, then you need to do something like: foo - function() { goo - matrix(1:10, nrow = 5, ncol = 2) No, you don't want to do it that way, but you want to return(), in almost all cases I can imagine ... Uwe } to force goo to become a global variable, instead of a local variable to foo(). HTH, Kevin Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] Matrix
I have a matrix 2900X2900 and I have to solve it. But R says that it can't allocate 67899kb. How can I do? Appreciate your kindly help! Salvati Nicola Dipartimento di Statistica G.Parenti [EMAIL PROTECTED] tel. 055.4237.224 fax 055.4223560 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] 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] Interface between R and Perl
Hi, I have made a GUI in PerlTk and I would use R within perl. I actually try to install RSPerl but I have some problems during the compilation In order to call R from perl I use actually an other system based on the OPEN command in perl. It works fine but when I tried to call the fonction plot() of R from perl the plot do not appears and a file named plot.ps is generated. Unfortunalelly, my plot is dynamic (I also use the identify() command) so I can't integrate this plot as an jpeg image for example. My question is : Is there a solution to call the plot() and identify() R commands from perl in order to have a dynamic plot ?? can RSPerl do this or not ?? If it can I will spend more time to install it but it looks hard Thank you very much and excuse me for my english :-) __ [EMAIL PROTECTED] 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] optim a log-likelihood function
dear optim experts, optim(c(1,1),LL,control=list(fnscale=-1),trans=trans,times=times) Error in optim(c(1, 1), LL, control = list(fnscale = -1), trans = trans, : Function cannot be evaluated at initial parameters Finally i would constraint r and alpha than a small positive number? optim(c(1,1),LL,lower=c(0.0001,0.001),upper=Inf,method=L-BFGS-B,control=list(fnscale=-1),trans=trans,times=times) Error in optim(c(1, 1), LL, lower = c(0.001, 0.001), upper = Inf, method = L-BFGS-B, : L-BFGS-B needs finite values of fn where are my mistakes? Many thanks, christian ## The data and function dm - subset(dm09,select=c(ID,TRANS,TIMES)) trans - dm$TRANS length(trans) [1] 269732 times - dm$TIMES length(times) [1] 269732 LL - function(x,trans,times){ r - x[1] alpha - x[2] l0 - exp(lgamma(r+trans)-lgamma(r))/gamma(trans+1)*(alpha/(alpha+times))**r*(times/(alpha+times))**trans l - log(l0) sum(l) } Am Mittwoch, 29. September 2004 19:41 schrieb Sundar Dorai-Raj: Christian Schulz wrote: Hello, i know that i have to use optim, but i'm confused how its possible maximize the sum over all l[i] and get the optimized max(LL), r and alpha? LL - function(trans,time){ for(i in 1:length(trans){ l[i] - log(lgamma(r+trans[i] - gamma(r+1)*(alpha/alpha+t[i]))**r)*(t[i]/alpha+t[i]))**trans[i] } return(sum(l)) } i'm confused how i have to set r and alpha and i found no related help in archives? ...in Excel it works with solver but only for ~65.000 rows :-) #This notation is 1 for trans and 1 for time instead the Startvalues for r and alpha? I'm not sure what the above statement means, so I may have misinterpretted what you are trying to accomplish. optim(c(1,1),-LL) many thanks for an easy example or hint regards,christian Did you look at the first example in ?optim? There also numerous errors in LL: missing parans, time is not used, t is undefined in the function. LL - function(x, trans, time) { r - x[1] alpha - x[2] ... sum(l) } optim(c(1, 1), LL, control = list(fnscale = -1), trans = trans, time = time) Some style issues: 1. Break up lines that run too long, especially if you expect others to read your code. 2. You don't need an explicit return at the end of a function. 3. You should remove the for loop in LL and vectorise l, which should be easy. Hope this is helpful, --sundar __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] Can't load rgl library
Hi, I've installed rgl package through R CMD INSTALL on a Debian-Sarge machine (PIV) without any compiling error (see attached file), but when trying to load this package within R (and also Rcmdr library) I get: library(rgl) RGL: GLX extension missing on server Error in firstlib(which.lib.loc, package) : error rgl_init error in library(rgl) : .First.lib failed Segmentation fault Same failure problem if I use the apt option (apt-get install r-cran-gl). I've searched through the R mail archives but couldn't find or understand the answer for this problem. Thanks in advance! Antonio Rodríguez laptop:/home/toni/tmp# R CMD INSTALL rgl_0.64-13.tar.gz * Installing *source* package 'rgl' ... checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E checking for X... libraries /usr/X11R6/lib, headers /usr/X11R6/include checking for libpng-config... yes configure: creating ./config.status config.status: creating src/Makevars ** libs g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c x11lib.cpp -o x11lib.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c x11gui.cpp -o x11gui.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c types.cpp -o types.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c math.cpp -o math.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c fps.cpp -o fps.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c pixmap.cpp -o pixmap.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c gui.cpp -o gui.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c api.cpp -o api.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c device.cpp -o device.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c devicemanager.cpp -o devicemanager.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c rglview.cpp -o rglview.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c scene.cpp -o scene.o g++ -I/usr/lib/R/include -I/usr/X11R6/include -DHAVE_PNG_H -mieee-fp -Wall -pedantic -fno-exceptions -fno-rtti -fPIC -g -O2 -c glgui.cpp -o glgui.o g++ -shared -o rgl.so x11lib.o x11gui.o types.o math.o fps.o pixmap.o gui.o api.o device.o devicemanager.o rglview.o scene.o glgui.o -L/usr/X11R6/lib -lpng12 -lstdc++ -lX11 -lXext -lGL -lGLU -lpng12 -L/usr/lib/R/bin -lR ** R ** demo ** inst ** help Building/Updating help pages for package 'rgl' Formats: text html latex example bbox texthtmllatex example bgtexthtmllatex example light texthtmllatex material texthtmllatex primitive texthtmllatex example rgl-internal texthtmllatex rgl texthtmllatex example scene texthtmllatex snapshot texthtmllatex example spheres texthtmllatex example sprites texthtmllatex example surface texthtmllatex example texts texthtmllatex example viewpoint texthtmllatex example * DONE (rgl) laptop:/home/toni/tmp# R CMD INSTALL Rcmdr_0.9-11.tar.gz * Installing *source* package 'Rcmdr' ... ** R ** inst ** help Building/Updating help pages for package 'Rcmdr' Formats: text html latex example Commander texthtmllatex example Compute texthtmllatex Hist
Re: [R] Matrix
salvati nicola wrote: I have a matrix 2900X2900 and I have to solve it. But R says that it can't allocate 67899kb. How can I do? a) Clean up your workspace before trying to work on the matrix b) Is this an outdated R version on Windows? Then (i) please upgrade and (ii) please read the R for Windows FAQs and ?Memory. c) Buy more memory, if you have less than 512MB. 512 MB suffices for me (in a clean workspace!) in ~5 min. using Rblas.dll linked against ATLAS. You probably want to have ~1GB of memory for serious other calculations with those matrices. Uwe Ligges Appreciate your kindly help! Salvati Nicola Dipartimento di Statistica G.Parenti [EMAIL PROTECTED] tel. 055.4237.224 fax 055.4223560 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] Can't load rgl library
On Thu, 30 Sep 2004 11:40:48 +0200, [EMAIL PROTECTED] wrote: Hi, I've installed rgl package through R CMD INSTALL on a Debian-Sarge machine (PIV) without any compiling error (see attached file), but when trying to load this package within R (and also Rcmdr library) I get: library(rgl) RGL: GLX extension missing on server Error in firstlib(which.lib.loc, package) : error rgl_init error in library(rgl) : .First.lib failed Segmentation fault Problems about packages should be sent to the maintainer of the package, in this case Daniel Adler [EMAIL PROTECTED]. But it does sound as though you don't have OpenGL or Mesa installed on your machine. Duncan Murdoch __ [EMAIL PROTECTED] 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] Interface between R and Perl
I don't think RSPerl can do this from within perl, but others would know better than I. Have you considered using tcltk for R? You could recreate the GUI there, if the GUI is that is the use of perl in your application. Sean On Sep 30, 2004, at 4:39 AM, [EMAIL PROTECTED] wrote: Hi, I have made a GUI in PerlTk and I would use R within perl. I actually try to install RSPerl but I have some problems during the compilation In order to call R from perl I use actually an other system based on the OPEN command in perl. It works fine but when I tried to call the fonction plot() of R from perl the plot do not appears and a file named plot.ps is generated. Unfortunalelly, my plot is dynamic (I also use the identify() command) so I can't integrate this plot as an jpeg image for example. My question is : Is there a solution to call the plot() and identify() R commands from perl in order to have a dynamic plot ?? can RSPerl do this or not ?? If it can I will spend more time to install it but it looks hard Thank you very much and excuse me for my english :-) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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: R-help Digest, Vol 19, Issue 30
I will be out of the office 9/30/04 - 10/4/04. For immediate help, please call the JPSM main number, 301-314-7911. __ [EMAIL PROTECTED] 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: Vectorising and loop (was Re: [R] optim alog-likelihoodfunction)
Mr. Grothendieck does suggest me to paste the data here. I just show a small one here. I must metion that I made a mistake in my former email. The first column should be j and is greater than the second column. I have corrected ll. z is the matrix below 2 1 3 3 1 1 3 3 1 5 2 4 k-max(z[,1]) ll - function(theta) {t-0 for (ii in 1:k) {t-t+exp(theta[ii])} lll-0 x00-1/(1+t) x0-x00*exp(theta) for (m in 1:length(z[,1])) {j-z[m,1] i-z[m,2] a-z[m,3] l-i:(k-j+i) s-rep(0,k) s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) # we only define some of s to be non-zero, since dim(l) might be smaller than dim(s) ss-sum(s*x0) # ss is a weighted sum of x0 lll-lll+a*log(ss) } -lll # the negative sign is to find the maximum of the log-likelihood function. It can be omitted if we #use the finscale option in optim. } Then I need to optim(b0,ll,hessian=T), where b0-c(0.8331934, 20.8009068, -7.0893623, 1.2109221, 18.7213273). optim(b0,ll,hessian=T) $par [1] 0.8331934 20.8009068 -7.0893623 1.2109221 18.7213273 $value [1] 5.182791 $counts function gradient 52 NA $convergence [1] 0 $message NULL $hessian [,1] [,2] [,3] [,4] [,5] [1,] 1.065814e-08 -9.325873e-09 0.00e+00 -3.330669e-10 -2.109424e-09 [2,] -9.325873e-09 8.887936e-01 -3.330669e-10 -1.620926e-08 -8.887936e-01 [3,] 0.00e+00 -3.330669e-10 -6.661338e-10 0.00e+00 0.00e+00 [4,] -3.330669e-10 -1.620926e-08 0.00e+00 7.549517e-09 7.105427e-09 [5,] -2.109424e-09 -8.887936e-01 0.00e+00 7.105427e-09 8.887936e-01 I have tried to use eval() and modify my function, it seems to be able to remove the m loop, however, optim() can not recognize it. So my main concern is to avoid the loop and optim() can works for my function. Thanks. __ [EMAIL PROTECTED] 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] defining a template for functions via do.call and substitute.
Hi, Many thanks for the responses which solved my problem. Fyi, my actual application is copulaClayton - function(u, v, alpha) (u^-alpha + v^-alpha - 1)^(-1/alpha) g - function(){} body(g) - do.call(substitute, list(body(copulaClayton), list(u = as.name(w), v = quote(pnorm(var - qnorm(w)) formals(g) - alist(w=, var=, alpha=) g and the substitutions seem to be working fine. Thanks to Liaw, Andy [EMAIL PROTECTED] Dimitris Rizopoulos [EMAIL PROTECTED] Bert Gunter [EMAIL PROTECTED] and Thomas Lumley [EMAIL PROTECTED], Gabor Grothendieck [EMAIL PROTECTED] Regards, John. -Original Message- From: Gavin, John Sent: 29 September 2004 12:17 To: '[EMAIL PROTECTED]' Subject: defining a template for functions via do.call and substitute. Hi, Given a function fun - function(a, b) a + b how do I generate the function 'function(x, y) x + y'? Working from the help files and Bill Venables' R-news article (June 2002), I have tried various permutations with substitute without success. e.g. do.call(substitute, list(fun, list(a = as.name(x), b = as.name(y Regards, John. John Gavin john.gavin at ubs.com, Quantitative Risk Models and Statistics, UBS Investment Bank, 6th floor, 100 Liverpool St., London EC2M 2RH, UK. Phone +44 (0) 207 567 4289 Fax +44 (0) 207 568 5352 Visit our website at http://www.ubs.com This message contains confidential information and is intend...{{dropped}} __ [EMAIL PROTECTED] 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] Warning: number of items to replace is not a multiple of replacement length
Mag. Ferri Leberl wrote: What does this warning mean precisely? Is there any reason to care about it? Can I Avoid it by another way of programming? As you have already gotten most of your questions answered, here is a possible answer to the last. You may want to care about it, but not necessarily. I have had to use the recycling capability of R without knowing whether the length of the result would be a multiple of that of the source vector. Say I want to label a vector of daily observations, but I do not know which day the observations start or how many there are: label.weekdays-function(ndays,start=1) { daynames-rep(c(Sun,Mon,Tue,Wed,Thu,Fri,Sat),ndays/7+1) return(daynames[start:(start+ndays-1)]) } By creating a vector that is intentionally too long, then truncating it on one or both ends, I can recycle the source vector and avoid the warning. Jim __ [EMAIL PROTECTED] 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] biplot.princomp with loadings only
Christoph Lehmann wrote: Hi is there a way to plot only the loadings in a biplot (with the nice arrows), and to skip the scores? thanks christoph Hi Christoph, Three options I can think of: 1) Hack the source for biplot.princomp and biplot.default (which does the plotting) by commenting out the lines that plot the scores or altering the code to plot only the scores. You want to plot just y[,1] against y[,2] and ignore the x[,1] and x[,2] bits in biplot.default. 2) Write your own function based on biplot.default and biplot.princomp 3) If you don't like hacking/coding then see package vegan and the function scores, which has a method for class princomp, which can extract the loadings and the scores (in princomp terms, vegan calls them something else). Function ordiplot (also in vegan) provides direct plotting of various ordination results including objects from princomp. All the best, Gav -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. ECRC [E] [EMAIL PROTECTED] UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ [EMAIL PROTECTED] 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 save graphics in portable way in batch mode?
Hi all, What is the right portable way to save graphics in batch mode? Remarks: 1. Problem is STFWed and RTFMed. In particular a short note about png() is found in R-FAQ. In fact, there were stated that png() is not reliable under Linux in batch mode. 2. savePlot under windows is quite convenient, but not supplied under Linux. 3. pdf() + postscript() savePlot() Indeed, savePlot does support much more image formats and is flexible in changing type of output via its argument. 4. The scheme postscript(); plot(); dev.off(); makes R-scripts not really nice. Indeed, if one's script had about 15 plot calls then in order to save graphics one need to add 15 times the postscript() in prior of plot() call and then 15 times the dev.off() as epilogue to plot() call. 5. Hm, one could create function similar to Sweave() (see R-1.9.1\src\library\utils\R\Sweave.R) and benefit from automatic name generation and saving. But it is quite unnatural, isn't it? so, it would be nice to know what is the right way. P.S. BTW, will be there any specific changes in R-2.x? Thank you a priori for your comments, Valery. __ [EMAIL PROTECTED] 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 print landscape from script in Windows: dev.print(win.print, printer=local printer name, ...) does not accept horizontal=TRUE
On Wed, 29 Sep 2004 16:28:09 -0500, [EMAIL PROTECTED] wrote : This is a windows-specific question. After generating a plot, I can print from scripts or the command line with dev.print(win.print,printer=local windows printer name) I would like to print in landscape mode. From the menus, I can accomplish this by changing the properties of the printer before clicking print. I think the easiest way to do this is to create a new printer which defaults to landscape, and then do dev.print(win.print,printer=local landscape printer name) I think it's unlikely we'll add this to win.print(); there are just too many options in Windows printer drivers, and it's fairly easy to set them using the Windows dialogs. Duncan Murdoch __ [EMAIL PROTECTED] 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 save graphics in portable way in batch mode?
Have you considered the following approach to creating a single PDF file with multiple pages of plots? pdf(file=c:\\myfigs.pdf) plot() plot() plot() dev.off() Or if you want a file for each figure with names generated automatically, try something like: pdf(onefile=FALSE) plot() plot() plot() dev.off() It seems like as long as the PDF device is going to have the same settings (e.g., width, height, and pointsize) across plots, there is no need to call pdf() and dev.off() multiple times within a script. hope this helps, Chuck Cleland Khamenia, Valery wrote: Hi all, What is the right portable way to save graphics in batch mode? Remarks: 1. Problem is STFWed and RTFMed. In particular a short note about png() is found in R-FAQ. In fact, there were stated that png() is not reliable under Linux in batch mode. 2. savePlot under windows is quite convenient, but not supplied under Linux. 3. pdf() + postscript() savePlot() Indeed, savePlot does support much more image formats and is flexible in changing type of output via its argument. 4. The scheme postscript(); plot(); dev.off(); makes R-scripts not really nice. Indeed, if one's script had about 15 plot calls then in order to save graphics one need to add 15 times the postscript() in prior of plot() call and then 15 times the dev.off() as epilogue to plot() call. 5. Hm, one could create function similar to Sweave() (see R-1.9.1\src\library\utils\R\Sweave.R) and benefit from automatic name generation and saving. But it is quite unnatural, isn't it? so, it would be nice to know what is the right way. P.S. BTW, will be there any specific changes in R-2.x? Thank you a priori for your comments, Valery. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 __ [EMAIL PROTECTED] 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 save graphics in portable way in batch mode?
Khamenia, Valery [EMAIL PROTECTED] writes: Hi all, What is the right portable way to save graphics in batch mode? Remarks: 1. Problem is STFWed and RTFMed. In particular a short note about png() is found in R-FAQ. In fact, there were stated that png() is not reliable under Linux in batch mode. 2. savePlot under windows is quite convenient, but not supplied under Linux. 3. pdf() + postscript() savePlot() Indeed, savePlot does support much more image formats and is flexible in changing type of output via its argument. 4. The scheme postscript(); plot(); dev.off(); makes R-scripts not really nice. Indeed, if one's script had about 15 plot calls then in order to save graphics one need to add 15 times the postscript() in prior of plot() call and then 15 times the dev.off() as epilogue to plot() call. 5. Hm, one could create function similar to Sweave() (see R-1.9.1\src\library\utils\R\Sweave.R) and benefit from automatic name generation and saving. But it is quite unnatural, isn't it? so, it would be nice to know what is the right way. Looks like you may have RTFM but didn't RTWFM (or even RTWHP). Check out the onefile argument in postscript(). P.S. BTW, will be there any specific changes in R-2.x? The sources are available E.g. https://svn.r-project.org/R/trunk/NEWS -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] How to save graphics in portable way in batch mode?
pdf(onefile=FALSE) plot() plot() plot() dev.off() oh, nice hint. The following: pdf(file=aaa%02d.pdf, onefile=FALSE) is very close to compromise, thank you, Chunk! -- Valery. __ [EMAIL PROTECTED] 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] Matrix
Douglas Bates wrote: Uwe Ligges wrote: salvati nicola wrote: I have a matrix 2900X2900 and I have to solve it. But R says that it can't allocate 67899kb. How can I do? a) Clean up your workspace before trying to work on the matrix b) Is this an outdated R version on Windows? Then (i) please upgrade and (ii) please read the R for Windows FAQs and ?Memory. c) Buy more memory, if you have less than 512MB. 512 MB suffices for me (in a clean workspace!) in ~5 min. using Rblas.dll linked against ATLAS. You probably want to have ~1GB of memory for serious other calculations with those matrices. Uwe Ligges 5 Min? On a modest desktop system (Athlon XP 2500+, approx 1.8 GHz) it took about 20 seconds for the inversion and about 8 seconds for the LU decomposition. This is using the Matrix package. mm - Matrix(rnorm(2900*2900), ncol = 2900) object.size(mm) [1] 67280636 system.time(rcond(mm)) [1] 7.73 0.10 7.96 0.00 0.00 object.size(mm) [1] 134573052 system.time(minv - solve(mm)) [1] 19.93 0.10 20.04 0.00 0.00 rcond(mm) [1] 2.466351e-07 The initial call to rcond calculates and stores the LU decomposition. That is why the size of the object approximately doubles. I get similar results without the matrix package except that the decomposition must be recomputed for each such operation on the matrix. m1 - matrix(rnorm(2900*2900), ncol = 2900) system.time(minv1 - solve(m1)) [1] 30.08 0.86 32.32 0.00 0.00 I'm sorry, I only thought I had used the ATLAS optimized version (but it was the standard Rblas.dll), it really has system.time(minv - solve(mm)) [1] 31.69 1.82 34.14NANA (R-1.9.1, ATLAS, WinNT4.0, Athlon with real 1.67 GHz) Uwe __ [EMAIL PROTECTED] 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] Rpy vs RSPython
Hi, I'm planning to write some code in Python using R functions. I'm aware of the two R-Python packages - Rpy and RSPython. Rpy seems easier to get up and running with, but does anybody have any comments regarding which would be a better system to work with in the long run? Thanks, --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- I live in my own little world... but it's OK, they like me there __ [EMAIL PROTECTED] 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] pointsize in png graphics
Dear all, I'm trying to produce 2 png files, one consisting of an image plot and a color-table (also an image plot) and the other one consisting of 4 image plots and a color table. I'd like the color table to be exactly the same. The way I proceded is the following: for one plot and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() for 4 plots and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() The only difference is the layout of the plot. The outcome though is completely different. It seems that the definition of the size of one point is different in the two plots as the graphics with 4 plots and color table has smaller fonts and smaller margins. What do I have to do to be sure the size of the fonts is the same in two different png graphcis of exactly the same size when the pointsize is the same? I'm working with Windows XP and tried both running the R script as a batch job and running it within Emacs with ESS. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major1 minor9.1 year 2004 month06 day 21 language R Many thanks in advance and best regards, Jan:-) __ [EMAIL PROTECTED] 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] Using try()
Hello R people, I am need some help using the try() function. Currently I am running a loop which uses arima() for some values of p and q, which sometimes crashes. When it crashes, I want the program to just ignore it and move on to the next values to loop through. I currently have this, looping through a range of values for p and q: lo = try( arima1 - arima( y, order=c( p, 0, q ) ) if( !inherits( lo, try-error ) ){ ... code here ... } This works perfectly for my purposes, with one exception: Everytime the program invokes try(), I have to press Esc in the R console for the program to continue. How can I avoid this (so that I don't have to keep pushing Esc). I tried reading the help file for tryCatch(), which showed a wide range of options to try (no pun intended), but this confused me. Thanks, Nate __ [EMAIL PROTECTED] 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] tcl/tk
Hi all, I am already using R under Window and would like now to try and install it under Unix; I read I need tcl/tk installed so I connected to http://www.scriptics.com downloaded the file and extracted them to a directory tcltk beside R. I configured (./configure) both packages (tcl and tk) and compiled (make) them but I am not sure about how to proceed now: should I launch the command make install? Should I edit the config.site of R to specify some configuration variables? But how? Does anybody know anything about it and have suggestions on how to go on and properly install tcl/tk and subsequently R? I should be able to complete the installation of R once I worked around this tcl/tk hindrance. Thank you very much, Filippo Biscarini Filippo Biscarini, Research and Development ANAFI (Italian Holstein Association) Via Bergamo, 292 26100, Cremona, Italy tel: +39.0372.474234 * __ [EMAIL PROTECTED] 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] Boxplot, space to axis
Hello, I've crearted a boxplot with 84 boxes. So fat everything is as I expect, but there is quite some space between the 1st box and axis 2 and the last box and axis 4. Since 84 boxes get very slim anyway I'd like to discribute as much of the horizontal space over the x-axis. Maybe I've forgotten about a graphics parameter? Thanks for your help, Arne __ [EMAIL PROTECTED] 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] tcl/tk
Filippo BISCARINI wrote: Hi all, I am already using R under Window and would like now to try and install it under Unix; I read I need tcl/tk installed so I connected to http://www.scriptics.com downloaded the file and extracted them to a directory tcltk beside R. I configured (./configure) both packages (tcl and tk) and compiled (make) them but I am not sure about how to proceed now: should I launch the command make install? Should I edit the config.site of R to specify some configuration variables? But how? Yes, make install is sufficient on most systems. Does anybody know anything about it and have suggestions on how to go on and properly install tcl/tk and subsequently R? ./configure make make install In the common case, R's configure detects the tcl/tk installation ... Uwe Ligges I should be able to complete the installation of R once I worked around this tcl/tk hindrance. Thank you very much, Filippo Biscarini Filippo Biscarini, Research and Development ANAFI (Italian Holstein Association) Via Bergamo, 292 26100, Cremona, Italy tel: +39.0372.474234 * __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] pointsize in png graphics
[EMAIL PROTECTED] wrote: Dear all, I'm trying to produce 2 png files, one consisting of an image plot and a color-table (also an image plot) and the other one consisting of 4 image plots and a color table. I'd like the color table to be exactly the same. The way I proceded is the following: for one plot and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() for 4 plots and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() The only difference is the layout of the plot. The outcome though is completely different. It seems that the definition of the size of one point is different in the two plots as the graphics with 4 plots and color table has smaller fonts and smaller margins. What do I have to do to be sure the size of the fonts is the same in two different png graphcis of exactly the same size when the pointsize is the same? I'm working with Windows XP and tried both running the R script as a batch job and running it within Emacs with ESS. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major1 minor9.1 year 2004 month06 day 21 language R Many thanks in advance and best regards, Jan:-) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Hi Jan, Generally, I've found it very undesirable to set pointsize when calling a graphics device. Instead, I set the cex parameter, either globally through par or for each individual plot. If you don't tweak the defaults, then cex effectively works in picas, so you can divide your desired point size by 12 to come up with the right value of cex. Why don't you give that a try and let me know how it turns out? Also, are you sure that you managed to run that code as a batched script? png() is one of the graphics devices that doesn't work in batch. To get batched pngs, I typically have to use bitmap(type = png16m, ...). Kevin __ [EMAIL PROTECTED] 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] RSXML - Parsing XML Documents on Internet
Professors Ripley and Lang, Thanks. Your fix was dead-on, setting the env var http_proxy solved my problem. Mark Sorry, my flaky connection (I am on a slow dialup) broke this up: here's the rest. On Thu, 30 Sep 2004, Prof Brian Ripley wrote: On Wed, 29 Sep 2004 [EMAIL PROTECTED] wrote: [...] Now I know that xmlTreeParse uses the libxml facilities for downloading and parsing off the web. Along with one of our network people, I did some packet sniffing and it looks like libxml doesn't go through our proxy server (it tries to directly connect to the above URL), which is the reason for the error. Is there anyway to force it through the proxy? Am I missing some setting or option? If I download the xml file and parse it locally it works without error. Please Note that the URL is valid and I can open it in my browser. Also note that I must start R with the --internet2 option so it'll use our proxy server. That's your problem. You *can* use proxies without --internet2 (see ?download.file) and the XML code uses the standard version of the code. The first issue is that you have not configured R to use your proxy, so please get that working. Issue two is that you may need to get an older version of XML compiled against an older libxml, as the current one has not been tested. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] 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] Boxplot, space to axis
Hello Deepayan, thanks for your suggestion, xaxs='i' works, but it leaves no space at all. I though this may be configurable by a real value. kind regards, Arne -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Deepayan Sarkar Sent: 30 September 2004 17:12 To: [EMAIL PROTECTED] Cc: Muller, Arne PH/FR Subject: Re: [R] Boxplot, space to axis On Thursday 30 September 2004 09:41, [EMAIL PROTECTED] wrote: Hello, I've crearted a boxplot with 84 boxes. So fat everything is as I expect, but there is quite some space between the 1st box and axis 2 and the last box and axis 4. Since 84 boxes get very slim anyway I'd like to discribute as much of the horizontal space over the x-axis. Maybe I've forgotten about a graphics parameter? Perhaps par(xaxs = i) ? Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] expand.model.frame gives object not found
Hello, I am a (relatively) experienced programmer, but new to R. I have a problem using R 1.9.1. I have fit some data using glm(), from within a function: formula = as.formula(paste(depvarname, ~, rhs), env=globalenv()) return (glm(formula, family=binomial(link=logit))) I have now come back to the formula and want to add some more variables to it. So I do: expand.model.frame(formulaname, ~ new_variable) but I get the response Error in eval(expr, envir, enclos) : Object foreignaid.dummy not found where foreignaid.dummy is my dependent variable. However, foreignaid.dummy is clearly visible in the global environment: ls(pat=foreignaid.dummy, envir=globalenv()) [1] foreignaid.dummy ... So why is my dependent variable lost? I have read the earlier comments on the same topic, but they seem to indicate that a previous bug was fixed. Am I missing the point about scoping? Any help much appreciated. David Hugh-Jones Essex University Govt Dept __ [EMAIL PROTECTED] 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] function by
Hi, I'm just getting started with R and I'm having problems with some simple operations: I want to get the the sum of the column SStot for each year using the function by. The data set is named SS. I've tried this: by (SS, year, sum(SStot)) and it's not working. Is it because there's a different number of rows for each year? How else can I do this? -- Emilie Berthiaume Graduate student Biology Departement Université de Sherbrooke 2500 boul. de l'Université Sherbrooke, Québec J1K 2R1 CANADA Tél: 1-819-821-8000 poste 2059 Fax: 1-819-821-8049 [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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] Boxplot, space to axis
On Thu, 2004-09-30 at 10:22, [EMAIL PROTECTED] wrote: Hello Deepayan, thanks for your suggestion, xaxs='i' works, but it leaves no space at all. I though this may be configurable by a real value. kind regards, Arne -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Deepayan Sarkar Sent: 30 September 2004 17:12 To: [EMAIL PROTECTED] Cc: Muller, Arne PH/FR Subject: Re: [R] Boxplot, space to axis On Thursday 30 September 2004 09:41, [EMAIL PROTECTED] wrote: Hello, I've crearted a boxplot with 84 boxes. So fat everything is as I expect, but there is quite some space between the 1st box and axis 2 and the last box and axis 4. Since 84 boxes get very slim anyway I'd like to discribute as much of the horizontal space over the x-axis. Maybe I've forgotten about a graphics parameter? Perhaps par(xaxs = i) ? Deepayan Here is a possible solution, albeit a little kludgy. The problem is that there is no way to define the x axis range in the call to boxplot(), which would allow you to make some adjustments that way. If you trace through the code for boxplot() and then bxp() [the latter actually does the plotting], you could figure out how the range of the x axis is computed and the factors that influence that calculation. With that knowledge, you could feasibly adjust the 'at' argument for the placement of the boxes. However, that may be more complicated than my approach below. Create some test data: set.seed(2) MyData - matrix(rnorm(84 * 100), ncol = 84) and then plot it normally: boxplot(as.data.frame(MyData)) You can then see the par(usr) values: par(usr) [1] -2.86 87.86 -4.379829 3.844485 Note the extra space on the x axis range. Now, let's control that part of the process: # Open a new plotting device plot.new() # Now specify the plotting coordinate system # There are 84 boxes, so let's add one unit before # and after to the 'xlim'. Also, specify 'i' for # xaxs, so there is no expansion of the x axis # range as per the default. plot.window(xlim = c(0, 85), ylim = range(MyData), xaxs = i) # Now do the boxplot, setting 'add = TRUE' so that # the plot is added to the current window, also # specifying the 'at' argument boxplot(as.data.frame(MyData), add = TRUE, at = 1:84) Now note the par(usr) values: par(usr) [1] 0.00 85.00 -4.379829 3.844485 You can do further adjustments to the x axis range as you require in the call to plot.window(). HTH, Marc Schwartz __ [EMAIL PROTECTED] 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] function by
?by FUN: a function to be applied to data frame subsets of 'data'. ...: further arguments to 'FUN'. by (SS, year, sum) /E Emilie Berthiaume wrote: Hi, I'm just getting started with R and I'm having problems with some simple operations: I want to get the the sum of the column SStot for each year using the function by. The data set is named SS. I've tried this: by (SS, year, sum(SStot)) and it's not working. Is it because there's a different number of rows for each year? How else can I do this? -- Emilie Berthiaume Graduate student Biology Departement Université de Sherbrooke 2500 boul. de l'Université Sherbrooke, Québec J1K 2R1 CANADA Tél: 1-819-821-8000 poste 2059 Fax: 1-819-821-8049 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin _ tel: 0049-30-83875219 'v' http://www.molgen.mpg.de/~wolski / \ mail: [EMAIL PROTECTED] ---W-W [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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 a text codebook
Is there a currently existing method in an R package for creating a codebook from a dataframe? Preferably, I would like to be able to export to a text file all relevant information. Thanks, Harold [[alternative HTML version deleted]] __ [EMAIL PROTECTED] 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] Rpy vs RSPython
On Thu, Sep 30, 2004 at 09:57:53AM -0400, Rajarshi Guha wrote: Rpy seems easier to get up and running with, but does anybody have any comments regarding which would be a better system to work with in the long run? I've been using rpy for a number of months and have been very pleased with it. On the other hand, I haven't tried RSPython so I can't really compare. + seth __ [EMAIL PROTECTED] 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] Can't load rgl library
Hello, [EMAIL PROTECTED] schrieb: Hi, I've installed rgl package through R CMD INSTALL on a Debian-Sarge machine (PIV) without any compiling error (see attached file), but when trying to load this package within R (and also Rcmdr library) I get: library(rgl) RGL: GLX extension missing on server Error in firstlib(which.lib.loc, package) : error rgl_init error in library(rgl) : .First.lib failed Segmentation fault Sounds like you're missing opengl/ xlibmesa(gl) +(glut) packages; make sure that these packages are installed and work flawlessly. HtH __ [EMAIL PROTECTED] 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 any way to release memory in running time?
?gc /E [EMAIL PROTECTED] wrote: Hi all, I am doing some intensive computation right now. My system is Pentium4 3.20G + 1.0G RAM + WindowsXP + R1.9.1. It seems my computer is very powerful. However, when I do some simple matrix algebra operations based on a matrix (DD) with dimension 500 by 2, I found that the consumption of RAM is huge. For example, the command a - 1 - DD[,2] eats my 100M RAM. Does anyone know how to release memory in the middle of program (running time)? BTW, the command rm() does not free memory unless you quit R as I as know. Thanks in advance. Rui __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin _ tel: 0049-30-83875219 'v' http://www.molgen.mpg.de/~wolski / \ mail: [EMAIL PROTECTED] ---W-W [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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] Can't load rgl library
Hello, [EMAIL PROTECTED] schrieb: Hi, I've installed rgl package through R CMD INSTALL on a Debian-Sarge machine (PIV) without any compiling error (see attached file), but when trying to load this package within R (and also Rcmdr library) I get: library(rgl) RGL: GLX extension missing on server Error in firstlib(which.lib.loc, package) : error rgl_init error in library(rgl) : .First.lib failed Segmentation fault Same failure problem if I use the apt option (apt-get install r-cran-gl). I've searched through the R mail archives but couldn't find or understand the answer for this problem. I just forgot to say that you also could try to rename /usr/share/tls (IIRC, its tls directory!) to /usr/share/tls_old and re-try loading the package. Maybe default installation doesn't recognize the working drivers, especially if you run NVidia driver on your box! HtH __ [EMAIL PROTECTED] 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] function by
On Thu, 30 Sep 2004, Witold Eryk Wolski wrote: ?by FUN: a function to be applied to data frame subsets of 'data'. ...: further arguments to 'FUN'. by (SS, year, sum) Quite likely by(SS, year, function(these) sum(these$SStot)) will be needed. There are probably some columns for which sum() won't work -thomas /E Emilie Berthiaume wrote: Hi, I'm just getting started with R and I'm having problems with some simple operations: I want to get the the sum of the column SStot for each year using the function by. The data set is named SS. I've tried this: by (SS, year, sum(SStot)) and it's not working. Is it because there's a different number of rows for each year? How else can I do this? -- Emilie Berthiaume Graduate student Biology Departement Université de Sherbrooke 2500 boul. de l'Université Sherbrooke, Québec J1K 2R1 CANADA Tél: 1-819-821-8000 poste 2059 Fax: 1-819-821-8049 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin _ tel: 0049-30-83875219 'v' http://www.molgen.mpg.de/~wolski / \ mail: [EMAIL PROTECTED] ---W-W [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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__ [EMAIL PROTECTED] 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 a text codebook
On Thu, 30 Sep 2004, Doran, Harold wrote: Is there a currently existing method in an R package for creating a codebook from a dataframe? Preferably, I would like to be able to export to a text file all relevant information. There's something along these lines (though not quite what you want) in the latest version of the foreign package. The function write.foreign writes out two text files, one of data and one of code to read those data into some other package. It currently handles SPSS and Stata, and writeForeignSPSS writes out variable names and factor levels into the SPSS code file. It doesn't handle more complicated things such as dates, though. -thomas __ [EMAIL PROTECTED] 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] Using try()
Thanks, Spencer! As a neophyte to the R mailing lists, I shall follow the guidelines of the posting guide. As for my specific question (which concerns R 1.9.1 on WinXP, using WinEdt as my editor), I solved it myself in the following manner: options( show.error.messages = FALSE, error=expression( NULL ) ) # supresses the error messages and stops for( ... values of p and q ... ){ lo = try( arima1 - arima( y, order=c( p, 0, q ) ) if( !inherits( lo, try-error ) ){ ... code here ... } } options( show.error.messages = TRUE, error=NULL ) # brings back the error messages and stops Following a tip from ?stop, it's quite adviseable to bring back the stops and error messages after the loop! Thanks, Nate On Thu, 30 Sep 2004, Spencer Graves wrote: Are you using ESS? If yes, can you try to code in RGui, without Emacs or XEmacs? If that fails, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html;, and tell us which version of R, what operating system, etc. hope this helps. spencer graves __ [EMAIL PROTECTED] 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: Vectorising and loop (was Re: [R] optim alog-likelihoodfunction)
Zhen Pang nusbj at hotmail.com writes: : : Mr. Grothendieck does suggest me to paste the data here. I just show a small : one here. I must metion that I made a mistake in my former email. The first : column should be j and is greater than the second column. I have corrected : ll. : : z is the matrix below : : 2 1 3 : 3 1 1 : 3 3 1 : 5 2 4 : : k-max(z[,1]) : ll - function(theta) : {t-0 :for (ii in 1:k) : {t-t+exp(theta[ii])} :lll-0 :x00-1/(1+t) :x0-x00*exp(theta) : for (m in 1:length(z[,1])) :{j-z[m,1] : i-z[m,2] : a-z[m,3] : l-i:(k-j+i) : s-rep(0,k) : s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) : # we only define some of s to be non-zero, since dim(l) might be smaller : than dim(s) : ss-sum(s*x0) # ss is a weighted sum of x0 : lll-lll+a*log(ss) : } : -lll : # the negative sign is to find the maximum of the log-likelihood function. : It can be omitted if we #use the finscale option in optim. : } : : Then I need to optim(b0,ll,hessian=T), : where b0-c(0.8331934, 20.8009068, -7.0893623, 1.2109221, 18.7213273). : : optim(b0,ll,hessian=T) : $par : [1] 0.8331934 20.8009068 -7.0893623 1.2109221 18.7213273 : : $value : [1] 5.182791 : : $counts : function gradient : 52 NA : : $convergence : [1] 0 : : $message : NULL : : $hessian : [,1] [,2] [,3] [,4] [,5] : [1,] 1.065814e-08 -9.325873e-09 0.00e+00 -3.330669e-10 -2.109424e-09 : [2,] -9.325873e-09 8.887936e-01 -3.330669e-10 -1.620926e-08 -8.887936e-01 : [3,] 0.00e+00 -3.330669e-10 -6.661338e-10 0.00e+00 0.00e+00 : [4,] -3.330669e-10 -1.620926e-08 0.00e+00 7.549517e-09 7.105427e-09 : [5,] -2.109424e-09 -8.887936e-01 0.00e+00 7.105427e-09 8.887936e-01 : : : I have tried to use eval() and modify my function, it seems to be able to : remove the m loop, however, optim() can not recognize it. So my main concern : is to avoid the loop and optim() can works for my function. Thanks. I suspect your code may be wrong but taking it at face value s does not depend on the input theta so precalculate it as a matrix whose mth column is s[,m]. Also the only purpose of the loop indexed by m is to calculate lll and the final iteration of that loop calculates an lll which does not depend on the prior iterations so remove the loop and just run the final iteration. Similarly we only need the final value of x0 that is calculated. Note that the value of ll(b0), your loopy function, and ll2(b0) the one line non-loopy function using the precalculated s, give the same result: R z - matrix(c( 2,1,3, 3,1,1, 3,3,1, 5,2,4), 4, 3, byrow = TRUE) R b0-c(0.8331934, 20.8009068, -7.0893623, 1.2109221, 18.7213273) R R k-max(z[,1]) R s - apply(z, 1, function(z) { + j-z[1]; i-z[2] + l-i:(k-j+i) + s-rep(0,k) + s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) + s + }) R ll2 - function(theta) { + - sum(z[,3]*log(crossprod(s, exp(theta)* 1/(1+sum(exp(theta)) + } R ll(b0) # this is the ll function from your post [1] 5.182791 R ll2(b0) [1] 5.182791 __ [EMAIL PROTECTED] 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] scan with Apple
Dear Madam, Sir, I wonder me how I can scan a file in R when I work at an Apple (Mac OS X). I know how to do in a Windows surrounding, but not in the Apple one. Can you help me? Hope to hear from you and thanks in front, Lilian Roos PS. I have to scan verzoeken2.txt and this file is at my USB DISK drive. = All the freaky people make a beauty of the world - Michael Franti ___ Declare Yourself - Register online to vote today! __ [EMAIL PROTECTED] 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] dot density maps
On Wed, 22 Sep 2004, Johannes SCHNITZLER wrote: Dear All, In the moment i'm using the map and maptools package to read shapefiles and display the maps. I'm looking for the possibility to draw points (randomly positioned or positioned according to a grid) into the polygons instead of filling the polygons with colors. I apologize for not replying earlier. I think that you can combine the polylist class from the maptools package with the csr function in the splancs package to position points randomly (the gridpts() finction can be used instead of csr() to give grid points): library(maptools) library(splancs) source(dotsinpolys.R) x - read.shape(system.file(shapes/sids.shp, package=maptools)[1]) ncpolys - Map2poly(x, raw=FALSE) names(x$att.data) plot(ncpolys) try1 - dotsInPolys(ncpolys, x$att.data$SID74) xx - lapply(try1, function(x) {if (!is.null(x)) points(x, pch=18, + col=red)}) try2 - dotsInPolys(ncpolys, x$att.data$SID74, f=gridpts) plot(ncpolys) xx - lapply(try2, function(x) {if (!is.null(x)) points(x, pch=18, + col=red)}) where dotsinpolys.R is: dotsInPolys - function(pl, x, f=csr) { if (!inherits(pl, polylist)) stop(not a polylist object) if (length(pl) != length(x)) stop(different lengths) n - length(pl) res - vector(mode=list, length=n) for (i in 1:n) { if (x[i] 0) { if (attr(pl[[i]], nParts) == 1) { if (attr(pl[[i]], ringDir) != 1) warning(paste(hole with content at:, i)) res[[i]] - f(matrix(c(ncpolys[[i]]), ncol=2), x[i]) } else { areas - rep(0, attr(pl[[i]], nParts)) for (j in 1:attr(pl[[i]], nParts)) { if (attr(pl[[i]], ringDir)[j] == 1) { from - attr(pl[[i]], pstart)$from[j] to - attr(pl[[i]], pstart)$to[j] areas[j] - areapl(matrix(c(ncpolys[[i]][from:to,]), ncol=2)) } } pareas - areas/sum(areas) px - as.integer(round(pareas*x[i], digits = 0)) for (j in 1:attr(pl[[i]], nParts)) { if (px[j] 0) { from - attr(pl[[i]], pstart)$from[j] to - attr(pl[[i]], pstart)$to[j] pj - matrix(c(ncpolys[[i]][from:to,]), ncol=2) res[[i]] - rbind(res[[i]], f(pj, px[j])) } } } res[[i]] - matrix(res[[i]], ncol=2) } } res } The extra work is because not all polygon units are a single polygon, and some may be lakes within other polygons, doubling up on area. I suspect that the more sophisticated polygons in spatstat may be able to prevent sampled points landing in the water. In multi-polygon units, points are divided by relative area, and because of rounding may not be exactly the same as the input count. The gridded points are also not likely to add up exactly. Could you indicate whether this function is any use, and if you would like it added to some suitable package? Roger Bivand For example: a map (shapefile) with 10 countries, 15 points in the polygon of country A, 20 points in the polygon of country B. Thank you in advance for your help Johannes [[alternative HTML version deleted]] __ [EMAIL PROTECTED] 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] __ [EMAIL PROTECTED] 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 a text codebook
Something like summary() will produce the start of a codebook for a dataset within a data.frame, but it probably would need to be munged up a bit more. Actually, the first use of literate statistical analysis (noweb-style) was done to produce a codebook. On Thu, 30 Sep 2004 14:35:03 -0400, John Fox [EMAIL PROTECTED] wrote: Dear Harold, I'm not sure what you have in mind, but take a look at the prompt() function, which can create a skeleton .Rd (R documentation) for a data frame. It will distinguish between numeric variables and factors, and will show the various levels of each factor. I don't think that there's any other relevant information in the data frame. I hope that this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold Sent: Thursday, September 30, 2004 11:39 AM To: [EMAIL PROTECTED] Subject: [R] Creating a text codebook Is there a currently existing method in an R package for creating a codebook from a dataframe? Preferably, I would like to be able to export to a text file all relevant information. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- A.J. Rossini [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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] scan with Apple
On Thu, 30 Sep 2004, Lilian Roos wrote: Dear Madam, Sir, I wonder me how I can scan a file in R when I work at an Apple (Mac OS X). I know how to do in a Windows surrounding, but not in the Apple one. Can you help me? Hope to hear from you and thanks in front, Lilian Roos PS. I have to scan verzoeken2.txt and this file is at my USB DISK drive. The same way. You need to know the path for the file. Look in the Finder to see the name of your USB disk drive. Suppose it is called UNNAMED (which is the default for some brands). Then scan(/Volumes/UNNAMED/verzoeken2.txt) would work -thomas = All the freaky people make a beauty of the world - Michael Franti ___ Declare Yourself - Register online to vote today! __ [EMAIL PROTECTED] 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 __ [EMAIL PROTECTED] 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] histograms with more than one variable
Hello. I want to plot the distribution of a continuous variable (y) in each of two groups on the same graph as histograms. I suppose one could call this a 2-d histogram? Can this be done in R? Here is a typical data.set: y group 1.2 1 3.3 1 2.4 2 5.7 1 0.2 2 etc. Bill Shipley Subject Matter Editor, Ecology North American Editor, Annals of Botany Département de biologie, Université de Sherbrooke, Sherbrooke (Québec) J1K 2R1 CANADA [EMAIL PROTECTED] http://callisto.si.usherb.ca:8080/bshipley/ http://callisto.si.usherb.ca:8080/bshipley/ [[alternative HTML version deleted]] __ [EMAIL PROTECTED] 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] histograms with more than one variable
Sounds like you want something similar to: library(lattice) y - rnorm(40) group - rep(1:2, each=20) histogram(~y | group) Andy From: Bill Shipley y group 1.2 1 3.3 1 2.4 2 5.7 1 0.2 2 etc. Bill Shipley Subject Matter Editor, Ecology North American Editor, Annals of Botany Département de biologie, Université de Sherbrooke, Sherbrooke (Québec) J1K 2R1 CANADA [EMAIL PROTECTED] http://callisto.si.usherb.ca:8080/bshipley/ http://callisto.si.usherb.ca:8080/bshipley/ [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] 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] pointsize in png graphics
Hi [EMAIL PROTECTED] wrote: Dear all, I'm trying to produce 2 png files, one consisting of an image plot and a color-table (also an image plot) and the other one consisting of 4 image plots and a color table. I'd like the color table to be exactly the same. The way I proceded is the following: for one plot and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() for 4 plots and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() The only difference is the layout of the plot. The outcome though is completely different. It seems that the definition of the size of one point is different in the two plots as the graphics with 4 plots and color table has smaller fonts and smaller margins. What do I have to do to be sure the size of the fonts is the same in two different png graphcis of exactly the same size when the pointsize is the same? I'm working with Windows XP and tried both running the R script as a batch job and running it within Emacs with ESS. I think the problem is that R is trying to think for you. R automatically reduces text size when there are more than three plots (or more than three cells in a layout) on a page. Below are two suggestions for making the two layouts the same: # dummy image plot dummyplot - function(col) { plot.new() usr - par(usr) rect(usr[1], usr[3], usr[2], usr[4], col=col) } # original problem x11() layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) dummyplot(orange) dummyplot(blue) x11() layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) dummyplot(red) dummyplot(yellow) dummyplot(pink) dummyplot(violet) dummyplot(blue) # solution 1: make second layout same as first # leave first page alone # revert auto cex decrease on second page x11() layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) dummyplot(orange) dummyplot(blue) x11() layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0, ### CHANGES HERE cex=1.5, mex=0.66) dummyplot(red) dummyplot(yellow) dummyplot(pink) dummyplot(violet) dummyplot(blue) # solution 2: make first layout same as second # make same number of columns/rows in first layout # leave second page alone x11() layout(### CHANGES HERE matrix(c(1, 1, 2, 1, 1, 2), ncol = 3, nrow = 2, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) dummyplot(orange) dummyplot(blue) x11() layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c(3, 3, 1), heights = c(1, 1)) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) dummyplot(red) dummyplot(yellow) dummyplot(pink) dummyplot(violet) dummyplot(blue) Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ [EMAIL PROTECTED] 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] dev.print and win.print
Dear R Users: Was there an answer to the question about using dev.print and win.print to print as horizontal = FALSE, please? I was working on it and I didn't find the solution. R 1.9.1 Windows Thanks, Erin Hodgess mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] 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] polr (MASS) and lrm (Design) differences in tests of statistical signifcance
Greetings: I'm running R-1.9.1 on Fedora Core 2 Linux. I tested a proportional odds logistic regression with MASS's polr and Design's lrm. Parameter estimates between the 2 are consistent, but the standard errors are quite different, and the conclusions from the t and Wald tests are dramatically different. I cranked the abstol argument up quite a bit in the polr method and it did not make the differences go away. So 1. Can you help me see why the std. errors in the polr are so much smaller, and 2. Can I hear more opinions on the question of t vs. Wald in making these signif tests. So far, I understand the t is based on the asymptotic Normality of the estimate of b, and for finite samples b/se is not exactly distributed as a t. But I also had the impression that the Wald value was an approximation as well. summary(polr(as.factor(RENUCYC) ~ DOCS + PCT65PLS*RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data=elaine1)) Re-fitting to get Hessian Call: polr(formula = as.factor(RENUCYC) ~ DOCS + PCT65PLS * RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data = elaine1) Coefficients: Value Std. Error t value DOCS 0.004942217 0.002952001 1.674192 PCT65PLS 0.454638558 0.113504288 4.005475 RANNEY2 0.110473483 0.010829826 10.200855 OLDCRASH 0.139808663 0.042245692 3.309418 FISCAL2 0.025592117 0.011465812 2.232037 PCTMETRO 0.018184093 0.007792680 2.333484 ADMLICEN -0.028490387 0.011470999 -2.483688 PCT65PLS:RANNEY2 -0.008559228 0.001456543 -5.876400 Intercepts: Value Std. Error t value 2|36.6177 0.301921.9216 3|47.1524 0.277325.7938 4|5 10.5856 0.214949.2691 5|6 12.2132 0.185865.7424 6|8 12.2704 0.185666.1063 8|10 13.0345 0.218459.6707 10|12 13.9801 0.351739.7519 12|18 14.6806 0.558726.2782 Residual Deviance: 587.0995 AIC: 619.0995 lrm(RENUCYC ~ DOCS + PCT65PLS*RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data=elaine1) Logistic Regression Model lrm(formula = RENUCYC ~ DOCS + PCT65PLS * RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data = elaine1) Frequencies of Responses 2 3 4 5 6 8 10 12 18 21 12 149 46 1 10 6 2 2 Frequencies of Missing Values Due to Each Variable RENUCYC DOCS PCT65PLS RANNEY2 OLDCRASH FISCAL2 PCTMETRO ADMLICEN 50060505 Obs Max Deriv Model L.R. d.f. P C Dxy 249 7e-05 56.58 8 0 0.733 0.465 Gamma Tau-a R2 Brier 0.47 0.278 0.22 0.073 Coef S.E. Wald Z P y=3-6.617857 6.716688 -0.99 0.3245 y=4-7.152561 6.716571 -1.06 0.2869 y=5 -10.585705 6.74 -1.57 0.1164 y=6 -12.213340 6.755656 -1.81 0.0706 y=8 -12.270506 6.755571 -1.82 0.0693 y=10 -13.034584 6.756829 -1.93 0.0537 y=12 -13.980235 6.767724 -2.07 0.0389 y=18 -14.680760 6.786639 -2.16 0.0305 DOCS 0.004942 0.002932 1.69 0.0918 PCT65PLS 0.454653 0.552430 0.82 0.4105 RANNEY2 0.110475 0.076438 1.45 0.1484 OLDCRASH 0.139805 0.042104 3.32 0.0009 FISCAL2 0.025592 0.011374 2.25 0.0245 PCTMETRO 0.018184 0.007823 2.32 0.0201 ADMLICEN-0.028490 0.011576 -2.46 0.0138 PCT65PLS * RANNEY2 -0.008559 0.006417 -1.33 0.1822 -- Paul E. Johnson email: [EMAIL PROTECTED] Dept. of Political Sciencehttp://lark.cc.ku.edu/~pauljohn 1541 Lilac Lane, Rm 504 University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66044-3177 FAX: (785) 864-5700 __ [EMAIL PROTECTED] 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] polr (MASS) and lrm (Design) differences in tests of statistical signifcance
Dear Paul, I tried polr() and lrm() on a different problem and (except for the difference in signs for the cut-points/intercepts) got identical results for both coefficients and standard errors. There might be something ill-conditioned about your problem that produces the discrepancy -- I noticed, for example, that some of the upper categories of the response are very sparse. Perhaps the two functions use different forms of the information matrix. I expect that someone else will be able to supply more details. I believe that the t-statistics in the polr() output are actually Wald statistics. I hope this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Johnson Sent: Thursday, September 30, 2004 4:41 PM To: r help Subject: [R] polr (MASS) and lrm (Design) differences in tests of statistical signifcance Greetings: I'm running R-1.9.1 on Fedora Core 2 Linux. I tested a proportional odds logistic regression with MASS's polr and Design's lrm. Parameter estimates between the 2 are consistent, but the standard errors are quite different, and the conclusions from the t and Wald tests are dramatically different. I cranked the abstol argument up quite a bit in the polr method and it did not make the differences go away. So 1. Can you help me see why the std. errors in the polr are so much smaller, and 2. Can I hear more opinions on the question of t vs. Wald in making these signif tests. So far, I understand the t is based on the asymptotic Normality of the estimate of b, and for finite samples b/se is not exactly distributed as a t. But I also had the impression that the Wald value was an approximation as well. summary(polr(as.factor(RENUCYC) ~ DOCS + PCT65PLS*RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data=elaine1)) Re-fitting to get Hessian Call: polr(formula = as.factor(RENUCYC) ~ DOCS + PCT65PLS * RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data = elaine1) Coefficients: Value Std. Error t value DOCS 0.004942217 0.002952001 1.674192 PCT65PLS 0.454638558 0.113504288 4.005475 RANNEY2 0.110473483 0.010829826 10.200855 OLDCRASH 0.139808663 0.042245692 3.309418 FISCAL2 0.025592117 0.011465812 2.232037 PCTMETRO 0.018184093 0.007792680 2.333484 ADMLICEN -0.028490387 0.011470999 -2.483688 PCT65PLS:RANNEY2 -0.008559228 0.001456543 -5.876400 Intercepts: Value Std. Error t value 2|36.6177 0.301921.9216 3|47.1524 0.277325.7938 4|5 10.5856 0.214949.2691 5|6 12.2132 0.185865.7424 6|8 12.2704 0.185666.1063 8|10 13.0345 0.218459.6707 10|12 13.9801 0.351739.7519 12|18 14.6806 0.558726.2782 Residual Deviance: 587.0995 AIC: 619.0995 lrm(RENUCYC ~ DOCS + PCT65PLS*RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data=elaine1) Logistic Regression Model lrm(formula = RENUCYC ~ DOCS + PCT65PLS * RANNEY2 + OLDCRASH + FISCAL2 + PCTMETRO + ADMLICEN, data = elaine1) Frequencies of Responses 2 3 4 5 6 8 10 12 18 21 12 149 46 1 10 6 2 2 Frequencies of Missing Values Due to Each Variable RENUCYC DOCS PCT65PLS RANNEY2 OLDCRASH FISCAL2 PCTMETRO ADMLICEN 500605 05 Obs Max Deriv Model L.R. d.f. P C Dxy 249 7e-05 56.58 8 0 0.733 0.465 Gamma Tau-a R2 Brier 0.47 0.278 0.22 0.073 Coef S.E. Wald Z P y=3-6.617857 6.716688 -0.99 0.3245 y=4-7.152561 6.716571 -1.06 0.2869 y=5 -10.585705 6.74 -1.57 0.1164 y=6 -12.213340 6.755656 -1.81 0.0706 y=8 -12.270506 6.755571 -1.82 0.0693 y=10 -13.034584 6.756829 -1.93 0.0537 y=12 -13.980235 6.767724 -2.07 0.0389 y=18 -14.680760 6.786639 -2.16 0.0305 DOCS 0.004942 0.002932 1.69 0.0918 PCT65PLS 0.454653 0.552430 0.82 0.4105 RANNEY2 0.110475 0.076438 1.45 0.1484 OLDCRASH 0.139805 0.042104 3.32 0.0009 FISCAL2 0.025592 0.011374 2.25 0.0245 PCTMETRO 0.018184 0.007823 2.32 0.0201 ADMLICEN-0.028490 0.011576 -2.46 0.0138 PCT65PLS * RANNEY2 -0.008559 0.006417 -1.33 0.1822 -- Paul E. Johnson email: [EMAIL PROTECTED] Dept. of Political Sciencehttp://lark.cc.ku.edu/~pauljohn 1541 Lilac Lane, Rm 504 University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66044-3177 FAX: (785) 864-5700 __ [EMAIL PROTECTED] mailing list
Re: Vectorising and loop (was Re: [R] optim alog-likelihoodfunction)
Thank you for your kind help. my s does not depend on the input theta. Code without loop is really efficient. From: Gabor Grothendieck [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Vectorising and loop (was Re: [R] optim alog-likelihoodfunction) Date: Thu, 30 Sep 2004 17:59:21 + (UTC) Zhen Pang nusbj at hotmail.com writes: : : Mr. Grothendieck does suggest me to paste the data here. I just show a small : one here. I must metion that I made a mistake in my former email. The first : column should be j and is greater than the second column. I have corrected : ll. : : z is the matrix below : : 2 1 3 : 3 1 1 : 3 3 1 : 5 2 4 : : k-max(z[,1]) : ll - function(theta) : {t-0 :for (ii in 1:k) : {t-t+exp(theta[ii])} :lll-0 :x00-1/(1+t) :x0-x00*exp(theta) : for (m in 1:length(z[,1])) :{j-z[m,1] : i-z[m,2] : a-z[m,3] : l-i:(k-j+i) : s-rep(0,k) : s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) : # we only define some of s to be non-zero, since dim(l) might be smaller : than dim(s) : ss-sum(s*x0) # ss is a weighted sum of x0 : lll-lll+a*log(ss) : } : -lll : # the negative sign is to find the maximum of the log-likelihood function. : It can be omitted if we #use the finscale option in optim. : } : : Then I need to optim(b0,ll,hessian=T), : where b0-c(0.8331934, 20.8009068, -7.0893623, 1.2109221, 18.7213273). : : optim(b0,ll,hessian=T) : $par : [1] 0.8331934 20.8009068 -7.0893623 1.2109221 18.7213273 : : $value : [1] 5.182791 : : $counts : function gradient : 52 NA : : $convergence : [1] 0 : : $message : NULL : : $hessian : [,1] [,2] [,3] [,4] [,5] : [1,] 1.065814e-08 -9.325873e-09 0.00e+00 -3.330669e-10 -2.109424e-09 : [2,] -9.325873e-09 8.887936e-01 -3.330669e-10 -1.620926e-08 -8.887936e-01 : [3,] 0.00e+00 -3.330669e-10 -6.661338e-10 0.00e+00 0.00e+00 : [4,] -3.330669e-10 -1.620926e-08 0.00e+00 7.549517e-09 7.105427e-09 : [5,] -2.109424e-09 -8.887936e-01 0.00e+00 7.105427e-09 8.887936e-01 : : : I have tried to use eval() and modify my function, it seems to be able to : remove the m loop, however, optim() can not recognize it. So my main concern : is to avoid the loop and optim() can works for my function. Thanks. I suspect your code may be wrong but taking it at face value s does not depend on the input theta so precalculate it as a matrix whose mth column is s[,m]. Also the only purpose of the loop indexed by m is to calculate lll and the final iteration of that loop calculates an lll which does not depend on the prior iterations so remove the loop and just run the final iteration. Similarly we only need the final value of x0 that is calculated. Note that the value of ll(b0), your loopy function, and ll2(b0) the one line non-loopy function using the precalculated s, give the same result: R z - matrix(c( 2,1,3, 3,1,1, 3,3,1, 5,2,4), 4, 3, byrow = TRUE) R b0-c(0.8331934, 20.8009068, -7.0893623, 1.2109221, 18.7213273) R R k-max(z[,1]) R s - apply(z, 1, function(z) { + j-z[1]; i-z[2] + l-i:(k-j+i) + s-rep(0,k) + s[l]-choose(j,i)*choose((k-j),(l-i))/choose(k,l) + s + }) R ll2 - function(theta) { + - sum(z[,3]*log(crossprod(s, exp(theta)* 1/(1+sum(exp(theta)) + } R ll(b0) # this is the ll function from your post [1] 5.182791 R ll2(b0) [1] 5.182791 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html