Re: [R] SQLite: When reading a table, a \r is padded onto the last column. Why?
I guess you are using package RSQLite without telling us (or telling us the version), and that your example is incomplete? Using RSiteSearch(RSQLite Windows) quickly shows that this is a previously reported problem with the package, e.g.: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/72515.html I believe the issue is that RSQLite actually writes out a CRLF-terminated text file and imports that into SQLite. (I checked version 0.4-15.) It seems function safe.write() needs to be modified to write to a binary-mode connection since SQLite appears to require LF-terminated files. Using RODBC to work with SQLite databases works correctly even under Windows (and is much more efficient at writing to the database). [I am not sure who is actually maintaining RSQLite, so am Cc: both the stated maintainer and the person who prepared the package for distribution. The posting guide asked you to contact the maintainer: what response did _you_ get?] On Wed, 3 Jan 2007, Søren Højsgaard wrote: Hi, I put the iris data into a SQLite database with dbWriteTable(con, iris, iris, row.names=F, overwrite = T) Then I retrieve data from the database with rs - dbSendQuery(con, select * from iris) d1 - fetch(rs) dbClearResult(rs) Then I get head(d1) Sepal_Length Sepal_Width Petal_Length Petal_Width Species 1 5.1 3.5 1.4 0.2 setosa\r 2 4.9 3.0 1.4 0.2 setosa\r 3 4.7 3.2 1.3 0.2 setosa\r 4 4.6 3.1 1.5 0.2 setosa\r 5 5.0 3.6 1.4 0.2 setosa\r 6 5.4 3.9 1.7 0.4 setosa\r Can anyone explain the extra \r at the end? I am on Windows XP using R 2.4.1 Thanks in advance Søren __ 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 and provide commented, minimal, self-contained, reproducible code. -- 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__ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] arith-true mean() fails make check on IRIX
On Tue, 2 Jan 2007, [EMAIL PROTECTED] wrote: Hello, I am building R-2.4.1 on an SGI IRIX platform, using gcc 3.3. gmake check failed, and the arith-true.Rout.fail file indicated: is.na(mean(c(1,NA,NA)[-1], trim = .1, na.rm = TRUE)) [1] FALSE I tried the mean() command in R and got: mean(c(1,NA,NA)[-1], trim = .1, na.rm = TRUE) [1] Inf I think the problem is in the na.rm = TRUE, because I get: mean(c(1,NA,NA)[-1]) [1] NA How serious is this problem, and is there a workaround ? It indicates that your compiler is getting the wrong answer when computing 0./0, and that does look quite serious. You should get the same answer as mean(numeric(0)), and that should be NaN. As the compiler is very old, you might like to try updating it. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Hershey fonts for musical notation?
Hi, I'd like to know if it is possible to use Hershey vector fonts to create very primitive musical notation. If I can hang some whole notes on these lines X11() plot(0,0, xlim=c(0,10), ylim=c(0,10)) # Staves: for (i in c(seq(from=2,to=2.8,by=0.2),seq(from=4,to=4.8,by=0.2))) { abline(h=i) } it is enough. Best wishes, Atte Tenkanen University of Turku, Finland ___ P.S. By the way, right now the demo(Hershey) seems not to work in OSX version R 2.4.1. ... I get a message i - i + 1 Error in deparse(ei, control = c(showAttributes, useSource)) : invalid multibyte string __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] graphical parameters: margins
In this particular case 'An Introduction to R' has a comprehensive description of graphical parameters with figures (as do all good books on S/R e.g. MASS4 - since it has the same first author). On Tue, 2 Jan 2007, Ricardo Rodríguez - Your XEN ICT Team wrote: -- Ricardo Rodríguez Your XEN ICT Team Gavin Simpson[EMAIL PROTECTED] 2/1/2007 17:44 Either of these two gives you the answer help.search(graphical parameters) RSiteSearch(graphical parameters margin) more specifically, read ?par and in particular, the entry for parameter 'mar' and it's relatives. You might also need to add the axis label separately from the figure: opar - par(mar = c(5,7,4,2) +0.1) plot(1:10, ann = FALSE) # or plot(1:10, ylab = ) mtext(label, side = 2, line = 6) par(opar) 1) opar - par(mar = c(5,7,4,2) +0.1) creates 7.1 lines on the left of the plot and saves defaults 2) mtext(label, side = 2, line = 6) displays the axis label on line 6 to push it away from the plot axis. Repeat for other sides... 3) par(opar) resets to the defaults. HTH Thanks Gavin, I frequently reach the help page or any other document concerning the doubt, but at least for me it is by no means easy to correctly interpret their contents without the help of more experienced people. I do hope I will catch up ASAP! -- 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__ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hershey fonts for musical notation?
Hi, Atte De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Atte Tenkanen Envoyé : mercredi 3 janvier 2007 09:17 Hi, I'd like to know if it is possible to use Hershey vector fonts to create very primitive musical notation. [...] There is an example of a music score produced with R and the Hershey fonts in the book 'R Graphics', by Paul Murrell (Chapman Hall/CRC, 2005), page 15. The R Code is on the web page for the book: http://www.stat.auckland.ac.nz/~paul/RGraphics/examples-stevemiller.R BTW, I do a lot of things with R but for music scores I use the ABC language (http://www.walshaw.plus.com/abc/). You can output PostScript from it with Jef Moine's abcm2ps (http://moinejf.free.fr/). Happy new year! Christophe -- Christophe Declercq, MD Observatoire régional de la santé Nord-Pas-de-Calais 235, avenue de la recherche BP 86 F-59373 LOOS CEDEX Phone +33 3 20 15 49 24 Fax + 33 3 20 15 10 46 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] graphical parameters: margins
Prof Brian Ripley[EMAIL PROTECTED] 3/1/2007 09:22 In this particular case 'An Introduction to R' has a comprehensive description of graphical parameters with figures (as do all good books on S/R e.g. MASS4 - since it has the same first author). Thanks, Brian, I've reached both Introduction to R, particularly http://cran.r-project.org/doc/manuals/R-intro.html#Figure-margins, and MASS4 at Springer website. I think it is worth I ask the Three Wise Men for MASS4 as a present! Greetings, Ricardo __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hershey fonts for musical notation?
Hello Christophe, Thanks a lot! This is what I need. My purpose is to generate chords and I need interactive responses straight in R. I can output midi event lists as csv-files and convert them with a nice midicsv-program in linux- or OSX-console. Then it is easy to convert midi files to notes with Finale or other music notation program. Atte Hi, Atte De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Atte Tenkanen Envoyé : mercredi 3 janvier 2007 09:17 Hi, I'd like to know if it is possible to use Hershey vector fonts to create very primitive musical notation. [...] There is an example of a music score produced with R and the Hershey fonts in the book 'R Graphics', by Paul Murrell (Chapman Hall/CRC, 2005), page 15. The R Code is on the web page for the book: http://www.stat.auckland.ac.nz/~paul/RGraphics/examples-stevemiller.R BTW, I do a lot of things with R but for music scores I use the ABC language(http://www.walshaw.plus.com/abc/). You can output PostScript from it with Jef Moine's abcm2ps (http://moinejf.free.fr/). Happy new year! Christophe -- Christophe Declercq, MD Observatoire régional de la santé Nord-Pas-de-Calais 235, avenue de la recherche BP 86 F-59373 LOOS CEDEX Phone +33 3 20 15 49 24 Fax + 33 3 20 15 10 46 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 and provide commented, minimal, self-contained, reproducible code.
[R] optim
Hi! I'm trying to figure out how to use optim... I get some really strange results, so I guess I got something wrong. I defined the following function which should be minimized: errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { lambda - 1/sqrt(147) # error - abs(errHuber(localShifts,globalShift, #/home/sarah/Semesterarbeit/Sequences/R/R1593_filtered.data,3.48)) + #sum(abs(localShifts))*lambda error - sum(abs(localShifts))*lambda error # return the error to be minimized } Then I call optim: par - seq(length=9, from=0, by=0) lambda - 1/sqrt(147) optim(par, errorFunction, gr=NULL, method=Nelder-Mead, hessian=FALSE, globalShift, /home/sarah/Semesterarbeit/Sequences/R/R1593_filtered.data, experimentalPI=3.48, lambda = lambda) The output is: $par [1] 0.56350964 0.56350964 0.56350964 0.56350964 0. -0.29515957 [7] 0.00569937 0.32543297 0.18615880 $value [1] 0.2529198 $counts function gradient 31 31 $convergence [1] 0 $message [1] CONVERGENCE: REL_REDUCTION_OF_F = FACTR*EPSMCH Warning messages: 1: bounds can only be used with method L-BFGS-B in: optim(par, errorFunction, gr = NULL, method = Nelder-Mead, 2: NAs introduced by coercion If I change my error-function to errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { error - sum(abs(localShifts*lambda)) error # return the error to be minimized } or to: errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { error - sum(abs(localShifts))/sqrt(147) error # return the error to be minimized } The output is: $par [1] 6.018101e-20 6.018101e-20 6.018101e-20 6.018101e-20 0.00e+00 [6] 5.176245e-21 -4.002183e-21 -8.254019e-20 3.231412e-21 $value [1] 2.768593e-20 $counts function gradient 76 76 $convergence [1] 0 $message [1] CONVERGENCE: NORM OF PROJECTED GRADIENT = PGTOL Warning messages: 1: bounds can only be used with method L-BFGS-B in: optim(par, errorFunction, gr = NULL, method = Nelder-Mead, 2: NAs introduced by coercion - What is wrong with the first version? Thanks for the help! Sarah __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Lattice / Trellis analog of axis(graphics) ?
My question is so basic that I am (almost too) embarrassed to admit that I could not find an answer after an hour's worth of homework. What is the Trellis / Lattice analog for the axis(graphics) function that enables the creation of axes in locations other than the default (i.e., bottom for X axis and right for Y axis) ? For example when plotting mileage against weight (in American units), one might want to also include a second X axis on the top margin (e.g., axis() pos = 3) with fuel mileage in metric units. xyplot(Mileage ˜ Weight, data = fuel.frame) Thank you, humbly yours, Derek Eder platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.0 year 2006 month 10 day 03 svn rev 39566 language R version.string R version 2.4.0 (2006-10-03) -- Derek N. Eder Gothenburg University VINKLA - Vigilance and Neurocognition laboratory SU/Sahlgrenska Utvecklingslab 1, Med Gröna stråket 8 SE 413 45 Göteborg (Gothenburg) Sverige (Sweden) +46 (031)* 342 8261 (28261 inom Sahlgrenska) +46 0704 915 714 (mobile) +46 (031) 25 97 07 (home) * omit the 0 when calling from outside Sweden __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R and threading
Hi, I am considering using R to integrate with a Java application. However, before deciding upon R I need to understand if R is capable of dealing with multiple requests simulataneously. Is a single instance of R capable of dealing with multiple simulataneous requests or does a new instance of R have to be started for each request? I have read Luke Tierney's 2001 notes on threading at http://www.stat.uiowa.edu/~luke/R/thrgui/thrgui.pdf. Have these concepts been introduced into the R engine? Regards Dr.Simon Pears _ Be the first to hear what's new at MSN - sign up to our free newsletters! __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] RODBC compile error with R 2.4.1
Hi All, I'm getting the following error, could anyone help please? $ R CMD INSTALL RODBC_1.1-7.tar.gz * Installing *source* package 'RODBC' ... checking for gcc... gcc -std=gnu99 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 -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sql.h usability... yes checking sql.h presence... yes checking for sql.h... yes checking sqlext.h usability... yes checking sqlext.h presence... yes checking for sqlext.h... yes checking for library containing SQLTables... -lodbc checking for SQLLEN... yes checking for SQLULEN... yes checking for long... yes checking size of long... configure: error: cannot compute sizeof (long), 77 See `config.log' for more details. ERROR: configuration failed for package 'RODBC' ** Removing '/usr/local/lib/R/library/RODBC' ** Restoring previous '/usr/local/lib/R/library/RODBC' version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) Regards, Matthew __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice / Trellis analog of axis(graphics) ?
Hi Derek, see ?xyplot and ?panel.axis Hint: RSiteSearch(panel.axis) will point you to examples. Thomas Derek Eder wrote: My question is so basic that I am (almost too) embarrassed to admit that I could not find an answer after an hour's worth of homework. What is the Trellis / Lattice analog for the axis(graphics) function that enables the creation of axes in locations other than the default (i.e., bottom for X axis and right for Y axis) ? For example when plotting mileage against weight (in American units), one might want to also include a second X axis on the top margin (e.g., axis() pos = 3) with fuel mileage in metric units. xyplot(Mileage ˜ Weight, data = fuel.frame) [...] __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R's capaability of dealing with multiple requests
Hi, I am interested in integrating R with a Java front end. Before deciding to use R I am concerned about multi-threading. I have been investigating R's capability of dealing with multiple requests simultaneously (multi-threading) and have looked at Luke Tierney's 2001 notes for ideas for future releases of R at http://www.stat.uiowa.edu/~luke/R/thrgui/thrgui.pdf Is a single instance of R capable of dealing with multiple requests simultanouesly or does a new instance of R have to be created for each request? Regards, Dr. Simon Pears __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] optim
The function needs to have a single parameter. Then extract each parameter. For example, or see first example in help for optim. errorFunction - function(params) { localShifts - params[1] etc Gerster Sarah [EMAIL PROTECTED] 01/03/07 9:22 PM Hi! I'm trying to figure out how to use optim... I get some really strange results, so I guess I got something wrong. I defined the following function which should be minimized: errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { lambda - 1/sqrt(147) # error - abs(errHuber(localShifts,globalShift, # /home/sarah/Semesterarbeit/Sequences/R/R1593_filtered.data,3.48)) + #sum(abs(localShifts))*lambda error - sum(abs(localShifts))*lambda error # return the error to be minimized } Then I call optim: par - seq(length=9, from=0, by=0) lambda - 1/sqrt(147) optim(par, errorFunction, gr=NULL, method=Nelder-Mead, hessian=FALSE, globalShift, /home/sarah/Semesterarbeit/Sequences/R/R1593_filtered.data, experimentalPI=3.48, lambda = lambda) The output is: $par [1] 0.56350964 0.56350964 0.56350964 0.56350964 0. -0.29515957 [7] 0.00569937 0.32543297 0.18615880 $value [1] 0.2529198 $counts function gradient 31 31 $convergence [1] 0 $message [1] CONVERGENCE: REL_REDUCTION_OF_F = FACTR*EPSMCH Warning messages: 1: bounds can only be used with method L-BFGS-B in: optim(par, errorFunction, gr = NULL, method = Nelder-Mead, 2: NAs introduced by coercion If I change my error-function to errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { error - sum(abs(localShifts*lambda)) error # return the error to be minimized } or to: errorFunction - function(localShifts,globalShift,fileName,experimentalPI,lambda) { error - sum(abs(localShifts))/sqrt(147) error # return the error to be minimized } The output is: $par [1] 6.018101e-20 6.018101e-20 6.018101e-20 6.018101e-20 0.00e+00 [6] 5.176245e-21 -4.002183e-21 -8.254019e-20 3.231412e-21 $value [1] 2.768593e-20 $counts function gradient 76 76 $convergence [1] 0 $message [1] CONVERGENCE: NORM OF PROJECTED GRADIENT = PGTOL Warning messages: 1: bounds can only be used with method L-BFGS-B in: optim(par, errorFunction, gr = NULL, method = Nelder-Mead, 2: NAs introduced by coercion - What is wrong with the first version? Thanks for the help! Sarah __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] How to add characters on graph ?
Dear R-users, I have following data # Plot coloured scatter plot c-dat[100:110,c(5,7,8)] par(mfrow=c(3,2)) plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, xlab=LB, ylab=Index,cex.main =1,font.main= 1, main=scatterplot) ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 When I plotted a scatter plot of index against lb, there are two extreme values. How can I plot so that these values are replaced by their ID or the IDs are next to these values on the graph? I want to do something like: if index 1.5 then plot the IDs instead of the indexes greater than 1.5 or place the Ids next to their indexes. The data above is a little part of my real data (which might have more than two extreme outliers). Thanks for your help, Jenny __ [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hershey fonts for musical notation?
On Wed, 3 Jan 2007, Atte Tenkanen wrote: [...] By the way, right now the demo(Hershey) seems not to work in OSX version R 2.4.1. ... I get a message i - i + 1 Error in deparse(ei, control = c(showAttributes, useSource)) : invalid multibyte string But it does should work in R-devel, which deparses differently. The issue is the use of a UTF-8 locale and the Hershey byte codes are indeed an invalid string in such a locale. Here is a simple example in UTF-8. x - \301 x [1]Error: invalid multibyte string -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] RODBC compile error with R 2.4.1
This is not a 'compile error' but an error from the configure script, probably a run error. As it says See `config.log' for more details. and then ask your local Linux guru what is broken locally. This is neither an R nor an RODBC problem, and for what it is worth RODBC_1.1-7.tar.gz configures correctly on x86_64 Linux on FC5 and FC3, as well as various Debian versions (even with Debian's modified unixODBC). On Wed, 3 Jan 2007, Matthew Dowle wrote: Hi All, I'm getting the following error, could anyone help please? $ R CMD INSTALL RODBC_1.1-7.tar.gz * Installing *source* package 'RODBC' ... checking for gcc... gcc -std=gnu99 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 -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sql.h usability... yes checking sql.h presence... yes checking for sql.h... yes checking sqlext.h usability... yes checking sqlext.h presence... yes checking for sqlext.h... yes checking for library containing SQLTables... -lodbc checking for SQLLEN... yes checking for SQLULEN... yes checking for long... yes checking size of long... configure: error: cannot compute sizeof (long), 77 See `config.log' for more details. ERROR: configuration failed for package 'RODBC' ** Removing '/usr/local/lib/R/library/RODBC' ** Restoring previous '/usr/local/lib/R/library/RODBC' version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) Regards, Matthew __ 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 and provide commented, minimal, self-contained, reproducible code. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to add characters on graph ?
Hi On 3 Jan 2007 at 12:54, Jenny persson wrote: Date sent: Wed, 3 Jan 2007 12:54:50 +0100 (CET) From: Jenny persson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] How to add characters on graph ? Dear R-users, I have following data # Plot coloured scatter plot c-dat[100:110,c(5,7,8)] par(mfrow=c(3,2)) plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, xlab=LB, ylab=Index,cex.main =1,font.main= 1, main=scatterplot) ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 When I plotted a scatter plot of index against lb, there are two extreme values. How can I plot so that these values are replaced by their ID or the IDs are next to these values on the graph? I want to do something like: if index 1.5 then plot the IDs instead of the indexes greater than 1.5 or place the Ids next to their indexes. The I would use such construction plot(x,y, ..., type=n) points(x,y, pch=c(NA,1)[(index1.5)+1]) sel-(index1.5) text(x[sel],y[sel], ID[sel]) see ?points, ?text, ?plot HTH Petr data above is a little part of my real data (which might have more than two extreme outliers). Thanks for your help, Jenny __ [[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 and provide commented, minimal, self-contained, reproducible code. Petr Pikal [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to add characters on graph ?
This should do it. You can play around with the alignment of the labels. input - 'ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 ' # read in the data inData - read.table(textConnection(input), header=TRUE) with(inData, { plot(lb,index, pch=1, col=5,cex=1, lwd=2, xlab=LB, ylab=Index,cex.main =1,font.main= 1, main=scatterplot) text(lb[index 1.5], index[index 1.5], labels=ID[index 1.5]) # label the outliers }) On 1/3/07, Jenny persson [EMAIL PROTECTED] wrote: Dear R-users, I have following data # Plot coloured scatter plot c-dat[100:110,c(5,7,8)] par(mfrow=c(3,2)) plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, xlab=LB, ylab=Index,cex.main =1,font.main= 1, main=scatterplot) ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 When I plotted a scatter plot of index against lb, there are two extreme values. How can I plot so that these values are replaced by their ID or the IDs are next to these values on the graph? I want to do something like: if index 1.5 then plot the IDs instead of the indexes greater than 1.5 or place the Ids next to their indexes. The data above is a little part of my real data (which might have more than two extreme outliers). Thanks for your help, Jenny __ [[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 and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[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 and provide commented, minimal, self-contained, reproducible code.
[R] loading data and executing queries with R and Mysql
Hello everyone, I have a problem when I execute queries using R 2.3.1 and MySql server 5.0. What I do: I load data in different csv files (every file represents a particular temporal step of a simulation) using Mysql query load data with RMySQL command DbSendQuery (but the same problem there is also using DbWritetable). Then I use a function where I have a lot of queries that interact with the database. Well, while loading data is very fast, query execution is very slow ...looking to Windows task manager I see that my cpu doesn't go to 100% of usage, but only at 30-45%. Looking at the processes I see Rgui.exe use between 0-23% and mysql-nt.exe use between 8-20% and so it is very slow. I am sure my cpu has no particular problems. Could you help me? Thanks in advance Davide [[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 and provide commented, minimal, self-contained, reproducible code.
[R] understanding integer divide (%/%)
I am confused about why the following occurs: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) 1 %/% 0.1 [1] 9 10 %/% 1 [1] 10 This effect led me into an trap when I tried to classify a set of proportions based on the first decimal place by integer dividing by 0.1. Can someone explain why this behavior occurs and give me an insight into how to predict it? Thanks, -- Jeff __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding integer divide (%/%)
This is due to the internal representation of 0.1, which is not exactly 0.1 but very close to it. If you want to do an integer divide, you should only use integers to divide with. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Jeffrey Prisbrey Verzonden: woensdag 3 januari 2007 14:21 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] understanding integer divide (%/%) I am confused about why the following occurs: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) 1 %/% 0.1 [1] 9 10 %/% 1 [1] 10 This effect led me into an trap when I tried to classify a set of proportions based on the first decimal place by integer dividing by 0.1. Can someone explain why this behavior occurs and give me an insight into how to predict it? Thanks, -- Jeff __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loading data and executing queries with R and Mysql
Nevermind the CPU usage, the likely problem is that your queries are inefficient in one or more ways (i.e., you don't use indexes when you really should - it's impossible to guess without knowing how the data and the queries look like, which somehow you've decided are not important enough to describe in your email). One nice reference is http://highperformancemysql.com/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bagatti Davide Sent: Wednesday, January 03, 2007 8:05 AM To: r-help@stat.math.ethz.ch Subject: [R] loading data and executing queries with R and Mysql Hello everyone, I have a problem when I execute queries using R 2.3.1 and MySql server 5.0. What I do: I load data in different csv files (every file represents a particular temporal step of a simulation) using Mysql query load data with RMySQL command DbSendQuery (but the same problem there is also using DbWritetable). Then I use a function where I have a lot of queries that interact with the database. Well, while loading data is very fast, query execution is very slow ...looking to Windows task manager I see that my cpu doesn't go to 100% of usage, but only at 30-45%. Looking at the processes I see Rgui.exe use between 0-23% and mysql-nt.exe use between 8-20% and so it is very slow. I am sure my cpu has no particular problems. Could you help me? Thanks in advance Davide [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] RODBC : first line of data from query omitted
Dear List, when reading MS Excel files in R using package RODBC I encountered the problem of having the first line of data getting omitted. I read the data as : library(RODBC) channel1 - odbcConnectExcel(myFile.xls) sheet1 - sqlQuery(channel1, SELECT * FROM [Cell measures (1)$]) # I use sqlQuery() instead of sqlFetch() since the sheet I want to extract is called : Cell measures (1) The first line of data is missing in the resulting object (sheet1) in the case where the corresponding sheet contains a list of data without a line serving as header. And the original first line appears as column-name (in the case of strings while any numeric content is transformed to incrementing column-names). The 2nd line from my input appears then as 1st line of data in the resulting R-object and, no surprise, the total number of lines is 1 too few. sheet1[1:3,1:5] D - 5(fld 10) F2 F3F4 F5 1 D - 5(fld 11) 162 182.110 0.042 184.695 2 D - 5(fld 12) 163 198.154 0.086 201.932 3 D - 5(fld 13) 164 182.403 0.034 182.816 However, the 1st line in the original reads as : D - 5(fld 10) 161 182.929 0.045 188.819 Do you have an idea how to formulate the query that I can read the 1st line of data ? Is there some argument like the col.names=FALSE in read.table() ? Or is there a way to add an additional line unsing the SQL coomand INSERT (so that the real data would start in line 2) ? sessionInfo() R version 2.4.0 (2006-10-03) i386-pc-mingw32 locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 attached base packages: [1] methods stats graphics grDevices utils datasets tcltk base other attached packages: RODBC svIO R2HTML svMisc svSocketsvIDE 1.1-7 0.9-5 1.58 0.9-5 0.9-5 0.9-5 Thank's in advance, Wolfgang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3314 Fax (+33) 388 65 3276 [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loading data and executing queries with R and Mysql
Without any actual example Ias requested in the footer of this message) I can only guess, but the most common cause of slow queries is the lack of indices in the database, so did you create any? You haven't told us your actual OS (beyond 'Windows'), but a guess is that your processes are I/O bound, and that your file system could well do with a tune. For example, if this is NTFS, is there lots (at least 30%) of free space and did you defragment it after saving the data? On Wed, 3 Jan 2007, Bagatti Davide wrote: Hello everyone, I have a problem when I execute queries using R 2.3.1 and MySql server 5.0. What I do: I load data in different csv files (every file represents a particular temporal step of a simulation) using Mysql query load data with RMySQL command DbSendQuery (but the same problem there is also using DbWritetable). Then I use a function where I have a lot of queries that interact with the database. Well, while loading data is very fast, query execution is very slow ...looking to Windows task manager I see that my cpu doesn't go to 100% of usage, but only at 30-45%. Looking at the processes I see Rgui.exe use between 0-23% and mysql-nt.exe use between 8-20% and so it is very slow. I am sure my cpu has no particular problems. Could you help me? Thanks in advance Davide [[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 and provide commented, minimal, self-contained, reproducible code. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] label array
hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) -- View this message in context: http://www.nabble.com/-R--label-array-tf2913929.html#a8142071 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding integer divide (%/%)
Thierry Onkelinx wrote: If you want to do an integer divide, you should only use integers to divide with. I think this should go into ``fortunes''. cheers, Rolf Turner [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 and provide commented, minimal, self-contained, reproducible code.
[R] Is there a function for this?
Hi everybody, I'm trying to do a statistic on the error rate of a prediction algorithm. suppose this is the real category [good, good, bad, bad, good, good, bad, bad] this is the predicted category [good, bad, bad, bad, good, good, good, bad] I'm trying to do a statistic on the error rate for each group(good,bad): what percentage of instances are predicted incorrectly for each group ? Of course I can write a loop to do that, but is there a easy way to do that? Thank you! Best, Feng __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is there a function for this?
Try this: actual - factor(c(good, good, bad, bad, good, good, bad, bad)) pred - factor(c(good, bad, bad, bad, good, good, good, bad)) table(actual, pred) pred actual bad good bad31 good 13 prop.table(table(actual, pred), 1) pred actual bad good bad 0.75 0.25 good 0.25 0.75 prop.table(table(actual, pred), 2) pred actual bad good bad 0.75 0.25 good 0.25 0.75 library(gmodels) CrossTable(actual, pred) Cell Contents |-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |-| Total Observations in Table: 8 | pred actual | bad | good | Row Total | -|---|---|---| bad | 3 | 1 | 4 | | 0.500 | 0.500 | | | 0.750 | 0.250 | 0.500 | | 0.750 | 0.250 | | | 0.375 | 0.125 | | -|---|---|---| good | 1 | 3 | 4 | | 0.500 | 0.500 | | | 0.250 | 0.750 | 0.500 | | 0.250 | 0.750 | | | 0.125 | 0.375 | | -|---|---|---| Column Total | 4 | 4 | 8 | | 0.500 | 0.500 | | -|---|---|---| On 1/3/07, Feng Qiu [EMAIL PROTECTED] wrote: Hi everybody, I'm trying to do a statistic on the error rate of a prediction algorithm. suppose this is the real category [good, good, bad, bad, good, good, bad, bad] this is the predicted category [good, bad, bad, bad, good, good, good, bad] I'm trying to do a statistic on the error rate for each group(good,bad): what percentage of instances are predicted incorrectly for each group ? Of course I can write a loop to do that, but is there a easy way to do that? Thank you! Best, Feng __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is there a function for this?
Try the following: act - c('good','good','bad','bad','good','good','bad','bad') pred - c('good','bad','bad','bad','good','good','good','bad') table(pred,act) table(pred,act)/apply(table(pred,act),1,sum) Cheers, Andreas On 1/3/07, Feng Qiu [EMAIL PROTECTED] wrote: Hi everybody, I'm trying to do a statistic on the error rate of a prediction algorithm. suppose this is the real category [good, good, bad, bad, good, good, bad, bad] this is the predicted category [good, bad, bad, bad, good, good, good, bad] I'm trying to do a statistic on the error rate for each group(good,bad): what percentage of instances are predicted incorrectly for each group ? Of course I can write a loop to do that, but is there a easy way to do that? Thank you! Best, Feng __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] mathematical symbols in plots
Hello everyone! I'm trying to plot some mathematical expression along my axis, but demo(plotmath) did not have the symbol I was looking for. In particular, I would like to denote the mean of an observable by writing k which I tried to enter with expression(group(, k, )) However, my naive try doesn't work and the help doesn't want to tell me, does someone know? And here another one: How can I sepcify which fonts get used with which R prints those mathematical symbols? Since I finally include my plots in latex-documents as eps, I would love to use the same font-encoding for all postscript stuff. A problem in the past has been, that R embedded it's own font within the ps-files generated. These were not compatible with the fonts used at the magazine where I published my document. This lead to quite some confusion as \gamma became g and so on. Any solution to this problem? Any hint? As I'm not too much into font-encoding, I have actually no real clue where to even start searching. Thank you very much for any help. Greetings, Sebastian Weber __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding integer divide (%/%)
On Wed, 3 Jan 2007, ONKELINX, Thierry wrote: This is due to the internal representation of 0.1, which is not exactly 0.1 but very close to it. If you want to do an integer divide, you should only use integers to divide with. This must be more-or-less correct, but it is worth noting that 0.1*10==1 [1] TRUE 1/0.1==10 [1] TRUE 1%/%0.1==10 [1] FALSE so it isn't quite that simple. Interestingly, the results seem to vary by system -- on a G4 Mac I get 1 %/% (1/x) == x for all x from 1 to 50 -thomas Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Jeffrey Prisbrey Verzonden: woensdag 3 januari 2007 14:21 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] understanding integer divide (%/%) I am confused about why the following occurs: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) 1 %/% 0.1 [1] 9 10 %/% 1 [1] 10 This effect led me into an trap when I tried to classify a set of proportions based on the first decimal place by integer dividing by 0.1. Can someone explain why this behavior occurs and give me an insight into how to predict it? Thanks, -- Jeff __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] wrapping mle()
On Sat, 30 Dec 2006, Sebastian P. Luque wrote: On Sat, 30 Dec 2006 15:46:01 -0600 (CST), Luke Tierney [EMAIL PROTECTED] wrote: It is much cleaner to do this sort of thing with lexical scope. For example, mkll - function(x, y) { function(ymax=15, xhalf=6) { -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) } } creates a log-likelihood likelyhood function for data x,y that can then be used by fit.mle - function(mkfun, x, y) { loglik.fun - mkfun(x, y) mle(loglik.fun, method=L-BFGS-B, lower=c(0, 0)) } as in fit.mle(mkll, x=0:10, y=c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)) Call: mle(minuslogl = loglik.fun, method = L-BFGS-B, lower = c(0, 0)) Coefficients: ymax xhalf 24.999420 3.055779 Thanks Luke, this looks excellent. It is not clear why you want to be able to pass ll as a character string or why you want to assume that the thing passed in will refer to variables named 'x' and 'y', both usually bad ideas, so this specific approach may not apply, but something variant should. In the real case, I need to provide two different log likelihood functions, and then tell fit.mle() which one to use in a given call. I was actually defining 'x' and 'y' as formal arguments to fit.mle(). Wouldn't that ensure that the original ll() would refer to the correct variables? No, since ll was defined at top level lexical scoping rules mean that free variables in the definition of ll are top level variables, regardless of where ll is called. In any case, it was easy to use your suggestion almost by direct analogy, which makes the code much more readable. Thanks a lot. In the case I describe though, why would it be a bad idea to use a string to refer to the function, and then use match.fun()? I actually picked up the idea from functions such as apply() and friends. Not bad just not necessary. Calling fit.mle(ll ...) will do and you then don't need match.call, which makes your code simpler. Best, luke The ability to use environment(f)-env to change the environment of a function is one of the most dubious language features of R (maybe the most dubious, though there are a couple of other strong contenders) and should not be used except in very rare circumstances. Keeping the lexical scoping technique you showed in mind should help stay away from that. Cheers, -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] wrapping mle()
On Sat, 30 Dec 2006, Gabor Grothendieck wrote: That has two disadvantages: (1) it only works if the user is defining ll himself; however, if the user is getting ll from somewhere else then its not applicable since the user no longer controls its scope whereas resetting the environment method still works In that case surgery on environments is even worse: There is no reliable way to know which variables in an arbitrary function body might benefit from having values provided though environment surgery and which ones definitely should not be messed with this in this way. Brian's reply in this thread is related to this. The reliable way to provide data for variables in a function body is to make those variables arguments in an appropriate function -- that is what the nested function approach does. In situations like these careful use of ... arguments is another option but this can be tricky to get right. It is far superior to environment surgery though. (2) its cleaner for the developer but harder for the user who is now forced into a more complicated construct, i.e. the nested double function construct Aside from the fact that the S language philosophy is to blur the user/developer distinction this really does not make sense. Nested functions like these are a simple idea that is basic to all modern function-oriented languages. (It even exists in languages like Pascal for downward-only function arguments.) It is an idea that can be useful for anyone who writes functions in R. Environment surgery in contrast is messy and complex and essentially impossible to get right. If you want to do this in the privacy of your own code that is fine, but please don't encourage others to go down this path. Best, luke By the way, here is one additional solution using the proto package that avoids explicitly resetting of the environment in favor implicitly setting it. A new proto object is created which to hold FUN and since proto methods have their object as their scope, their environment is implicitly reset: library(proto) library(stats4) ll - function(ymax=15, xhalf=6) { -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) } fit.mle - function(FUN, x, y) mle(proto(FUN = match.fun(FUN))[[FUN]], method=L-BFGS-B, lower=c(0, 0)) fit.mle(ll, x=0:10, y=c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)) On 12/30/06, Luke Tierney [EMAIL PROTECTED] wrote: It is much cleaner to do this sort of thing with lexical scope. For example, mkll - function(x, y) { function(ymax=15, xhalf=6) { -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) } } creates a log-likelihood likelyhood function for data x,y that can then be used by fit.mle - function(mkfun, x, y) { loglik.fun - mkfun(x, y) mle(loglik.fun, method=L-BFGS-B, lower=c(0, 0)) } as in fit.mle(mkll, x=0:10, y=c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)) Call: mle(minuslogl = loglik.fun, method = L-BFGS-B, lower = c(0, 0)) Coefficients: ymax xhalf 24.999420 3.055779 It is not clear why you want to be able to pass ll as a character string or why you want to assume that the thing passed in will refer to variables named 'x' and 'y', both usually bad ideas, so this specific approach may not apply, but something variant should. The ability to use environment(f)-env to change the environment of a function is one of the most dubious language features of R (maybe the most dubious, though there are a couple of other strong contenders) and should not be used except in very rare circumstances. Best, luke On Sat, 30 Dec 2006, Gabor Grothendieck wrote: Add the line marked ### so that the environment of loglik.fun is reset to the environment within fit.mle so that it can find y there: library(stats4) ll - function(ymax=15, xhalf=6) { -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) } fit.mle - function(FUN, x, y) { loglik.fun - match.fun(FUN) environment(loglik.fun) - environment() ### mle(loglik.fun, method=L-BFGS-B, lower=c(0, 0)) } fit.mle(ll, x=0:10, y=c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)) On 12/30/06, Sebastian P. Luque [EMAIL PROTECTED] wrote: Hi, How can we set the environment for the minuslog function in mle()? The call in this code fails because the ll function cannot find the object 'y'. Modifying from the example in ?mle: library(stats4) ll - function(ymax=15, xhalf=6) { -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) } fit.mle - function(FUN, x, y) { loglik.fun - match.fun(FUN) mle(loglik.fun, method=L-BFGS-B, lower=c(0, 0)) } fit.mle(ll, x=0:10, y=c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)) How should fit.mle be constructed so that ll works on the appropriate environment? Thanks in advance for any advice on this. -- Seb __
Re: [R] How to add characters on graph ?
If you just want to label and identify outliers after creating a plot then look at the identify function. In your case you could just run the following command after creating your plot: out.index - identify( c$lb, c$index ) Then click on (or near) the outliers or other interesting points. The points will be labelled on the plot and their position in the dataset will be saved in out.index. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jenny persson Sent: Wednesday, January 03, 2007 4:55 AM To: r-help@stat.math.ethz.ch Subject: [R] How to add characters on graph ? Dear R-users, I have following data # Plot coloured scatter plot c-dat[100:110,c(5,7,8)] par(mfrow=c(3,2)) plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, xlab=LB, ylab=Index,cex.main =1,font.main= 1, main=scatterplot) ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 When I plotted a scatter plot of index against lb, there are two extreme values. How can I plot so that these values are replaced by their ID or the IDs are next to these values on the graph? I want to do something like: if index 1.5 then plot the IDs instead of the indexes greater than 1.5 or place the Ids next to their indexes. The data above is a little part of my real data (which might have more than two extreme outliers). Thanks for your help, Jenny __ [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] SQLite: When reading a table, a \r is padded onto the last column. Why?
RSQLite can import data from a large file directly (via dbWriteTable). This future is quite appealing. On 1/3/07, Prof Brian Ripley [EMAIL PROTECTED] wrote: I guess you are using package RSQLite without telling us (or telling us the version), and that your example is incomplete? Using RSiteSearch(RSQLite Windows) quickly shows that this is a previously reported problem with the package, e.g.: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/72515.html I believe the issue is that RSQLite actually writes out a CRLF-terminated text file and imports that into SQLite. (I checked version 0.4-15.) It seems function safe.write() needs to be modified to write to a binary-mode connection since SQLite appears to require LF-terminated files. Using RODBC to work with SQLite databases works correctly even under Windows (and is much more efficient at writing to the database). [I am not sure who is actually maintaining RSQLite, so am Cc: both the stated maintainer and the person who prepared the package for distribution. The posting guide asked you to contact the maintainer: what response did _you_ get?] On Wed, 3 Jan 2007, Søren Højsgaard wrote: Hi, I put the iris data into a SQLite database with dbWriteTable(con, iris, iris, row.names=F, overwrite = T) Then I retrieve data from the database with rs - dbSendQuery(con, select * from iris) d1 - fetch(rs) dbClearResult(rs) Then I get head(d1) Sepal_Length Sepal_Width Petal_Length Petal_Width Species 1 5.1 3.5 1.4 0.2 setosa\r 2 4.9 3.0 1.4 0.2 setosa\r 3 4.7 3.2 1.3 0.2 setosa\r 4 4.6 3.1 1.5 0.2 setosa\r 5 5.0 3.6 1.4 0.2 setosa\r 6 5.4 3.9 1.7 0.4 setosa\r Can anyone explain the extra \r at the end? I am on Windows XP using R 2.4.1 Thanks in advance Søren __ 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 and provide commented, minimal, self-contained, reproducible code. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Ronggui Huang Department of Sociology Fudan University, Shanghai, China 黄荣贵 复旦大学社会学系 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] User defined split function in Rpart
Dear all, I'm trying to manage with user defined split function in rpart (file rpart\tests\usersplits.R in http://cran.r-project.org/src/contrib/rpart_3.1-34.tar.gz - see bottom of the email). Suppose to have the following data.frame (note that x's values are already sorted) D y x 1 7 0.428 2 3 0.876 3 1 1.467 4 6 1.492 5 3 1.703 6 4 2.406 7 8 2.628 8 6 2.879 9 5 3.025 10 3 3.494 11 2 3.496 12 6 4.623 13 4 4.824 14 6 4.847 15 2 6.234 16 7 7.041 17 2 8.600 18 4 9.225 19 5 9.381 20 8 9.986 Running rpart and setting minbucket=1 and maxdepth=1 we get the following tree (which uses, by default, deviance): rpart(D$y~D$x,control=rpart.control(minbucket=1,maxdepth=1)) n= 20 node), split, n, deviance, yval * denotes terminal node 1) root 20 84.8 4.60 2) D$x 9.6835 19 72.63158 4.421053 * 3) D$x=9.6835 1 0.0 8.00 * This means that the first 19 observation has been sent to the left side of the tree and one observation to the right. This is correct when we observe goodness (the maximum is the last element of the vector). The thing i really don't understand is the direction vector. # direction= -1 = send y cutpoint to the left side of the tree # 1 = send y cutpoint to the right What does it mean ? In the example here considered we have sign(lmean) [1] 1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Which is the criterion used ? In my opinion we should have all the values equal to -1 given that they have to be sent to left side of the tree. Does someone can help me ? Thank you ### # The split function, where most of the work occurs. # Called once per split variable per node. # If continuous=T (the case here considered) # The actual x variable is ordered # y is supplied in the sort order of x, with no missings, # return two vectors of length (n-1): # goodness = goodness of the split, larger numbers are better. # 0 = couldn't find any worthwhile split # the ith value of goodness evaluates splitting obs 1:i vs (i+1):n # direction= -1 = send y cutpoint to the left side of the tree # 1 = send y cutpoint to the right # this is not a big deal, but making larger mean y's move towards # the right of the tree, as we do here, seems to make it easier to # read # If continuos=F, x is a set of integers defining the groups for an # unordered predictor. In this case: # direction = a vector of length m= # groups. It asserts that the # best split can be found by lining the groups up in this order # and going from left to right, so that only m-1 splits need to # be evaluated rather than 2^(m-1) # goodness = m-1 values, as before. # # The reason for returning a vector of goodness is that the C routine # enforces the minbucket constraint. It selects the best return value # that is not too close to an edge. The vector wt of weights in our case is: wt [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 temp2 - function(y, wt, x, parms, continuous) { # Center y n - length(y) y - y- sum(y*wt)/sum(wt) if (continuous) { # continuous x variable temp - cumsum(y*wt)[-n] left.wt - cumsum(wt)[-n] right.wt - sum(wt) - left.wt lmean - temp/left.wt rmean - -temp/right.wt goodness - (left.wt*lmean^2 + right.wt*rmean^2)/sum(wt*y^2) list(goodness= goodness, direction=sign(lmean)) } } Paolo Radaelli Dipartimento di Metodi Quantitativi per le Scienze Economiche ed Aziendali Facoltà di Economia Università degli Studi di Milano-Bicocca P.zza dell'Ateneo Nuovo, 1 20126 Milano Italy 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
try this : x - array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26])) Cheers, Wolfgang downunder03 a écrit : hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3314 Fax (+33) 388 65 3276 [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] RODBC compile error with R 2.4.1
Matthew, You don't seem to say what linux release you are using, They can't very well help you without that information. Not all releases are equal. JWD On Wednesday 03 January 2007 03:49, Matthew Dowle wrote: Hi All, I'm getting the following error, could anyone help please? $ R CMD INSTALL RODBC_1.1-7.tar.gz * Installing *source* package 'RODBC' ... checking for gcc... gcc -std=gnu99 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 -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sql.h usability... yes checking sql.h presence... yes checking for sql.h... yes checking sqlext.h usability... yes checking sqlext.h presence... yes checking for sqlext.h... yes checking for library containing SQLTables... -lodbc checking for SQLLEN... yes checking for SQLULEN... yes checking for long... yes checking size of long... configure: error: cannot compute sizeof (long), 77 See `config.log' for more details. ERROR: configuration failed for package 'RODBC' ** Removing '/usr/local/lib/R/library/RODBC' ** Restoring previous '/usr/local/lib/R/library/RODBC' version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) Regards, Matthew __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
Hi Wolfgang, thanks for your hint. But I am desperating. I have an 3 dim array of say 10 matrices where every matrix has to stick an other label. I found no way to direct assign the labels. for example tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes)) dimnames(tab[,,2]) - list(c(big,small), c(small,big)) should look like this , , 1 No Yes No 1 3 Yes 2 4 , , 2 big small small 5 7 big 6 8 Wolfgang Raffelsberger wrote: try this : x - array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26])) Cheers, Wolfgang downunder03 a écrit : hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3314 Fax (+33) 388 65 3276 [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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/-R--accessing-arrays-tf2913929.html#a8144807 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
You can't do that. If you want to have different labels on the first two dimensions, then a 3-dimensional array doesn't seem to be the natural data structure. I would suggest two matrices held in a list. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) downunder03 wrote: hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
Or you could define it as your own class and define your own print and other methods, e.g. X - structure(array(1:8, c(2,2,2)), class = twomats) attr(X, DIMNAMES) - list(list(c(No, Yes), c(No, Yes)), +dimnames = list(c(No, Yes), c(big, small))) print.twomats - function(x, ...) { + Y - list(X[,,1], X[,,2]) + for(i in 1:2) { + dimnames(Y[[i]]) - attr(x, DIMNAMES)[[i]] + print(Y[[i]]) + } + } X No Yes No 1 3 Yes 2 4 big small No5 7 Yes 6 8 On 1/3/07, Patrick Burns [EMAIL PROTECTED] wrote: You can't do that. If you want to have different labels on the first two dimensions, then a 3-dimensional array doesn't seem to be the natural data structure. I would suggest two matrices held in a list. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) downunder03 wrote: hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
Hi Lars, in a 3-dim array you have 3 axes, day x, y and z (which I named xNo/xYes, yNo/yYes and zSmall/zBig) to assign directly the labels use : tab - array(1:8, c(2, 2, 2),dimnames= list(c(xNo,xYes), c(yNo,yYes),c(zBig,zSmall))) tab , , zBig yNo yYes xNo13 xYes 24 , , zSmall yNo yYes xNo57 xYes 68 If you wanted to have an array allowing to capture xNo/xYes vs yNo/yYes AND zBig,zSmall vs aaBig,aaSmall you need to go one dimension higher .. but I'm not sure if this is really what you wanted. Hope this helps, Wolfgang Lars Rohrschneider a écrit : Hi Wolfgang, thanks for your hint. But I am desperating. I have an 3 dim array of say 10matrices where every matrix has to stick an other label. I found no way todirect assign the labels. for example tab - array(1:8, c(2, 2, 2))dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes))dimnames(tab[,,2]) - list(c(big,small), c(small,big)) should look like this, , 1 No YesNo 1 3Yes 2 4 , , 2 big smallsmall 5 7big 6 8 Wolfgang Raffelsberger wrote: try this : x - array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26])) Cheers, Wolfgang downunder03 a écrit : hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3314 Fax (+33) 388 65 3276 [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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/-R--accessing-arrays-tf2913929.html#a8144807Sent from the R help mailing list archive at Nabble.com. [EMAIL PROTECTED] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3314 Fax (+33) 388 65 3276 http://www-bio3d-igbmc.u-strasbg.fr/~wraff [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 and provide commented, minimal, self-contained, reproducible code.
[R] question about regression forest
Dear All, My name is José Cortiñas Abrahantes, I am statistician and work at the university in Belgium. I started working recently with machine learning techniques and I finding a fascinating field. The reason of my email is to ask you a question related to regression forest. I am interested to compare the fit of linear regression, regression trees, bagging trees and regression forest for the case in which we have only one predictor variable. In all the articles that I have found related to regression forest they reported the advantages of the use of a random subsets of predictors used to grow the tree with respect to bagging, in my case I have only one, thus it is not really contributing. I was expecting then to see a similar behaviour than bagging, the rsquared values produced by both methods are very similar indeed, but what I find strange is that if I take the 2.5 and 97.5 percentile of all rsquared from each tree grow the interval obtained for regression forest is much narrower than the one obtained for bagging. Do anyone know why is this? Thanks in advance. Best regards and best wishes for 2007, José Cortiñas Abrahantes __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding integer divide (%/%)
On Wed, 3 Jan 2007, Thomas Lumley wrote: On Wed, 3 Jan 2007, ONKELINX, Thierry wrote: This is due to the internal representation of 0.1, which is not exactly 0.1 but very close to it. If you want to do an integer divide, you should only use integers to divide with. This must be more-or-less correct, but it is worth noting that 0.1*10==1 [1] TRUE 1/0.1==10 [1] TRUE 1%/%0.1==10 [1] FALSE so it isn't quite that simple. Interestingly, the results seem to vary by system -- on a G4 Mac I get 1 %/% (1/x) == x for all x from 1 to 50 And even 1 %/% 0.1 == 10 on my Linux boxes. Other things which are going on are the use of extra-precision registers (and potentially the system floor() function). %/% (but not / or *) makes use of a round of iterative refinement. It does 1/0.1 (10) rounds down (10) tmp = 1 - 0.1 *10 (slightly negative) Oops, the answer must be 10 - 1. This is needed for consistency since 1 %% 0.1 [1] 0.1 on MinGW. I think the Windows answer is correct, as 0.1 will be stored as 1/8 * 53-bit binary fraction with leading 1, and according to package gmp as.bigq(0.1) [1] 3602879701896397/36028797018963968 the denominator being 2^55. So 1 - 10 * 0.1 is -2/2^55 0. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] SQLite: When reading a table, a \r is padded onto the last column. Why?
Prof Brian Ripley [EMAIL PROTECTED] writes: [I am not sure who is actually maintaining RSQLite, so am Cc: both the stated maintainer and the person who prepared the package for distribution. The posting guide asked you to contact the maintainer: what response did _you_ get?] For the record, I will be (have been) taking on the maintainer role for RSQLite. The Maintainer field will be updated in the next version. As to the '\r' problem, a release candidate RSQLite 0.4-17 is available here: http://bioconductor.org/packages/misc/ This version uses prepared queries to implement dbWriteTable. This should resolve the '\r' issue on Windows and should also be considerably more efficient. Soren, can you give this one a try and let me know if it works for you? Recent work on RSQLite has focused on integrating SQLite3's type system into the interface. We now rely on the column type in the DB when retrieving results. Previously, type.convert was used. I'm fairly certain these changes will result in changes in behavior -- in most cases, I think the changes are for the better. + seth __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] problem with logLik and offsets
Hi, I'm trying to compare models, one of which has all parameters fixed using offsets. The log-likelihoods seem reasonble in all cases except the model in which there are no free parameters (model3 in the toy example below). Any help would be appreciated. Cheers, Jarrod x-rnorm(100) y-rnorm(100, 1+x) model1-lm(y~x) logLik(model1) sum(dnorm(y, predict(model1), summary(model1)$sigma,log=TRUE)) # no offset - in agreement model2-lm(y~offset(rep(1,100))+x-1) logLik(model2) sum(dnorm(y, predict(model2),summary(model2)$sigma,log=TRUE)) # offset and free parameters - in agreement model3-lm(y~offset(rep(1,100))+offset(x)-1) logLik(model3) sum(dnorm(y, predict(model3),summary(model3)$sigma,log=TRUE)) # offset only - discrepancy sum(predict(model3)-c(1+x)) # yet predict is correct __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] mcmcsamp and variance ratios
Hi folks, I have assumed that ratios of variance components (Fst and Qst in population genetics) could be estimated using the output of mcmcsamp (the series on mcmc sample estimates of variance components). What I have started to do is to use the matrix output that included the log(variances), exponentiate, calculate the relevant ratio, and apply either quantile or or HPDinterval to get confidence intervals. This seems too simple but I can't think of what is wrong with it. All thoughts appreciated. -Hank Dr. Hank Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] ewma help
I wrote my own ewma function to deal with the somewhat odd way that filter handles missing values. The function I wrote works as long as the NA isn't first but when it is first I still get a zero in the output. I'm not expert enough to look at filter and undeerstand what it is doing. # 1) THE FIRST CASE DOESN'T WORK # I WOULD PREFER A 1 IN THE SECOND ELEMENT OF THE OUTPUT # BECAUSE THAT IS THE INITIAL NON NA VALUE OF THE SERIES # I DONT KNOW WHY A ZERO GETS THERE AND THAT # MAKES THE REST OF THE SERIES WRONG BECAUSE IT'S #A RECURSIVE RELATIONSHIP. BASICALLY #I PREFER THE OUTPUT TO BE THE SAME AS THE SECOND SET OF OUTPUT : # 1 NA # 2 1.00 # 3 1.50 # 4 2.25 # WITH THE NA JUST IN A DIFFERENT PLACE x-zoo(matrix(c(NA,1,2,3),nc=1)) ewma(x,lambda=0.5) 1 NA 2 0 ( 3 1 4 2 #=== == # 2) THIS CASE DOES WORK x-zoo(matrix(c(1,NA,2,3),nc=1)) ewma(x,lambda=0.5) 1 1.00 2 NA 3 1.50 4 2.25 ewma-function(x,lambda = 1, init = x[1]) { # work with 'non-zoo' data for speed and then recombine .raw - coredata(x) good.ind - !is.na(.raw) # determine good values .raw[good.ind] - filter(lambda * .raw[good.ind], filter=(1-lambda), method='recursive', init=coredata(init)) zoo(.raw, index(x)) # create zoo object for return } This is not an offer (or solicitation of an offer) to buy/se...{{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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loading data and executing queries with R and Mysql
Hello, thanks for your help. I tried with index in database (primary keys and index) but nothing changed. My hard disk has two partition FAT 32: in the first there is ubuntu 6.10, in the second (19 GB with 6GB of free space, never defragmented) there is Windows XP HE. I have the problem under Windows. In attach (csv file) you find an example of data I am using: it is only one step, so I load (with load data) one file of this type for each step of the simulation (these are about 1000 steps, but the problem happens when I load more than 80-100 files ). The queries are similar to the following: dbGetQuery(con, paste(select ID,IDAgentPartner,Vote from TabAgentRelationships where step= ,passo, and Vote ,min_voto, and IDAgentPartner!=0,sep=)); Thanks Davide 2007/1/3, Prof Brian Ripley [EMAIL PROTECTED]: Without any actual example Ias requested in the footer of this message) I can only guess, but the most common cause of slow queries is the lack of indices in the database, so did you create any? You haven't told us your actual OS (beyond 'Windows'), but a guess is that your processes are I/O bound, and that your file system could well do with a tune. For example, if this is NTFS, is there lots (at least 30%) of free space and did you defragment it after saving the data? On Wed, 3 Jan 2007, Bagatti Davide wrote: Hello everyone, I have a problem when I execute queries using R 2.3.1 and MySql server 5.0. What I do: I load data in different csv files (every file represents a particular temporal step of a simulation) using Mysql query load data with RMySQL command DbSendQuery (but the same problem there is also using DbWritetable). Then I use a function where I have a lot of queries that interact with the database. Well, while loading data is very fast, query execution is very slow ...looking to Windows task manager I see that my cpu doesn't go to 100% of usage, but only at 30-45%. Looking at the processes I see Rgui.exe use between 0-23% and mysql-nt.exe use between 8-20% and so it is very slow. I am sure my cpu has no particular problems. Could you help me? Thanks in advance Davide [[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 and provide commented, minimal, self-contained, reproducible code. -- 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 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] na.action and simultaneous regressions
Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use only the observations for which neither y1 nor y2 is missing. I'd like to have the regression for each separate dependent variable use all the non-missing cases for that variable. I would think that there should be a way to do that using the na.action option, but I haven't seen this in the documentation or figured out how to do it on my own. Can it be done this way, or do I have to code the regressions in a loop? (By the way, since it restricts to non-missing values in all the variables simultaneously, is this because it's doing some sort of SUR or other simultaneous equation estimation behind the scenes?) Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice / Trellis analog of axis(graphics) ?
On 1/3/07, Derek Eder [EMAIL PROTECTED] wrote: My question is so basic that I am (almost too) embarrassed to admit that I could not find an answer after an hour's worth of homework. What is the Trellis / Lattice analog for the axis(graphics) function that enables the creation of axes in locations other than the default (i.e., bottom for X axis and right for Y axis) ? For example when plotting mileage against weight (in American units), one might want to also include a second X axis on the top margin (e.g., axis() pos = 3) with fuel mileage in metric units. xyplot(Mileage ˜ Weight, data = fuel.frame) You might find the help page ?axis.default (and its example) useful. -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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing arrays
Thanks all for your hints and extensive codes. With list it seemed to work. lars Gabor Grothendieck wrote: Or you could define it as your own class and define your own print and other methods, e.g. X - structure(array(1:8, c(2,2,2)), class = twomats) attr(X, DIMNAMES) - list(list(c(No, Yes), c(No, Yes)), +dimnames = list(c(No, Yes), c(big, small))) print.twomats - function(x, ...) { + Y - list(X[,,1], X[,,2]) + for(i in 1:2) { + dimnames(Y[[i]]) - attr(x, DIMNAMES)[[i]] + print(Y[[i]]) + } + } X No Yes No 1 3 Yes 2 4 big small No5 7 Yes 6 8 On 1/3/07, Patrick Burns [EMAIL PROTECTED] wrote: You can't do that. If you want to have different labels on the first two dimensions, then a 3-dimensional array doesn't seem to be the natural data structure. I would suggest two matrices held in a list. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) downunder03 wrote: hi all. how can i adress a array directly. for example i wanna give array 1 other labels than array 2. How can I overcome this problem? ...this doesn't work tab - array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2)) __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/-R--accessing-arrays-tf2913929.html#a8149519 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with filled.contour()
Dieter Menne wrote: Michael Kubovy kubovy at virginia.edu writes: I tried and it gave a strange result. See http://people.virginia.edu/~mk9y/mySite/twoGaussian.R and http://people.virginia.edu/~mk9y/mySite/twoGaussian.pdf * Session Info * sessionInfo() R version 2.4.1 (2006-12-18) powerpc-apple-darwin8.8.0 Hmm, strange, I can reproduce your problem on Windows (otherwise same config) with pdf, but it looks beautifully on screen for me if I mentally remove the ugly legend. Try the image function. The smoothness of the plot will be proportional to the length of x and y. For instance 200 isn't bad: mu1 - 0 mu2 - 5 s - 1 x - seq(-2.5, 7.5, length = 200) y - seq(-2.5, 2.5, length = 200) f - function(x,y){ term1 - 1/(2*pi*sqrt(s*s)) term2 - -1/2 term3 - (x - mu1)^2/s term4 - (y - mu1)^2/s term5 - (x - mu2)^2/s term1*(.5 * exp(term2*(term3 + term4)) + .5 * exp(term2*(term5 + term4))) } # setting up the function of the multivariate normal density z - outer(x, y, f) # persp(x, y, z) require(grDevices) #pdf('twoGaussian.pdf') #filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1, # col = gray(seq(0, 0.9, len = 25)), nlevels = 25) image(x,y,z,col=gray(seq(0,0.9,len=200))) Cheers, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] na.action and simultaneous regressions
Ravi: You misinterpreted my reply -- perhaps I was unclear. I did **not** say that lm() with a matrix response would do it, but that the apply construction or an explicit loop would. As you and the poster noted, lm() produces a separate fit to each column of only the rowwise complete data. Bert Gunter -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 03, 2007 2:15 PM To: 'Bert Gunter'; 'Talbot Katz'; r-help@stat.math.ethz.ch Subject: RE: [R] na.action and simultaneous regressions No, Bert, lm doesn't produce a list each of whose components is a separate fit using all the nonmissing data in the column. It is true that the regressions are independently performed, but when the response matrix is passed from lm on to lm.fit, only the complete rows are passed, i.e. rows with no missing values. I looked at lm function, but it was not obvious to me how to fix it. In the following toy example, the degrees of freedom for y1 regression should be 18 and that for y2 should be 15, but both degrees of freedom are only 15. y1 - runif(20) y2 - c(runif(17), rep(NA,3)) x - rnorm(20) summary(lm(cbind(y1,y2) ~ x)) Response y1 : Call: lm(formula = y1 ~ x) Residuals: Min 1Q Median 3Q Max -0.52592 -0.22632 -0.00964 0.25117 0.31227 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.569890.06902 8.257 5.82e-07 *** x -0.123250.06516 -1.8910.078 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2798 on 15 degrees of freedom Multiple R-Squared: 0.1926, Adjusted R-squared: 0.1387 F-statistic: 3.577 on 1 and 15 DF, p-value: 0.07804 Response y2 : Call: lm(formula = y2 ~ x) Residuals: Min 1Q Median 3Q Max -0.48880 -0.28552 -0.06022 0.23167 0.54425 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.437120.07686 5.687 4.31e-05 *** x0.102780.07257 1.4160.177 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3115 on 15 degrees of freedom Multiple R-Squared: 0.118, Adjusted R-squared: 0.05915 F-statistic: 2.006 on 1 and 15 DF, p-value: 0.1771 Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bert Gunter Sent: Wednesday, January 03, 2007 4:46 PM To: 'Talbot Katz'; r-help@stat.math.ethz.ch Subject: Re: [R] na.action and simultaneous regressions As the Help page says: If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix So there's nothing hidden going on behind the scenes, and apply(cbind(y1,y2),2,function(z)lm(z~x)) (or an explicit loop, of course) will produce a list each of whose components is a separate fit using all the nonmissing data in the column. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Wednesday, January 03, 2007 11:56 AM To: r-help@stat.math.ethz.ch Subject: [R] na.action and simultaneous regressions Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use only the observations for which neither y1 nor y2 is missing. I'd like to have the regression for each separate dependent variable use all the non-missing cases for that variable. I would think that there should be a way to do that using the na.action option, but I haven't seen this in the documentation or figured out how to do it on my own. Can it be done this way, or do I have to code the regressions in a loop? (By the way, since it restricts to non-missing values in all the variables simultaneously, is this because it's doing some sort of SUR or other simultaneous equation estimation behind the scenes?) Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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 and
Re: [R] na.action and simultaneous regressions
No, Bert, lm doesn't produce a list each of whose components is a separate fit using all the nonmissing data in the column. It is true that the regressions are independently performed, but when the response matrix is passed from lm on to lm.fit, only the complete rows are passed, i.e. rows with no missing values. I looked at lm function, but it was not obvious to me how to fix it. In the following toy example, the degrees of freedom for y1 regression should be 18 and that for y2 should be 15, but both degrees of freedom are only 15. y1 - runif(20) y2 - c(runif(17), rep(NA,3)) x - rnorm(20) summary(lm(cbind(y1,y2) ~ x)) Response y1 : Call: lm(formula = y1 ~ x) Residuals: Min 1Q Median 3Q Max -0.52592 -0.22632 -0.00964 0.25117 0.31227 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.569890.06902 8.257 5.82e-07 *** x -0.123250.06516 -1.8910.078 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2798 on 15 degrees of freedom Multiple R-Squared: 0.1926, Adjusted R-squared: 0.1387 F-statistic: 3.577 on 1 and 15 DF, p-value: 0.07804 Response y2 : Call: lm(formula = y2 ~ x) Residuals: Min 1Q Median 3Q Max -0.48880 -0.28552 -0.06022 0.23167 0.54425 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.437120.07686 5.687 4.31e-05 *** x0.102780.07257 1.4160.177 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3115 on 15 degrees of freedom Multiple R-Squared: 0.118, Adjusted R-squared: 0.05915 F-statistic: 2.006 on 1 and 15 DF, p-value: 0.1771 Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bert Gunter Sent: Wednesday, January 03, 2007 4:46 PM To: 'Talbot Katz'; r-help@stat.math.ethz.ch Subject: Re: [R] na.action and simultaneous regressions As the Help page says: If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix So there's nothing hidden going on behind the scenes, and apply(cbind(y1,y2),2,function(z)lm(z~x)) (or an explicit loop, of course) will produce a list each of whose components is a separate fit using all the nonmissing data in the column. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Wednesday, January 03, 2007 11:56 AM To: r-help@stat.math.ethz.ch Subject: [R] na.action and simultaneous regressions Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use only the observations for which neither y1 nor y2 is missing. I'd like to have the regression for each separate dependent variable use all the non-missing cases for that variable. I would think that there should be a way to do that using the na.action option, but I haven't seen this in the documentation or figured out how to do it on my own. Can it be done this way, or do I have to code the regressions in a loop? (By the way, since it restricts to non-missing values in all the variables simultaneously, is this because it's doing some sort of SUR or other simultaneous equation estimation behind the scenes?) Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] na.action and simultaneous regressions
Hi Bert. Thank you so much, your solution with apply works perfectly. Sorry, I know this was an elementary question, and I saw the statement you referred to on the Help page. I just wasn't sure why, considering that there is a facility for na options, the option of treating the dependent variables separately with respect to missing values wasn't included. Thanks! -- TMK -- 212-460-5430home 917-656-5351cell From: Bert Gunter [EMAIL PROTECTED] To: 'Talbot Katz' [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: RE: [R] na.action and simultaneous regressions Date: Wed, 3 Jan 2007 13:46:03 -0800 As the Help page says: If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix So there's nothing hidden going on behind the scenes, and apply(cbind(y1,y2),2,function(z)lm(z~x)) (or an explicit loop, of course) will produce a list each of whose components is a separate fit using all the nonmissing data in the column. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Wednesday, January 03, 2007 11:56 AM To: r-help@stat.math.ethz.ch Subject: [R] na.action and simultaneous regressions Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use only the observations for which neither y1 nor y2 is missing. I'd like to have the regression for each separate dependent variable use all the non-missing cases for that variable. I would think that there should be a way to do that using the na.action option, but I haven't seen this in the documentation or figured out how to do it on my own. Can it be done this way, or do I have to code the regressions in a loop? (By the way, since it restricts to non-missing values in all the variables simultaneously, is this because it's doing some sort of SUR or other simultaneous equation estimation behind the scenes?) Thanks! -- TMK -- 212-460-5430 home 917-656-5351 cell __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] na.action and simultaneous regressions
Sorry, Bert. I didn't notice your use of apply, which will indeed give you separate regression results using all available data. But I was wondering, if there was a way to modify lm to be able to accomplish this, since it is doing separate regressions anyway. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bert Gunter Sent: Wednesday, January 03, 2007 4:46 PM To: 'Talbot Katz'; r-help@stat.math.ethz.ch Subject: Re: [R] na.action and simultaneous regressions As the Help page says: If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix So there's nothing hidden going on behind the scenes, and apply(cbind(y1,y2),2,function(z)lm(z~x)) (or an explicit loop, of course) will produce a list each of whose components is a separate fit using all the nonmissing data in the column. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Wednesday, January 03, 2007 11:56 AM To: r-help@stat.math.ethz.ch Subject: [R] na.action and simultaneous regressions Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use only the observations for which neither y1 nor y2 is missing. I'd like to have the regression for each separate dependent variable use all the non-missing cases for that variable. I would think that there should be a way to do that using the na.action option, but I haven't seen this in the documentation or figured out how to do it on my own. Can it be done this way, or do I have to code the regressions in a loop? (By the way, since it restricts to non-missing values in all the variables simultaneously, is this because it's doing some sort of SUR or other simultaneous equation estimation behind the scenes?) Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R grahics: Save as hangs computer
Hello list, I have encountered a problem trying to save graphs using the R-graphics menu: File|Save as. The menu suggests that files may be saved as either Metafile, Postscript, pdf, png, bmp, jpeg. When I specify any of those file formats a menu comes up requesting a file name. After providing a name R invariably hangs and has to be restarted. I am able to save files under the various formats using the command line without problems. However, sometimes it would be convenient to use the menus. I was wondering if anyone else had encountered a similar behaviour and had found a remedy. I am running are under GNU-Emacs ESS 5.3.3. sessionInfo() Version 2.3.0 (2006-04-24) i386-pc-mingw32 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base other attached packages: lattice 0.13-8 Regards Karl _ Dr Karl J Sommer, Department of Primary Industries, Catchment Agriculture Services, PO Box 905 Mildura, VIC, 3502 Australia Tel: +61 (0)3 5051 4390 Fax +61 (0)3 5051 4534 Email: [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] R grahics: Save as hangs computer
On 1/3/2007 5:30 PM, [EMAIL PROTECTED] wrote: Hello list, I have encountered a problem trying to save graphs using the R-graphics menu: File|Save as. The menu suggests that files may be saved as either Metafile, Postscript, pdf, png, bmp, jpeg. When I specify any of those file formats a menu comes up requesting a file name. After providing a name R invariably hangs and has to be restarted. I am able to save files under the various formats using the command line without problems. However, sometimes it would be convenient to use the menus. I was wondering if anyone else had encountered a similar behaviour and had found a remedy. I am running are under GNU-Emacs ESS 5.3.3. sessionInfo() Version 2.3.0 (2006-04-24) That version is out of date. Could you please update to the current version (2.4.1), and see if the problem persists? If so, could you please try it when running Rterm or Rgui on its own, rather than running under Emacs? Thanks. Duncan Murdoch i386-pc-mingw32 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base other attached packages: lattice 0.13-8 Regards Karl _ Dr Karl J Sommer, Department of Primary Industries, Catchment Agriculture Services, PO Box 905 Mildura, VIC, 3502 Australia Tel: +61 (0)3 5051 4390 Fax +61 (0)3 5051 4534 Email: [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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with filled.contour()
To Jeff: a tip of the hat. I have another question after Jeff's solution: On Jan 3, 2007, at 5:09 PM, Jeffrey Horner wrote: Michael Kubovy kubovy at virginia.edu writes: I tried and it gave a strange result. See http://people.virginia.edu/~mk9y/mySite/twoGaussian.R and http://people.virginia.edu/~mk9y/mySite/twoGaussian.pdf Try the image function. The smoothness of the plot will be proportional to the length of x and y. For instance 200 isn't bad: mu1 - 0 mu2 - 5 s - 1 x - seq(-2.5, 7.5, length = 200) y - seq(-2.5, 2.5, length = 200) f - function(x,y){ term1 - 1/(2*pi*sqrt(s*s)) term2 - -1/2 term3 - (x - mu1)^2/s term4 - (y - mu1)^2/s term5 - (x - mu2)^2/s term1*(.5 * exp(term2*(term3 + term4)) + .5 * exp(term2*(term5 + term4))) } # setting up the function of the multivariate normal density z - outer(x, y, f) # persp(x, y, z) require(grDevices) #pdf('twoGaussian.pdf') #filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1, # col = gray(seq(0, 0.9, len = 25)), nlevels = 25) image(x,y,z,col=gray(seq(0,0.9,len=200))) Is there a simpler way to get rid of axes, frame, and axis labels than image(x, y, z, col = gray(seq(0, 0.9, len = 200)), asp = 1, xaxt = 'n', yaxt = 'n', bty = 'n', ann = F) ? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] SQLite: When reading a table, a \r is padded onto the last column. Why?
On 1/4/07, Seth Falcon [EMAIL PROTECTED] wrote: Prof Brian Ripley [EMAIL PROTECTED] writes: [I am not sure who is actually maintaining RSQLite, so am Cc: both the stated maintainer and the person who prepared the package for distribution. The posting guide asked you to contact the maintainer: what response did _you_ get?] For the record, I will be (have been) taking on the maintainer role for RSQLite. The Maintainer field will be updated in the next version. As to the '\r' problem, a release candidate RSQLite 0.4-17 is available here: http://bioconductor.org/packages/misc/ This version uses prepared queries to implement dbWriteTable. This should resolve the '\r' issue on Windows and should also be considerably more efficient. Soren, can you give this one a try and let me know if it works for you? When write a data frame to db table, the problem of \r is fixed. But for importing data frome file, the problem is still there. When if the final line lacks the eol sign \n, \001x\001( comes up. dbWriteTable(con,test,c:/test.txt,sep=\t,head=T,over=T,eol=\n) [1] TRUE Warning message: incomplete final line found by readTableHeader on 'c://test.txt' dbReadTable(con,test) a b 1 1 2\r 2 3 \r 3 1 3\r 4 0 5\001x\001( dbWriteTable(con,test,c:/test.txt,sep=\t,head=T,over=T,eol=\n) [1] TRUE dbReadTable(con,test) a b 1 1 2\r 2 3 \r 3 1 3\r 4 0 5\r data(USArrests) dbWriteTable(con, USArrests, USArrests, overwrite = T) [1] TRUE dbReadTable(con, USArrests) Murder Assault UrbanPop Rape Alabama 13.2 236 58 21.2 Alaska 10.0 263 48 44.5 Arizona 8.1 294 80 31.0 Arkansas 8.8 190 50 19.5 California9.0 276 91 40.6 Colorado 7.9 204 78 38.7 sessionInfo() R version 2.4.0 Patched (2006-11-21 r39949) i386-pc-mingw32 locale: LC_COLLATE=Chinese_People's Republic of China.936;LC_CTYPE=Chinese_People's Republic of China.936;LC_MONETARY=Chinese_People's Republic of China.936;LC_NUMERIC=C;LC_TIME=Chinese_People's Republic of China.936 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: RSQLite DBI 0.4-17 0.1-11 Recent work on RSQLite has focused on integrating SQLite3's type system into the interface. We now rely on the column type in the DB when retrieving results. Previously, type.convert was used. I'm fairly certain these changes will result in changes in behavior -- in most cases, I think the changes are for the better. + seth __ 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 and provide commented, minimal, self-contained, reproducible code. -- Ronggui Huang Department of Sociology Fudan University, Shanghai, China 黄荣贵 复旦大学社会学系 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Help re zinb model
Hi all, I am hoping someone can help with a problem I have. I want to do a zero-inflated negative binomial model on some count data. I have found how to get the model (using zicounts), and the test of each predictor on both the negative binomial and zero-inflated parts of the distribution. Can anyone tell me how I can also get an omnibus test of significance for the fit of the model? Stata I think gives a likelihood ratio chi-square test of the full versus null model for the zinb model. Is there a way to get this in R? Alternatively, is there a way I use the deviance, or maximum likelihood value to derive this? Cheers Philippe Lacherez __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] rJava help
I've just bought a couple of iButton Thermochrons (logging thermometers), and I'd like to access them through their Java interface from R. But I've never really used Java, so I'm running into a problem, and I hope there's a very simple solution. I've managed to use rJava to create an object with provider - .jnew(com/dalsemi/onewire/OneWireAccessProvider) .jcall(provider,Ljava/lang/Class;, getClass) [1] Java-Object{class com.dalsemi.onewire.OneWireAccessProvider} and can see that it has a getDefaultAdapter method: .jmethods(provider,getDefaultAdapter) [1] public static com.dalsemi.onewire.adapter.DSPortAdapter com.dalsemi.onewire.OneWireAccessProvider.getDefaultAdapter() throws com.dalsemi.onewire.adapter.OneWireIOException,com.dalsemi.onewire.OneWireException but when I call that, I get an error: adapter - .jcall(provider, Lcom/dalsemi/onewire/adapter/DSPortAdapter;, getDefaultAdapter) Error in .jcall(provider, Lcom/dalsemi/onewire/adapter/DSPortAdapter;, : RcallMethod: method not found Is it obvious what I am doing wrong? Duncan Murdoch __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Software for kriging
Dear R-list members, I wish everyone a happy and successful 2007! Does anyone know of R-based software for optimal spatial prediction (kriging)? We are working on a seismic event characterisation technique and need to do some kriging. Any help would be greatly appreciated. Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Software for kriging
packages gstat and geoR both have kriging functions. There are probably others. Have a look at the spatial task view on CRAN. HTH, Simon. [EMAIL PROTECTED] wrote: Dear R-list members, I wish everyone a happy and successful 2007! Does anyone know of R-based software for optimal spatial prediction (kriging)? We are working on a seismic event characterisation technique and need to do some kriging. Any help would be greatly appreciated. Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. This message was sent using MyMail __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] need help with debug package
Hi all, I met a problem while using the debug package, I have the following program: mainfun- function(){ beta-1 result-subfun(beta+x) } subfun-function(expr){ y - eval(expr, envir=list(x=c(1,2)),enclos = parent.frame()) return(y) } I have no problem using this program without calling the debug package. but once I mtrace(subfun), the debugger can't find all the beta after entering subfun , and give the message : Error in beta : non-numeric argument to binary operator Is there anyway to get around ? thanks a lot happy new year __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Time series plot
Dear all R users, Suppose I have a data set like this: date price 1-Jan-02 4.8803747 2-Jan-02 4.8798430 3-Jan-02 4.8840133 4-Jan-02 4.8803747 5-Jan-02 4.8749683 6-Jan-02 4.8754263 7-Jan-02 4.8746628 8-Jan-02 4.8753500 9-Jan-02 4.8882416 10-Jan-02 4.8895217 11-Jan-02 4.8871108 I want to get a time series plot of that dataset. But in x-axis I want to see the first day, and last day, and other day in between them i.e. 1-Jan-02, 6-Jan-02, and 11-Jan-02 only. Can anyone tell me how to do that? My second question is that is there any way to define a secondary axis like Microsoft Excel in the same plot window? Thanks and regards, Arun [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time series plot
You can use read.zoo in the zoo package to read in the data and then see: https://www.stat.math.ethz.ch/pipermail/r-help/2006-December/122742.html See ?axis for creating additional axes with classic graphics and library(lattice) ?panel.axis in lattice graphics. Search the archives for examples. On 1/4/07, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear all R users, Suppose I have a data set like this: date price 1-Jan-02 4.8803747 2-Jan-02 4.8798430 3-Jan-02 4.8840133 4-Jan-02 4.8803747 5-Jan-02 4.8749683 6-Jan-02 4.8754263 7-Jan-02 4.8746628 8-Jan-02 4.8753500 9-Jan-02 4.8882416 10-Jan-02 4.8895217 11-Jan-02 4.8871108 I want to get a time series plot of that dataset. But in x-axis I want to see the first day, and last day, and other day in between them i.e. 1-Jan-02, 6-Jan-02, and 11-Jan-02 only. Can anyone tell me how to do that? My second question is that is there any way to define a secondary axis like Microsoft Excel in the same plot window? Thanks and regards, Arun [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help re zinb model
Remember that -2 * the difference in the likelihoods between the two models is asymptotically chi-squared distributed, with degrees of freedom equal to the difference in number of parameters between the models. So you can just calculate that for your preferred and null models, then use the pchisq function to test significance. Get the likelihoods from obj$maxlike. HTH, Simon. Philippe Lacherez wrote: [Hide Quoted Text] Hi all, I am hoping someone can help with a problem I have. I want to do a zero-inflated negative binomial model on some count data. I have found how to get the model (using zicounts), and the test of each predictor on both the negative binomial and zero-inflated parts of the distribution. Can anyone tell me how I can also get an omnibus test of significance for the fit of the model? Stata I think gives a likelihood ratio chi-square test of the full versus null model for the zinb model. Is there a way to get this in R? Alternatively, is there a way I use the deviance, or maximum likelihood value to derive this? Cheers Philippe Lacherez __ 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 and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. This message was sent using MyMail __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Help re zinb model
Of course that should have been differences in the log-likelihoods in my previous post. Aaargh. Simon. -- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. This message was sent using MyMail __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] mathematical symbols in plots
Dear Sebastian plot(1:10, 1:10) text(4, 9, expression(paste(, k, ))) should work here. Best regards, Christoph -- Credit and Surety PML study: visit our web page www.cs-pml.org -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C13 ETH Zurich 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Sebastian Weber writes: Hello everyone! I'm trying to plot some mathematical expression along my axis, but demo(plotmath) did not have the symbol I was looking for. In particular, I would like to denote the mean of an observable by writing k which I tried to enter with expression(group(, k, )) However, my naive try doesn't work and the help doesn't want to tell me, does someone know? And here another one: How can I sepcify which fonts get used with which R prints those mathematical symbols? Since I finally include my plots in latex-documents as eps, I would love to use the same font-encoding for all postscript stuff. A problem in the past has been, that R embedded it's own font within the ps-files generated. These were not compatible with the fonts used at the magazine where I published my document. This lead to quite some confusion as \gamma became g and so on. Any solution to this problem? Any hint? As I'm not too much into font-encoding, I have actually no real clue where to even start searching. Thank you very much for any help. Greetings, Sebastian Weber __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.