Re: [R] Correspondence Analysis
Dear Kris, I am not sure what you mean by a 'standard' -- but you may want to check out the ade4 package. Best Marwan -- Marwan Khawaja http://staff.aub.edu.lb/~mk36 -- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kris Lockyear Sent: Tuesday, November 14, 2006 5:03 AM To: r-help@stat.math.ethz.ch Subject: [R] Correspondence Analysis Dear All, I am in the process of teaching myself R and am getting the hang of it slowly, and so apologies for what may be a novice question. (Many thanks to those who have helped me so far). I have been performing normal Correspondence Analysis for a number of years using a variety of packages. CA is available in a number of R packages (e.g. vegan). Could anyone advise me which one(s) would provide me with the standard Greenacre diagnostic statistics (ie. quality, mass, contribution etc as discussed in Correspondence Analysis in Practice, esp. chapter 11) and how I get hold of them? Many thanks in advance, Kris Lockyear. _ 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-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] Building R from source
We have seen one other report of this (from someone cross-compiling) but cannot reproduce it, and pcre_dfa.exec.o should not be being linked in. Please do check against the R-admin manual (the definitive source) that you have the same versions of tools as recommended. It looks like this is a bug in some version of ld.exe (from binutils). A possible workaround is to edit src/extra/pcre/Makefile.win and remove pcre_dfa_exec.c from CSOURCES. Then delete libpcre.a, and try making again. But if you have a buggy ld.exe, I would want to use a non-buggy one. On Mon, 13 Nov 2006, YONGWAN CHUN wrote: Hello, I was trying to build R from source on Windows XP. I installed software which are mentioned from the follow web page http://www.murdoch-sutherland.com/Rtools/ (Last accessed on Nov. 13th, 2006) . Unfortunately, I got error messages whenever I run 'make all recommended' without modifying 'MkRules' file. I have removed software and reinstalled them several times but I still failed to get it done. The below message is what I got. If anybody gives information, I would appreciate it very much. Thanks, Yongwan === D:\Rsource\R-2.4.0\src\gnuwin32make all recommended make[1]: `Rpwd.exe' is up to date. make[4]: Nothing to be done for `svnonly'. installing C headers make[2]: `all' is up to date. make[2]: `libRblas.dll.a' is up to date. make[5]: Nothing to be done for `svnonly'. installing C headers make --no-print-directory -C ../extra/intl -f Makefile.win make --no-print-directory -C ../appl OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' FOPTFLAGS='-O3 -Wall' -f Makefile.win make --no-print-directory -C ../nmath OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' -f Makefile.win make --no-print-directory -C ../main OPTFLAGS='-O3 -Wall -pedantic -std=gnu99 -DLEA_MALLOC' FFLAGS='-O3 -Wall' -f Makef ile.win make --no-print-directory -C ./graphapp OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' make --no-print-directory -C ./getline OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' make[4]: `gl.a' is up to date. make -f Makefile.win chartables.h make[5]: `chartables.h' is up to date. make -f Makefile.win makeMakedeps make -f Makefile.win libpcre.a make[5]: `libpcre.a' is up to date. make[4]: Nothing to be done for `all'. make[4]: Nothing to be done for `all'. gcc -shared -s -mwindows -o R.dll R.def console.o dataentry.o dynload.o edit.o editor.o embeddedR.o extra.o opt.o pager .o preferences.o psignal.o rhome.o rui.o run.o shext.o sys-win32.o system.o e_pow.o malloc.o ../main/libmain.a ../appl/l ibappl.a ../nmath/libnmath.a graphapp/ga.a getline/gl.a ../extra/xdr/libxdr.a ../extra/zlib/libz.a ../extra/pcre/libpcre .a ../extra/bzip2/libbz2.a ../extra/intl/libintl.a ../extra/trio/libtrio.a dllversion.o -L. -lg2c -lRblas -lcomctl32 -lv ersion ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x15f9): undefined reference to `_pcre_ucp_findprop' ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1639): undefined reference to `_pcre_ucp_findprop' ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1736): undefined reference to `_pcre_ucp_findprop' ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1770): undefined reference to `_pcre_ucp_findprop' ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x184d): undefined reference to `_pcre_ucp_findprop' ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1e0f): more undefined references to `_pcre_ucp_findpro p' follow collect2: ld returned 1 exit status make[3]: *** [R.dll] Error 1 make[2]: *** [../../bin/R.dll] Error 2 make[1]: *** [rbuild] Error 2 make: *** [all] Error 2 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] Forcing the intercept
On Mon, 13 Nov 2006, Heather Maughan wrote: Dear R-users: I am doing multiple regressions using the lm function and would like to force the intercept to be equal to a specific value (such as 4.3). I was able to find out how to force it through the origin but this does not work for other values. ?offset, e.g 0+x1+x2+offset(rep(4.3, 127)) You could also use y-4.3 ~ rhs, but that gives problems for prediction. I am also interested in forcing the regression parameters obtained from one regression in another regression with a subset of the data. That makes no sense to me: do you just want to predict the fit on a subset? If so use predict() or fitted(). Are either of these possible in R? I have been searching the help guide for hours and have been unsuccessful. Not sure what 'the help guide' is, but you need a book about doing statistics with R. -- 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] Survival analysis of interval censored data
Some time ago, someone asked the list on the availability of tool for analyzing interval censored data in survival analysis. The answer at that moment was that there are some solutions but nothing like a useful R package (aside of Icens which offer some solution but needs more documentation to be useful). Does anyone know if the methods discussed in Klein and Moeschberger (1997) have been implemented in R? I, and many others, will appreciate any comment on this. Albert Sorribas Grup de Biomatemàtica i Bioestadística Departament de Ciències Mèdiques Bàsiques Universitat de Lleida Montserrat Roig 2 25008-Lleida (Espanya) web.udl.es/Biomath/Group [[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] greatest common substring
Dear R-members, Suppose I have a vector with the following strings: V = c(Welfare_Group_1024, Welfare_Group_1536, Welfare_Group_160) I want to 'automatically generate a nice y-axis label for this data. A good candidate is something close to Welfare Group. Is there an easy way to compute something close to the greatest common substring? It would be nice if it also works in this case: V = c(xxxWelfare_Group_1024, yWelfare_Group_1536, zWelfare_Group_160) Should I iterate through all possible substrings in the first element, to see whether this substring is part of all other strings? I was hoping for some existing R function :) Thanks in advance, JeeBee. __ 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] ??: Re: Need help in waveslim package: imodwt and universal.thresh.modwt
Airon, I used R2.4.0 on a Windows XP (SP2) (not Chinese :-)) and it still works: data = read.csv(u:/airon.csv) xdata = data$Adj..Close modwt.la8 = modwt(xdata, la8, n.level=6) summary(modwt.la8) Length Class Mode d1 1467 -none- numeric d2 1467 -none- numeric d3 1467 -none- numeric d4 1467 -none- numeric d5 1467 -none- numeric d6 1467 -none- numeric s6 1467 -none- numeric ydata = imodwt(modwt.la8) summary(ydata) Min. 1st Qu. MedianMean 3rd Qu.Max. 37.35 57.56 67.93 67.31 78.32 104.90 max(ydata-xdata) [1] 2.957279e-11 Can you provide a simple program and the resulting messages showing that it doesn't work? Rogerio. -- Cabeçalho original --- De: Airon Yiu [EMAIL PROTECTED] Para: rdporto1 [EMAIL PROTECTED] Cópia: r-help r-help@stat.math.ethz.ch Data: Tue, 14 Nov 2006 13:56:51 +0800 (CST) Assunto: ??: Re:[R] Need help in waveslim package: imodwt and universal.thresh.modwt Hi Rogerio: I am using Waveslim 1.5 on R 2.3.0, running on Chinese WinXP (SP2). The data, attached in the CSV file, is a stock data (0001 from Hong Kong) downloaded from Yahoo!Finance. The time series data are the Adj. Close prices (last column) from 4-Jan-00 to 30-Nov-2005. The waveslim mra rountines are working fine on these data. Thks __ 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] dividing vectors into bins with equal widths
Hi R-users, I am trying to divide a vector (say X) into equal frequency bins. If one uses the hist() function, then a histogram is plotted, but with bins of equal widths, and not with bins having the same number of data points. I have then tried the histogram() function as follows: histogram(X, nint=10, breaks=NULL, equal.widths=F) This works as I want. However, I can't extract which points are in which bin, or where the breakpoints are made. Can anybody help? Thanks Daniel W. Daniel Kissling Institut für Zoologie, Abteilung Ökologie Johannes Gutenberg-Universität Mainz D-55099 Mainz, Germany 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] running R without X11
Hello, I'm trying to run R from a webserver, which doesn't have an X server, and produce pngs to go on a webpage, is this possible? I'm doing it in gnuplot with gnuplot set term png gnuplot set output With $DISPLAY unset, I get the following error from R: png() Error in X11(paste(png::, filename, sep = ), width, height, pointsize, : unable to start device PNG In addition: Warning message: unable to open connection to X11 display '' Is there anyway to remove this dependency on X11? Thanks, Laurence __ 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] dividing vectors into bins with equal widths
you probably looking for something like: x - rnorm(20) out - cut(x, quantile(x, seq(0, 1, len = 11)), include.lowest = TRUE) out table(out) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: W. Daniel Kissling [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Cc: [EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 1:52 PM Subject: [R] dividing vectors into bins with equal widths Hi R-users, I am trying to divide a vector (say X) into equal frequency bins. If one uses the hist() function, then a histogram is plotted, but with bins of equal widths, and not with bins having the same number of data points. I have then tried the histogram() function as follows: histogram(X, nint=10, breaks=NULL, equal.widths=F) This works as I want. However, I can't extract which points are in which bin, or where the breakpoints are made. Can anybody help? Thanks Daniel W. Daniel Kissling Institut für Zoologie, Abteilung Ökologie Johannes Gutenberg-Universität Mainz D-55099 Mainz, Germany 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 amova (ade4)
Hello, I am interested in using the amova function of ade4 package of R. I would like to know if there is any possibility to perform an amova with a specific anova model, as a factorial anova with some factors nested, or, if this could not be done, how could I perform an anova with my specific model but with molecular distance data? I would be very grateful if you could help me with this fact in any manner. Thank you in advance for your help. Regards, Alicia __ 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] confige error:X11 headres/libs
Can someone who uses SuSe Linux (I currently use 9.3) please tell me what I need toto to avoid the message configure: error: --with-x=yes (default) and X11 headers/libs are not available without setting --with-x=no currently my /usr/lib/X11 directory looks like this ls /usr/lib/X11 app-defaults fvwm2 nlstwm XErrorDB Xmodmap Cards getconfig Optionswmmount xinit Xmodmap.remote etc icons proxymngr x11perfcomp xkbXresources fonts lbxproxy rgb.txtxdm XKeysymDB xserver fslocale rstart xeditxman.help xsm thanks tom __ 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] confige error:X11 headres/libs
Please do as the file INSTALL asks and read the R-admin.html file. It says Remember that some package management systems (such as RPM and deb) make a distinction between the user version of a package and the development version. The latter usually has the same name but with the extension `-devel' or `-dev': you need both versions installed. Unless you do not want to view graphs on-screen you need `X11' installed, including its headers and client libraries. (On Fedora Core Linux this means the `xorg-x11-devel' and `xorg-x11-libs' RPMs, for example. Older Linuxen used `XFree86-'. Some Debian derivatives apparently also require `libxt-dev'.) If you really do not want these you will need to explicitly configure R without X11, using --with-x=no. On Tue, 14 Nov 2006, thomas phillipson wrote: Can someone who uses SuSe Linux (I currently use 9.3) please tell me what I need toto to avoid the message configure: error: --with-x=yes (default) and X11 headers/libs are not available without setting --with-x=no currently my /usr/lib/X11 directory looks like this ls /usr/lib/X11 app-defaults fvwm2 nlstwm XErrorDB Xmodmap Cards getconfig Optionswmmount xinit Xmodmap.remote etc icons proxymngr x11perfcomp xkbXresources fonts lbxproxy rgb.txtxdm XKeysymDB xserver fslocale rstart xeditxman.help xsm thanks tom __ 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] confige error:X11 headres/libs
Prof Brian Ripley wrote: Please do as the file INSTALL asks and read the R-admin.html file. It says Remember that some package management systems (such as RPM and deb) make a distinction between the user version of a package and the development version. The latter usually has the same name but with the extension `-devel' or `-dev': you need both versions installed. Unless you do not want to view graphs on-screen you need `X11' installed, including its headers and client libraries. (On Fedora Core Linux this means the `xorg-x11-devel' and `xorg-x11-libs' RPMs, for example. Older Linuxen used `XFree86-'. Some Debian derivatives apparently also require `libxt-dev'.) If you really do not want these you will need to explicitly configure R without X11, using --with-x=no. They have the same names on my SuSE 9.2 installation as Prof. Ripley indicated for a Fedora Core system. On SuSE, you need to install these packages with YaST (assuming that's what you are using for system admin). On Tue, 14 Nov 2006, thomas phillipson wrote: Can someone who uses SuSe Linux (I currently use 9.3) please tell me what I need toto to avoid the message configure: error: --with-x=yes (default) and X11 headers/libs are not available without setting --with-x=no currently my /usr/lib/X11 directory looks like this ls /usr/lib/X11 app-defaults fvwm2 nlstwm XErrorDB Xmodmap Cards getconfig Optionswmmount xinit Xmodmap.remote etc icons proxymngr x11perfcomp xkbXresources fonts lbxproxy rgb.txtxdm XKeysymDB xserver fslocale rstart xeditxman.help xsm thanks tom -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.946.8081 Fax: 416.946.3297 __ 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] For MacBook, best way to do R?
Mitchell, I have been using R on a variety of Macs for a couple of years with no problems. The R aqua interface is very good and I see no compelling reason to not use the precompiled binaries. Regards, Tom Mitchell Maltenfort wrote: I'm getting a MacBook and I'd like to stick with OS X rather than convert it to Linux just yet. However, my main concern is having decent performance. What's my best option: *use the existing binary for R? *compile R fresh under OS X? * install Linux and run R under that? Does anyone have any recent experience they can share? Thanks! -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: [EMAIL PROTECTED] VOICE: 937-383-0528 FAX:937-383-0033 __ 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] greatest common substring
Try: V1 - c(Welfare_Group_1024, Welfare_Group_1536, Welfare_Group_160) V2 - c(xxxWelfare_Group_1024, yWelfare_Group_1536, zWelfare_Group_160) lcs - function(ff) { L - ff[1]; for(f in ff) L - lcs2(f,L); L } lcs(V1) lcs(V2) where lcs2 was posted here: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/68013.html There are some obvious optimizations but just for y-axis labelling you probably don't need them. On 11/14/06, Jonne Zutt [EMAIL PROTECTED] wrote: Dear R-members, Suppose I have a vector with the following strings: V = c(Welfare_Group_1024, Welfare_Group_1536, Welfare_Group_160) I want to 'automatically generate a nice y-axis label for this data. A good candidate is something close to Welfare Group. Is there an easy way to compute something close to the greatest common substring? It would be nice if it also works in this case: V = c(xxxWelfare_Group_1024, yWelfare_Group_1536, zWelfare_Group_160) Should I iterate through all possible substrings in the first element, to see whether this substring is part of all other strings? I was hoping for some existing R function :) Thanks in advance, JeeBee. __ 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] Matrix-vector multiplication without loops
I think you need something along these lines: ind - c(sapply(1:(K+1), seq, length = K + 1)) cf1 - rep(rep(coef, each = n), K + 1) cf2 - rep(rep(coef, each = n), each = K + 1) rowSums(cf1 * cf2 * U[, ind]) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Ravi Varadhan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, November 14, 2006 4:45 PM Subject: [R] Matrix-vector multiplication without loops Hi, I am trying to do the following computation: p - rep(0, n) coef - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) for (i in 0:K){ for (j in 0:K){ p - p + coef[i+1]* coef[j+1] * U[,i+j+1] } } I would appreciate any suggestions on how to perform this computation efficiently without the for loops? Thank you, 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 [[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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] running R without X11
On Tue, 14 Nov 2006, Laurence Darby wrote: Hello, I'm trying to run R from a webserver, which doesn't have an X server, and produce pngs to go on a webpage, is this possible? Yes, see the help page for png. I'm doing it in gnuplot with gnuplot set term png gnuplot set output With $DISPLAY unset, I get the following error from R: png() Error in X11(paste(png::, filename, sep = ), width, height, pointsize, : unable to start device PNG In addition: Warning message: unable to open connection to X11 display '' Is there anyway to remove this dependency on X11? Please read the help page. R's png device uses X11 for its fonts. You need fonts from somewhere, and vanilla Unix systems don't come with any other sets. You can use ghostscript or libgdd or other resources for other graphics devices. I normally just use an Xvfb frame buffer (but, hint, it defaults to 12bit and you want a 24bit screen). -- 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] dividing vectors into bins with equal widths
Hi Daniel, Make sure to include working code and list all needed packages. I couldn't run your code on my machine. If you want equal data points in each class, then you could take every n point from the sorted vector. This example generates the breakpoints to divide a vector in 10 parts. x - floor(rnorm(100) * 10) x [1] -2 9 -12 3 11 7 6 -4 -16 -1 1 -7 -7 7 4 -4 -7 13 1 9 10 1 11 19 -19 -3 12 -6 5 -7 1 -13 -15 [34] 11 -8 -2 -13 10 6 8 15 4 0 -4 12 5 -2 -3 9 -17 -5 9 0 3 7 7 8 -14 -12 -4 -4 -24 -4 4 16 5 [67] 6 -8 -7 -14 -8 -4 -9 18 -2 11 11 -16 -2 2 -1 -8 10 2 21 -9 1 -3 -17 -4 10 -5 -14 7 -13 -6 8 -4 -2 [100] -2 NBreaks - 10 sort(x)[NBreaks * (1:(length(x) / NBreaks - 1))] [1] -14 -8 -5 -3 -1 2 6 9 11 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 W. Daniel Kissling Verzonden: dinsdag 14 november 2006 13:52 Aan: r-help@stat.math.ethz.ch CC: [EMAIL PROTECTED] Onderwerp: [R] dividing vectors into bins with equal widths Hi R-users, I am trying to divide a vector (say X) into equal frequency bins. If one uses the hist() function, then a histogram is plotted, but with bins of equal widths, and not with bins having the same number of data points. I have then tried the histogram() function as follows: histogram(X, nint=10, breaks=NULL, equal.widths=F) This works as I want. However, I can't extract which points are in which bin, or where the breakpoints are made. Can anybody help? Thanks Daniel W. Daniel Kissling Institut für Zoologie, Abteilung Ökologie Johannes Gutenberg-Universität Mainz D-55099 Mainz, Germany 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-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] gzfile with multiple entries in the archive
If I open a tgz archive with gzfile and then parse it using readLines I miss the initial line of each member of the archive - and also the name of the file although the archive otherwise complete (but useless!). Is there any way within R to extract both the list of files in a tgz archive and to extract any one of these files? Clearly I can use zcat and tar on Linux, but I need this to work within the R environment on Windows! Thanks John James [[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] For MacBook, best way to do R?
Thomas Adams[EMAIL PROTECTED] 14/11/2006 13:27 I'm getting a MacBook and I'd like to stick with OS X rather than convert it to Linux just yet. However, my main concern is having decent performance. What's my best option: *use the existing binary for R? *compile R fresh under OS X? * install Linux and run R under that? Does anyone have any recent experience they can share? Thanks! On my side: new to R, new to Mac OS X, but enjoying this new environment in a brand new MacBook. I think the R-SIG-Mac list, r-sig-mac@stat.math.ethz.ch, could be of major help. HTH, Ricardo -- Ricardo Rodríguez Your EPEC ICT Team __ 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] Variance of a complex estimator using survey package ...
Hi, I want to compute the variance of two complex statistics. The first statistic is the a ratio R1=Q(a1)/Q(a2) where Q denote de quantile at a1 and a2. The second is also a ratio but not a classic one this ratio is R2=sum(x_{i}|x_{i}Q(a1))/sum(x_{i}|x_{i}Q(a2)) Linearisation for those statistic is very complex. I want to use bootstrap and JKn How can I procede since I dont have a function like svrepanyfunction where you just specify the function to compute the statistic. Sincerly. Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses. ___ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses [[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] chi.test in R
downunder [EMAIL PROTECTED] writes: Hi all. I need some help computing multidimensional pvalues of a multivariate data set. chisq.test(x[,1],x[,2])$p.value i need a command or loop that creates me a vector or a matrix (each variabe with each variable) would be even better for the p.values of the variables of a data set. something like chisq.test(x[,1:5],x[,2])$p.value or i=c(1,2,3) chisq.test(x[,i],x[,j])$p.value doesn't work look at mapply, or generally apply HTH, Jens __ 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] running R without X11
Prof Brian Ripley wrote: On Tue, 14 Nov 2006, Laurence Darby wrote: Is there anyway to remove this dependency on X11? Please read the help page. R's png device uses X11 for its fonts. You need fonts from somewhere, and vanilla Unix systems don't come with any other sets. You can use ghostscript or libgdd or other resources for other graphics devices. I normally just use an Xvfb frame buffer (but, hint, it defaults to 12bit and you want a 24bit screen). Thanks for your prompt answer, although getting gs to work the way I want or setting up Xvfb, on top of learning R, is too many hoops to jump through, much more than reproducing a small R script I have in gnuplot. Laurence __ 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] Variance of a complex estimator using survey package ...
On Tue, 14 Nov 2006, justin bem wrote: Hi, I want to compute the variance of two complex statistics. The first statistic is the a ratio R1=Q(a1)/Q(a2) where Q denote de quantile at a1 and a2. The second is also a ratio but not a classic one this ratio is R2=sum(x_{i}|x_{i}Q(a1))/sum(x_{i} }|Q(a2)) Linearisation for those statistic is very complex. I want to use bootstrap and JKn How can I procede since I dont have a function like svrepanyfunction where you just specify the function to compute the statistic. You can specify any function of data and weights as an argument to withReplicates(). JKn weights will not work for the first statistic (they don't work for quantiles), but bootstrap weights should work. -thomas __ 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] gzfile with multiple entries in the archive
On Tue, 14 Nov 2006, John James wrote: If I open a tgz archive with gzfile and then parse it using readLines I miss the initial line of each member of the archive - and also the name of the file although the archive otherwise complete (but useless!). You can use a gzfile connection to read the underlying .tar file, but that is not a text file and you will need to pick its structure apart yourself via readBin and readChar. Is there any way within R to extract both the list of files in a tgz archive and to extract any one of these files? Clearly I can use zcat and tar on Linux, but I need this to work within the R environment on Windows! You could use tar on Windows: it is in the R tools set. -- 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] Fetching Intraday data from Bloomberg
na.action=bloomberg.handles will leave out any bars with no data. I don't see a way to get just trading days but take fill action (prev or na) if there is no data for a bar on a trading day. This is the same in the API. The periodicity parameter doesn't make sense in this context. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Monday, November 13, 2006 9:39 AM To: r-help@stat.math.ethz.ch Subject: [R] Fetching Intraday data from Bloomberg Hi Everyone. I am downloading intraday Bloomberg data from R. The code I give is: library(zoo) library(chron) library(RBloomberg) conn-blpConnect(show.days=trading,na.action=previous.days,periodici ty=daily) dat-blpGetData(conn, VG1 Index, c(LAST_PRICE), start=as.chron(as.Date(2006-9-01, %Y-%m-%d)),barfields=OPEN, barsize=10,retval=data.frame) blpDisconnect(conn) write.table(dat,Z:\h1.csv,sep=,,row.names=F,col.names=T) Now, though I give show.days=trading, in the above code, my intraday downloads also have Saturdays and Sunday data (non-active days). Why is this so? Is it not updated in R? Note that this happens only for intraday downloads and not for the usual historical downloads where time is not considered. Please answer me ASAP... Thanks in advance. [[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] drawing axes on all 4 sides of a trellis plot
Hi, I am creating a 4 x 8 trellis plot. I want the y axis scaled by the data in the rows, and the x axis scaled by data in each column. In March 2006 there was a post describing a way to do this. The link is: tolstoy.newcastle.edu.au/R/help/06/03/22937.html I am using the data from the example provided in the earlier post and have modified the plotting code to meet my needs (see below). The problem with the result is that the x and y axes only appear on the left and bottom of the plot. I would like them to appear on the left/bottom and top/right. However, the workaround to produce the plot requires setting relation to free, which causes xyplot to ignore the alternating argument. Any suggestions on how to do this would be greatly appreciated. Thanks, Steve d - expand.grid(a = gl(4, 1, 20), b = gl(8, 1, 40)) d$x - with(d, rnorm(nrow(d), mean = as.numeric(a) + as.numeric(b))) d$y - with(d, rnorm(nrow(d), mean = as.numeric(a) + as.numeric(b))) xyplot(y ~ x | a + b, d, scales = list(y = list(relation = free, limits = rep(c(rep(list(c(0,100)),4),rep(list(c(0,10)),4)),4), at = rep(list(TRUE, NULL, NULL, NULL),8)), x = list(relation = free, limits = rep(list(c(0, 11), c(1, 12), c(2, 13), c(4, 14)), 8), at = rep(list(NULL, TRUE),c(28,4)), labels = c(rep(list(NULL),28),rep(list(TRUE, NULL),2, par.settings = list(layout.heights = list(axis.panel = rep(c(0, 1), c(7, 1))), layout.widths = list(axis.panel = rep(c(1, 0), c(1, 3, par.strip.text = list(cex = 0.5), as.table=TRUE) __ 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] query in R
Xiaodong Jin [EMAIL PROTECTED] writes: how to realize the following SQL command in R? select distinct A, B, count(C) from TABLE group by A, B ; quit; The functional equivalent of is statement in R on a dataframe is: TABLE$ones - 1; aggregate(TABLE$ones, list(TABLE$a, TABLE$b), sum); HTH, Jens __ 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] Error in str(its-object)
Dear all, on my Windows XP R 2.4.0 version with Package its version 1.1.4 I have a problem with str() applied on an its-object after a simple matrix manipulation on the its object (see below). I am not sure, whether this a problem with my application, its or str(). Of course, one can make str(core(its(mat)) / 1) num [1:2, 1:3] 1 2 3 4 5 6 - attr(*, dimnames)=List of 2 ..$ : chr [1:2] 2003-01-01 2003-01-04 ..$ : chr [1:3] a b c But its object should be able to handle simple matrix multiplications, even if the result is a matrix. Any help is greatly appreciated. Many thanks in advance, Stefan mat - structure(1:6,dim=c(2,3),dimnames=list(c(2003-01-01,2003-01-04),letters[1:3])) its(mat) An object of class its a b c 2003-01-01 1 3 5 2003-01-04 2 4 6 Slot dates: [1] 2003-01-01 Westeuropäische Normalzeit 2003-01-04 Westeuropäische Normalzeit str(its(mat)) Formal class 'its' [package its] with 2 slots ..@ .Data: int [1:2, 1:3] 1 2 3 4 5 6 .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : chr [1:2] 2003-01-01 2003-01-04 .. .. ..$ : chr [1:3] a b c ..@ dates:'POSIXct', format: chr [1:2] 2003-01-01 2003-01-04 str(its(mat) / 1) Error in ob[!is.na(ob)] : (subscript) logical subscript too long str(its(mat / 1)) Formal class 'its' [package its] with 2 slots ..@ .Data: num [1:2, 1:3] 1 2 3 4 5 6 .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : chr [1:2] 2003-01-01 2003-01-04 .. .. ..$ : chr [1:3] a b c ..@ dates:'POSIXct', format: chr [1:2] 2003-01-01 2003-01-04 class(its(mat / 1)) [1] its attr(,package) [1] its Dr. Stefan Albrecht, CFA Allianz Private Equity Partners GmbH Giselastr. 4 | 80802 Munich | Germany Phone: +49.(0)89.3800.18317 Fax: +49.(0)89.3800.818317 EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.apep.com http://www.apep.com/ Please note my new email address: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix-vector multiplication without loops
Hi, I am trying to do the following computation: p - rep(0, n) coef - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) for (i in 0:K){ for (j in 0:K){ p - p + coef[i+1]* coef[j+1] * U[,i+j+1] } } I would appreciate any suggestions on how to perform this computation efficiently without the for loops? Thank you, 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 [[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] Error in str(its-object)
StAl == Albrecht, Dr Stefan (AZ Private Equity Partner) [EMAIL PROTECTED] on Tue, 14 Nov 2006 15:36:45 +0100 writes: StAl Dear all, on my Windows XP R 2.4.0 version with StAl Package its version 1.1.4 I have a problem with str() StAl applied on an its-object after a simple matrix StAl manipulation on the its object (see below). I am not StAl sure, whether this a problem with my application, its StAl or str(). I'd say mainly with its, and then with R internal arithmetic. str() actually reveals that the object you produce is not ``valid'' anymore in a certain sense (see below). StAl .. But its object should be able to handle simple matrix StAl multiplications, even if the result is a matrix. Any StAl help is greatly appreciated. / 1 is not a simple multiplication. But I agree that package its (which you failed to mention) should make sure that ' itsObj / 1 ' should work -- which it does not. Here is a reproducible example script - extended from your transcript : -- (mat - matrix(1:6, 2,3, dimnames=list(c(2003-01-01,2003-01-04),letters[1:3]))) library(its) (im - its(mat)) str(im) isS4(im)# TRUE, of course, but .. isS4(im / 1)# FALSE !!! ## even though class(im / 1) ## shows ## [1] its ## attr(,package) ## [1] its ## and the reason comes from selectMethod(/, signature(e1 = its, e2 = numeric)) ## - .Primitive(/) -- So what happens is that the builtin arithmetic *does* work on the .Data slot automatically -- as it should IIRC the green book on this topic. What the builtin arithmetic *fails* to do, is keeping the S4-object bit. -- I'll post a version of this to R-devel, since I think we should consider improving the current behavior here. For the current version of R, the maintainer of its should really define Arith methods for signature(its, numeric) and signature(numeric, its). Martin Maechler, ETH Zurich __ 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] indexing question
idx = c(31, 36, 41, 61, 66, 71, 91, 96, 101, 121, 126, 131) temp = 1:150 res = temp[idx] dim(res) = c(3, length(res) %/% 3) res = t(rbind(res, res[2, ] - res[1, ], res[3, ] - res[2, ])) res Heikki Kaskelma -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Monday, November 13, 2006 10:06 PM To: r-help@stat.math.ethz.ch Subject: [R] indexing question I have the following set of indices, call it idx, that correspond to the indices of a vector say temp. [1] 31 36 41 61 66 71 91 96 101 121 126 131 151 156 161 181 186 191 211 216 221 241 246 251 271 276 281 301 306 311 331 336 341 361 366 [36] 371 391 396 401 421 426 431 451 456 461 481 486 491 511 516 521 541 546 551 571 576 581 601 606 611 631 636 641 661 666 671 691 696 701 721 [71] 726 731 751 756 761 781 786 791 811 816 821 841 846 851 871 876 881 901 906 911 931 936 941 961 966 971 991 996 1001 1021 1026 1031 1051 1056 1061 [106] 1081 1086 1091 1116 1121 1141 1146 1151 1171 1176 1181 1201 1206 1211 1231 1236 1241 1261 1266 1271 1291 1296 1301 1321 1326 1331 1351 1356 1361 1381 1386 1391 1411 1416 [141] 1421 I want to calculate temp[36] - temp[31] and temp[41] - temp[36] Similarly, temp[66] - temp[61] and temp[71] - temp[66] . . . . Similarly temp[1416]-temp[1411] temp[1421] - temp[1416] I'm doing this because the above subractions represent pairs of returns and the correlations between them wil be calculated eventually. In other words, eventually I will have X_36_31 ( i.e : temp[36] - temp[31] ) X_66-61 X_96-91 . . . . . . . X_1411-1416 as one vector and Y_41-36 Y_71-66 Y_101-96 . . . . . Y_1416_1421 as another vector. and will calculate the correlation between the two vectors in order to get one number. The point is I am really only using the indices 31, 61, 91 etc as anchor's so a regular diff(temp[idx]) won't work because it will diff all the elements that are next to each other ? This is a weird problem. I'm still thinking about it. I'm hoping to figure it out before someone sends me something but I won't mind so much if I get an external solution first. I have no pride. 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. __ 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] Enabling function tips under ESS environment?
I use R in Mac environment ( R 2.4.0 under Tiger 10.4.7, Intel Machine. ) Function tips appear below the command line window in R.app. It makes me write R code correctly. I tried to view function tips under Emacs using ESS, but unfortunately failed. Could you tell me how to make ESS show function tips? Attached is captured image of R.app under Mac. I am looking forward to hearing from you. Sincerely,  === Dong H. Oh Ph. D Candidate Techno-Economics and Policy Program College of Engineering, Seoul National University, Seoul, 151-050, Republic of Korea E-mail:[EMAIL PROTECTED] Mobile: +82-10-6877-2109 Office : +82-2-880-9142 Fax: +82-2-880-8389 === __ 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] Error in str(its-object)
I'll update ITS to include that signature. Right now, the only signature for Arith is: signature(e1=its,e2=its). Thx, Whit -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Maechler Sent: Tuesday, November 14, 2006 11:24 AM To: Stefan Albrecht Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Error in str(its-object) StAl == Albrecht, Dr Stefan (AZ Private Equity Partner) [EMAIL PROTECTED] on Tue, 14 Nov 2006 15:36:45 +0100 writes: StAl Dear all, on my Windows XP R 2.4.0 version with StAl Package its version 1.1.4 I have a problem with str() StAl applied on an its-object after a simple matrix StAl manipulation on the its object (see below). I am not StAl sure, whether this a problem with my application, its StAl or str(). I'd say mainly with its, and then with R internal arithmetic. str() actually reveals that the object you produce is not ``valid'' anymore in a certain sense (see below). StAl .. But its object should be able to handle simple matrix StAl multiplications, even if the result is a matrix. Any StAl help is greatly appreciated. / 1 is not a simple multiplication. But I agree that package its (which you failed to mention) should make sure that ' itsObj / 1 ' should work -- which it does not. Here is a reproducible example script - extended from your transcript : -- (mat - matrix(1:6, 2,3, dimnames=list(c(2003-01-01,2003-01-04),letters[1:3]))) library(its) (im - its(mat)) str(im) isS4(im)# TRUE, of course, but .. isS4(im / 1)# FALSE !!! ## even though class(im / 1) ## shows ## [1] its ## attr(,package) ## [1] its ## and the reason comes from selectMethod(/, signature(e1 = its, e2 = numeric)) ## - .Primitive(/) -- So what happens is that the builtin arithmetic *does* work on the .Data slot automatically -- as it should IIRC the green book on this topic. What the builtin arithmetic *fails* to do, is keeping the S4-object bit. -- I'll post a version of this to R-devel, since I think we should consider improving the current behavior here. For the current version of R, the maintainer of its should really define Arith methods for signature(its, numeric) and signature(numeric, its). Martin Maechler, ETH Zurich __ 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. This e-mail message is intended only for the named recipient(s) above. It may contain confidential information. If you are not the intended recipient you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and delete the message and any attachment(s) from your system. Thank you. __ 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] Error in str(its-object)
A workaround if you need to multiply an its object by a number would be to convert the its object to zoo, do the multiply on the zoo object and then convert the resulting zoo object back to its. Using im from Martin's example: library(its) library(zoo) im as.its(3 * as.zoo(im)) On 11/14/06, Martin Maechler [EMAIL PROTECTED] wrote: StAl == Albrecht, Dr Stefan (AZ Private Equity Partner) [EMAIL PROTECTED] on Tue, 14 Nov 2006 15:36:45 +0100 writes: StAl Dear all, on my Windows XP R 2.4.0 version with StAl Package its version 1.1.4 I have a problem with str() StAl applied on an its-object after a simple matrix StAl manipulation on the its object (see below). I am not StAl sure, whether this a problem with my application, its StAl or str(). I'd say mainly with its, and then with R internal arithmetic. str() actually reveals that the object you produce is not ``valid'' anymore in a certain sense (see below). StAl .. But its object should be able to handle simple matrix StAl multiplications, even if the result is a matrix. Any StAl help is greatly appreciated. / 1 is not a simple multiplication. But I agree that package its (which you failed to mention) should make sure that ' itsObj / 1 ' should work -- which it does not. Here is a reproducible example script - extended from your transcript : -- (mat - matrix(1:6, 2,3, dimnames=list(c(2003-01-01,2003-01-04),letters[1:3]))) library(its) (im - its(mat)) str(im) isS4(im)# TRUE, of course, but .. isS4(im / 1)# FALSE !!! ## even though class(im / 1) ## shows ## [1] its ## attr(,package) ## [1] its ## and the reason comes from selectMethod(/, signature(e1 = its, e2 = numeric)) ## - .Primitive(/) -- So what happens is that the builtin arithmetic *does* work on the .Data slot automatically -- as it should IIRC the green book on this topic. What the builtin arithmetic *fails* to do, is keeping the S4-object bit. -- I'll post a version of this to R-devel, since I think we should consider improving the current behavior here. For the current version of R, the maintainer of its should really define Arith methods for signature(its, numeric) and signature(numeric, its). Martin Maechler, ETH Zurich __ 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] query in R
sqlQuery() function in RODBC library will be helpful. Sincerely, On Nov 15, 2006, at 1:33 AM, Jens Scheidtmann wrote: Xiaodong Jin [EMAIL PROTECTED] writes: how to realize the following SQL command in R? select distinct A, B, count(C) from TABLE group by A, B ; quit; The functional equivalent of is statement in R on a dataframe is: TABLE$ones - 1; aggregate(TABLE$ones, list(TABLE$a, TABLE$b), sum); HTH, Jens __ 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. === Dong H. Oh Ph. D Candidate Techno-Economics and Policy Program College of Engineering, Seoul National University, Seoul, 151-050, Republic of Korea E-mail:[EMAIL PROTECTED] Mobile: +82-10-6877-2109 Office : +82-2-880-9142 Fax: +82-2-880-8389 __ 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 and NULL values
Dear all, I'm afraid I'm still having trouble with RODBC and NULL values on Mac OS X 10.4.8. (I would add that otherwise, RODBC is running perfectly, and is doing an excellent job!). R 2.4. As before, all my data is stored in Postgresql 8.1.4. I'm using Actual's ODBC drivers (now updated to 2.5). I've removed RODBC and reinstalled, compiling from source rather than using the binary package. Installed using the line (all one line): LIBS='-framework iODBC' PKG_CFLAGS='-I/Library/Frameworks/iODBC.framework/Headers' R CMD INSTALL RODBC_1.1-7.tar.gz NULL values *are* correctly returned to a number of different client applications, including iodbctest, Filemaker, Excel and R/RdbiPgSQL, but not RODBC. SQLselect calc_survival_unilateral_support as unilateral, has_family_history_ataxia as familial from clinical, patient where clinical.patient_fk=patient_id and excluded=0 and calc_walking_disability_valid=1; unilateral |familial + 6 |1 6 |0 4 |0 2 |0 5 |1 |0 |1 8 |0 |0 |0 Running the same query from Excel, Filemaker or RdbiPgSQL correctly imports the data with missing data as NULL or empty. This is not the case using R/RODBC: unilateral = sqlQuery(channel, select calc_survival_unilateral_support as unilateral, has_family_history_ataxia as familial from clinical, patient where clinical.patient_fk=patient_id and excluded=0 and calc_walking_disability_valid=1) unilateral[1:10,] unilateral familial 1 61 2 60 3 40 4 20 5 51 6 00 7 01 8 80 9 00 10 00 These fields are both defined as numeric. There is no difference if I use 'ALTER TABLE' to change to int4. Using as.is makes no difference. I cannot explain why NULL values are not being transferred correctly using RODBC. Are there any other diagnostic strategies I could try? Since I last posted, I have installed RdbiPgSQL, and this seems to work. conn = dbConnect(PgSQL(), host=localhost, dbname=ataxia) test.df = dbGetQuery(conn, select calc_survival_unilateral_support as unilateral, has_family_history_ataxia as familial from clinical, patient where clinical.patient_fk=patient_id and excluded=0 and calc_walking_disability_valid=1) test.df[1:10,] unilateral familial 1 61 2 60 3 40 4 20 5 51 6 NA0 7 NA1 8 80 9 NA0 10 NA0 In my dataset, there is a considerable interpretative difference between NA and zero. I don't know how to take this further, and perhaps it only applies to my peculiar set-up. If there are any further diagnostic tests that others can suggest, or some debug mode (I can't see this in the source code), then let me know. Obviously, the fact that RdbiPgSQL successfully manages to transfer NULL values limits the problem to either the ODBC driver or RODBC itself. The success with iodbc, Filemaker and Excel as ODBC client presumably suggests this problem is limited to RODBC, and is not an ODBC driver problem? Any ideas? I'll be switching to RdbiPgSQL from now, but I thought it appropriate to flag this up as an unsolved problem. Many thanks, Best wishes, Mark -- Dr. Mark Wardle Clinical research fellow and Specialist Registrar in Neurology, C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Profile confidence intervals and LR chi-square test
Thank you to Prof Ripley and Henric Nilsson for their observation that I was using anova inappropriately for the question that I was trying to answer. Note that the Wald statistics and confidence interval were calculable in the previous email but that I prefered using the more accurate deviance statistics. I will demonstrate my error for the benefit of those new users of R (like me) that may not have appreciated how the anova function is working SEQUENTIALLY, and what SEQUENTIALLY actually means in this context. Since the anova function is a sequential test of the current model, only the statistic for the last term in the model formula is a true deviance chi-square statistic for (full model) .vs. (full model - term). For instance, using the data upon which this question was based, consider the following 2 models: -- fit0 - glm(y ~ 1, data=d, family=binomial(link=logit), na.action=na.omit) fit1 - update(fit0, . ~ . + x1 + x2 + x3) -- Here, fit0 is the null (intercept-only) model and fit1 is the full model (without interactions because interactions are not biologically plausible in this medical dataset). Now notice the result of the anova function for the full model: -- anova(fit1, test='Chisq') ... Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL99137.989 x118.26798129.721 0.004 x215.63997124.083 0.018 x313.43396120.650 0.064 --- It is incorrect to interpret the deviance chi-square test presented above for x1 (P=0.004) as the deviance chi-square statistic comparing (y~x1+x2+x3) .vs. (y~x2+x3) as the statistic calculated is for (y~1) .vs. (y~x1). Similarly, the deviance chi-square statistic calculated for x2 (P=0.018) is NOT for (y~x1+x2+x3) .vs. (y~x1+x3) but for (y~x1) .vs. (y~x1+x2). Lastly, the deviance chi-square statistic for x3(P=0.064) is probably the most intuitive because it is for the comparison of (y~x1+x2+x3) .vs. (y~x1+x2), the result we would typically want to present for x3 in the full model. So how do you get the correct deviance chi-square statistics for x1 and x2 in the full model? There are a couple of ways of arriving at the same answer as I will demonstrate for the case of x1. Option#1: Reorder the full model so that x1 is the last term in the model formula --- fit2 - glm(y ~ x2 + x3 + x1, data=d, family=binomial(link=logit), na.action=na.omit) anova(fit2, test='Chisq') ... Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL99137.989 x217.30598130.683 0.007 x313.82197126.862 0.051 x116.21296120.650 0.013 --- Notice that the deviance chi-square statistics for all of the variables have changed, despite fit2 being identical in content to fit1. Just the order of the terms in the model formula have changed from fit1 to fit2. The deviance statistic for x1 is now the correct one for the full model, that is for the comparison (y~x1+x2+x3) .vs. (y~x2+x3). Option#2: Compare the full model to a reduced model that does not include x1. --- fit3 - update(fit1, . ~ . - x1) anova(fit1, fit3, test='Chisq') ... Model 1: y ~ x1 + x2 + x3 Model 2: y ~ x2 + x3 Resid. Df Resid. Dev Df Deviance P(|Chi|) 196120.650 297126.862 -1 -6.212 0.013 --- Fit3 is the same model as fit1 except that it is missing the x1 term. Therefore, any change in the deviance chi-square statistic is due to the deletion of x1 from full model. Notice that the difference in residual deviances between fit3 and fit1 (126.862 - 120.650 = 6.212) is the same the difference b/t x1 and x3 in option#1. Brant __ 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] Profile confidence intervals and LR chi-square test
I did mention dropterm (and drop1 can also be used). This is more efficient, simpler and less-error prone than setting up your own anova()'s (especially if you want to do LRTs for dropping several terms). On Tue, 14 Nov 2006, Inman, Brant A. M.D. wrote: Thank you to Prof Ripley and Henric Nilsson for their observation that I was using anova inappropriately for the question that I was trying to answer. Note that the Wald statistics and confidence interval were calculable in the previous email but that I prefered using the more accurate deviance statistics. I will demonstrate my error for the benefit of those new users of R (like me) that may not have appreciated how the anova function is working SEQUENTIALLY, and what SEQUENTIALLY actually means in this context. Since the anova function is a sequential test of the current model, only the statistic for the last term in the model formula is a true deviance chi-square statistic for (full model) .vs. (full model - term). For instance, using the data upon which this question was based, consider the following 2 models: -- fit0 - glm(y ~ 1, data=d, family=binomial(link=logit), na.action=na.omit) fit1 - update(fit0, . ~ . + x1 + x2 + x3) -- Here, fit0 is the null (intercept-only) model and fit1 is the full model (without interactions because interactions are not biologically plausible in this medical dataset). Now notice the result of the anova function for the full model: -- anova(fit1, test='Chisq') ... Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL99137.989 x118.26798129.721 0.004 x215.63997124.083 0.018 x313.43396120.650 0.064 --- It is incorrect to interpret the deviance chi-square test presented above for x1 (P=0.004) as the deviance chi-square statistic comparing (y~x1+x2+x3) .vs. (y~x2+x3) as the statistic calculated is for (y~1) .vs. (y~x1). Similarly, the deviance chi-square statistic calculated for x2 (P=0.018) is NOT for (y~x1+x2+x3) .vs. (y~x1+x3) but for (y~x1) .vs. (y~x1+x2). Lastly, the deviance chi-square statistic for x3(P=0.064) is probably the most intuitive because it is for the comparison of (y~x1+x2+x3) .vs. (y~x1+x2), the result we would typically want to present for x3 in the full model. So how do you get the correct deviance chi-square statistics for x1 and x2 in the full model? There are a couple of ways of arriving at the same answer as I will demonstrate for the case of x1. Option#1: Reorder the full model so that x1 is the last term in the model formula --- fit2 - glm(y ~ x2 + x3 + x1, data=d, family=binomial(link=logit), na.action=na.omit) anova(fit2, test='Chisq') ... Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL99137.989 x217.30598130.683 0.007 x313.82197126.862 0.051 x116.21296120.650 0.013 --- Notice that the deviance chi-square statistics for all of the variables have changed, despite fit2 being identical in content to fit1. Just the order of the terms in the model formula have changed from fit1 to fit2. The deviance statistic for x1 is now the correct one for the full model, that is for the comparison (y~x1+x2+x3) .vs. (y~x2+x3). Option#2: Compare the full model to a reduced model that does not include x1. --- fit3 - update(fit1, . ~ . - x1) anova(fit1, fit3, test='Chisq') ... Model 1: y ~ x1 + x2 + x3 Model 2: y ~ x2 + x3 Resid. Df Resid. Dev Df Deviance P(|Chi|) 196120.650 297126.862 -1 -6.212 0.013 --- Fit3 is the same model as fit1 except that it is missing the x1 term. Therefore, any change in the deviance chi-square statistic is due to the deletion of x1 from full model. Notice that the difference in residual deviances between fit3 and fit1 (126.862 - 120.650 = 6.212) is the same the difference b/t x1 and x3 in option#1. Brant -- 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] alphachannel on pdf-device
Dear R users, since R-2.4.0 I am not able any more to draw figures without transparency after drawing one figure with alphachannel set lower than 100%. For better unterstanding here a small example of my problem: --- pdf(paste(test_alpha_rgb.pdf,sep=), version=1.4) plot(1:8, 1:8, type=n, xlab=, ylab=) lines(c(1,8), c(1,8), type=l, col=lightblue, lwd=15) # polygon with alphachannel=64 (transparency 40%) polygon(c(5,2,2,5,5), c(2,2,5,5,2), col=rgb(255,192,203,64, max = 255), border=NA) text(4,2, transparency 40%) # rectangle with alphachannel=255 (no transparency) goldenrod1 - rgb(255,193,37,255, names=c(goldenrod1), max=255) rect(4,4,7,7, col=goldenrod1, border=goldenrod1) text(5,7, no transparency) dev.off() --- In this example (see pdf in attachment) after plotting a line without any transparency a polygon is drawn with alphachannel set to 40%. All following figures and even text is shown with transparency. The described behaviour seems to be the same on FreeBSD 7.0-CURRENT and on WindowsXP. Am I doing something wrong? Many thanks for any help, Rainer Hurling test_alpha_rgb.pdf Description: Adobe PDF document __ 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] Plot title with numeric variables
I am trying to create a plot title in R with substitution by a numeric variable (Figure number N) within the text which is bold and has a subcripted part as well. Here is what I have: title - expression(bold(paste(Figure , N, : Plot , C[max], versus CrCL))) plot(1, main=) # Simple plot for testing N - 5 mtext(title, line=3, font=2, cex=1.25) I have the bold part and the subscripted text worked out but how do I replace the text N in the title by its numeric value (5 in this example)? I tried all kinds of stuff with substitute, etc. but can't figure it out. The last 3 lines are actually from a function with title as argument. N is internal to the function and changes. Any help is much appreciated. Thanks. Rene -- View this message in context: http://www.nabble.com/Plot-title-with-numeric-variables-tf2631678.html#a7344545 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] Matrix-vector multiplication without loops
Ravi, Here is another version, somewhat similar to what Dimitris proposed but without using 'rep'. For large n, K 'rep' tries allocating two vectors, each of length n*(K+1)^2, which can be a problem. In this version 'outer' buys you some efficiency and compactness, but your looping version is faster. n - 1000 K - 1000 p - rep(0, n) cf - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) # original code system.time( { for (i in 0:K) for (j in 0:K) p - p + cf[i+1]* cf[j+1] * U[,i+j+1] p.1 - p } ) # 'vectorized' system.time( { ind - sapply(1:(K+1), seq, length = K+1) cc - outer(cf,cf) p.2 - apply(U, 1, FUN=function(u) sum(cc * u[ind])) } ) all.equal(p.1, p.2) rm(n,K,p,U,cf,cc,ind,p.1,p.2) -Christos Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 400 West Cummings Park Suite 5350 Woburn, MA 01801 Tel: 781-938-3830 www.nuverabio.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dimitris Rizopoulos Sent: Tuesday, November 14, 2006 11:20 AM To: Ravi Varadhan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Matrix-vector multiplication without loops I think you need something along these lines: ind - c(sapply(1:(K+1), seq, length = K + 1)) cf1 - rep(rep(coef, each = n), K + 1) cf2 - rep(rep(coef, each = n), each = K + 1) rowSums(cf1 * cf2 * U[, ind]) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Ravi Varadhan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, November 14, 2006 4:45 PM Subject: [R] Matrix-vector multiplication without loops Hi, I am trying to do the following computation: p - rep(0, n) coef - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) for (i in 0:K){ for (j in 0:K){ p - p + coef[i+1]* coef[j+1] * U[,i+j+1] } } I would appreciate any suggestions on how to perform this computation efficiently without the for loops? Thank you, 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 [[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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] RODBC and NULL values
Mark Wardle wrote: Dear all, I'm afraid I'm still having trouble with RODBC and NULL values on Mac OS ... snip limited to RODBC, and is not an ODBC driver problem? Any ideas? I'll be switching to RdbiPgSQL from now, but I thought it appropriate to flag this up as an unsolved problem. Hmmm.. there are several issues with RdbiPgSQL (including not doing as good a job at recognising factors for example - this requires manually checking data frames returned, and fixing data types with liberal use of as.factor() etc..), so if anyone has information on the best way to access PostgreSQL from R, then all advice appreciated! Apart from the NULL value problem, RODBC seems the best and most mature and does a great job of inferring data types. The RPGSQL website suggests it is abandoned in favour of Rdbi, Rdbi's website suggests it is abandoned in favour of DBI. This doesn't complete support postgresql as far as I can see, but they recommend the RdbiPgSQL package on bioconductor as above. Thanks, Mark -- Dr. Mark Wardle Clinical research fellow and Specialist Registrar in Neurology, C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK email: [EMAIL PROTECTED] [EMAIL PROTECTED] OpenPGP key: 66896A39 office: +44(0)2920743454 facsimile: +44(0)2920743798 mob: +44(0)7786196137 home: +44(0)2920216341 __ 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 check a R object's property
Hi, I am writing a generic function and need to check if an arg is a data frame or not. I could use is.null(dim(x)) to get what i want. But i want to know if there is a function which can tell me whether it is a list, a numeric vector, a data frame, a factor and so on. Can R do that? thanks. -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. Did you always know? No, I did not. But I believed... ---Matrix III __ 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-Help : Warning messages using plot(cox.zph)
Hi, I get a warning message when I plot cox.zph objects with the transform km and rank, but not with id and log with the same data set. Here's the command: example is a coxph object rk - cox.zph(example, transform='rank') rk plot(rk) and here's the warning message: Warning messages: 1: suppression des ex-aequos de 'x' in: approx(xx, xtime, seq(min(xx), max(xx), length = 17)[2 * (1:8)]) 2: suppression des ex-aequos de 'x' in: approx(xtime, xx, temp) However, no points are actually missing on my plots. Is anybody get an idea of why this happens only with km and rank transforms and what does this mean? Thank you, Kathy - Courriel expédié via https://courriel.uqtr.ca __ 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 check a R object's property
check class() but if all you want is to test whether it's a data.frame or not: is.data.frame() b On Nov 14, 2006, at 3:07 PM, Weiwei Shi wrote: Hi, I am writing a generic function and need to check if an arg is a data frame or not. I could use is.null(dim(x)) to get what i want. But i want to know if there is a function which can tell me whether it is a list, a numeric vector, a data frame, a factor and so on. Can R do that? thanks. -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. Did you always know? No, I did not. But I believed... ---Matrix III __ 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] Creating a table
Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df-data.frame(loc=c(A,B,A,A,A), year=as.numeric(c(1970,1970,1970,1976,1980))) and I want to create the following table without using loops: 1970-74 ; 1975-79 ; 1980-85; rowsum A 2 1 1 4 B 1 00 1 colsum 31 15 so that the frequencies of df$loc are shown in the table for different time intervals. Thanks in advance for any hint, Michael Graber __ 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] Matrix-vector multiplication without loops
In my case, I have n K so the loop solution is faster than the solutions proposed by Christos and Dimitris. In any case, I would like to thank Christos and Dimitris for their solutions. Best, 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: Christos Hatzis [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 2:49 PM To: 'Dimitris Rizopoulos'; 'Ravi Varadhan' Cc: r-help@stat.math.ethz.ch Subject: RE: [R] Matrix-vector multiplication without loops Ravi, Here is another version, somewhat similar to what Dimitris proposed but without using 'rep'. For large n, K 'rep' tries allocating two vectors, each of length n*(K+1)^2, which can be a problem. In this version 'outer' buys you some efficiency and compactness, but your looping version is faster. n - 1000 K - 1000 p - rep(0, n) cf - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) # original code system.time( { for (i in 0:K) for (j in 0:K) p - p + cf[i+1]* cf[j+1] * U[,i+j+1] p.1 - p } ) # 'vectorized' system.time( { ind - sapply(1:(K+1), seq, length = K+1) cc - outer(cf,cf) p.2 - apply(U, 1, FUN=function(u) sum(cc * u[ind])) } ) all.equal(p.1, p.2) rm(n,K,p,U,cf,cc,ind,p.1,p.2) -Christos Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 400 West Cummings Park Suite 5350 Woburn, MA 01801 Tel: 781-938-3830 www.nuverabio.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dimitris Rizopoulos Sent: Tuesday, November 14, 2006 11:20 AM To: Ravi Varadhan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Matrix-vector multiplication without loops I think you need something along these lines: ind - c(sapply(1:(K+1), seq, length = K + 1)) cf1 - rep(rep(coef, each = n), K + 1) cf2 - rep(rep(coef, each = n), each = K + 1) rowSums(cf1 * cf2 * U[, ind]) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Ravi Varadhan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, November 14, 2006 4:45 PM Subject: [R] Matrix-vector multiplication without loops Hi, I am trying to do the following computation: p - rep(0, n) coef - runif(K+1) U - matrix(runif(n*(2*K+1)), n, 2*K+1) for (i in 0:K){ for (j in 0:K){ p - p + coef[i+1]* coef[j+1] * U[,i+j+1] } } I would appreciate any suggestions on how to perform this computation efficiently without the for loops? Thank you, 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 [[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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] Plot title with numeric variables
The key thing is the function bquote(). E.g. N - 5 xxx - bquote(bold(Figure~.(N)~Plot~C[max]~versus CrCl)) plot(1:10,main=xxx) (Not sure about the ``bold'' business, but R doesn't object.) Or to take a simpler and clearer example: N - 5 plot(1:10,main=bquote(Figure~.(N)) 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.
Re: [R] how to check a R object's property
On Tue, 14 Nov 2006, Weiwei Shi wrote: Hi, I am writing a generic function and need to check if an arg is a data frame or not. ?is.data.frame I could use is.null(dim(x)) to get what i want. In which case you would fail. Arrays and many other objects have non-NULL dims. But i want to know if there is a function which can tell me whether it is a list, a numeric vector, a data frame, a factor and so on. Can R do that? Yes. ?typeof, ?class, ?str, ?inherits ... and please do study 'An Introduction to R' (belatedly). You do seem to be asking almost daily for people to read the documentation for you. Please try install.packages(fortunes); library(fortunes); fortune(WTFM) -- 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] Creating a table
addmargins(table(df)) On 14/11/06, Michael Graber [EMAIL PROTECTED] wrote: Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df-data.frame(loc=c(A,B,A,A,A), year=as.numeric(c(1970,1970,1970,1976,1980))) and I want to create the following table without using loops: 1970-74 ; 1975-79 ; 1980-85; rowsum A 2 1 1 4 B 1 00 1 colsum 31 15 so that the frequencies of df$loc are shown in the table for different time intervals. Thanks in advance for any hint, Michael Graber __ 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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] Creating a table
tb = table(df$loc, cut(df$year, seq(1970, 1985, by=5), right=F)) rs = rowSums(tb) tb = cbind(tb, rs) cs = colSums(tb) tb = rbind(tb, cs) cheers, b On Nov 14, 2006, at 3:20 PM, Michael Graber wrote: Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df-data.frame(loc=c(A,B,A,A,A), year=as.numeric(c(1970,1970,1970,1976,1980))) and I want to create the following table without using loops: 1970-74 ; 1975-79 ; 1980-85; rowsum A 2 1 1 4 B 1 00 1 colsum 31 15 so that the frequencies of df$loc are shown in the table for different time intervals. Thanks in advance for any hint, Michael Graber __ 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] Creating a table
Michael One solution: df-data.frame(loc=c(A,B,A,A,A), year=c(1970,1970,1970,1976,1980)) df[,3] - cut(df$year, c(1969.5,1974.5,1979.5,1984.5), c('1970-74','1975-79','1980-85')) with(df, addmargins(table(loc, V3))) Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Graber Sent: Wednesday, 15 November 2006 9:21 a.m. To: R-Mailingliste Subject: [R] Creating a table Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df-data.frame(loc=c(A,B,A,A,A), year=as.numeric(c(1970,1970,1970,1976,1980))) and I want to create the following table without using loops: 1970-74 ; 1975-79 ; 1980-85; rowsum A 2 1 1 4 B 1 00 1 colsum 31 15 so that the frequencies of df$loc are shown in the table for different time intervals. Thanks in advance for any hint, Michael Graber __ 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. __ The contents of this e-mail are privileged and/or confidenti...{{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.
[R] GESCHAEFTS-VORCHLAG
Sehr geehrter Geschaefts-Vorschlag! Sicher sind Sie verwundert, diese Nachricht von jemandem zu erhalten, den sie nicht personlich kennen. Der Grund weshalb ich mich an Sie wende ist das ich Ehret Olds bin, der erstgeborene Sohn von Martin Olds, einem der bekanntesten schwarzen Farmer in Zimbabwe. Er wurde vor kurzem im Laufe des Landstreites in meinem Land ermordet. Ich erhielt Ihre Adresse durch das Internet und habe mich entschieden mich an Sie zu wenden. Bevor mein Vater starb, nahm er mich mit nach Johannesburg um dort einen Betrag von 8,5 Millionen US$ (Acht Millionen funfhunderttausend US Dollar) bei einer privaten Sicherheitsfirma zu deponieren. Er hat die drohende Gefahr geahnt und daher diesen Betrag in einer Kassette dort hinterlegt, die er als normales Wertgut deklarierte um keinen Verdacht zu erwecken und ausserdem die Kosten fuer die Hinterlegung gering zu halten. Niemand weis also von dem Bargeld in dieser Kassette. Ursprunglich war dieser Betrag fuer neue Maschinen und Chemikalien für seine Farm gedacht, ausserdem wollte er neues Farmland in Schwerz erwerben und erschliesen. Das Landproblem entstand als der Präsident von Zimbabwe, Mr. Robert Mugabe, seine neue Landreform durchsetzte bei der nur die reichen weisen Farmer und einige wenige schwarze Farmer Vorteile verschafft wurden, fuer alle anderen war die Existenz nun bedroht. Daraus resultierten dann schlielich die Unruhen die sich ausbreiteten und denen viele Menschen zum Opfer fielen und ihr Leben lassen mussten. Leider ist mein Vater ebenfalls eines dieser Opfer das sein Leben verlor. Vor diesem Hintergrund bin ich mit der Familie unter lebensgefährlichen Umständen aus Zimbabwe nach Holland geflohen, hier haben wir politisches Asyl beantragt. Das in Südafrika zurückgelassene Geld wollen wir nun der Sicherheit wegen auf ein Konto hier übertragen. Das Gesetz in Holland verbietet es Menschen die politisches Asyl beantragt haben während dieses Verfahrens ein Konto zu eröffnen oder irgendwelche Transfers/Transaktionen die Über die hollandische Grenze hinausgehen abzuwickeln. Als der erstgeborene Sohn bin ich nun für meine ganze Familie veranwortlich und habe die Rolle meines Vaters als Bewacher und Beschitzer Übernommen. Nun stehe ich vor dem Problem dieses Geld ohne Wissen der afrikanischen Regierung hierher zu transferieren, ansonsten wurde man uns den gesamten Betrag enteignen, dieses Geld ist aber alles das uns noch geblieben ist. Die Südafrikanische Regierung unterstützt wohl die Regierung Zimbabwes, so dass auch dort nichts von meinem Vorhaben bekannt werden darf. Als Geschäftsmann suche ich nun nach einem Partner dem ich voll und ganz vertrauen kann, dem ich meine und auch die Zukunft meiner ganzen Familie anvertrauen kann. Ich möchte Sie wissen lassen, dass ein Plan völlig ohne Risiko ist, falls Sie mir und meiner Familie helfen wollen. Alles worum ich Sie bitte, ist eine Vereinbarung mit der hollandischen Niederlassung der Sicherheitsfirma zu treffen, das hinterlegte Wertgut auszuhändigen. Ich meinerseits habe bereits Anweisung gegeben die Kassette von Südafrika nach Holland zu senden. Vorher allerdings müssen noch einige wichtige Formalitäten erledigt werden, wie die Änderung des Begunstigten an diesem Wertgut. Weiterhin habe ich vor diese Geld nach Erhalt möglichst gut und gewinnbringend zu investieren. Ich möchte Ihnen zwei Vorschläge unterbreiten.Erstens biete ich Ihnen einen Teil der Gesamtsumme an, wenn Sie bereit wären, Ihr eigenes Konto für diese Transaktion Verfügung zu stellen.Oder aber Sie sind an einer Partnerschaft mit mir interessiert um diese Summe profitabel in Ihrem Land zu investieren.Egal welcher Vorschlag Ihnen mehr zusagt, zögern Sie nicht mir Ihre Entscheidung mitzuteilen. Fuer alle entstehenden Unkosten habe ich 5% des Gesamtbetrages ingeplant. Sollten Sie nicht an einer Partnerschaft mit Mir interessieren sein, biete ich Ihnen 25% des Betrages an und werde die verbleibenden 70% fuer meine Investitionen in Ihrem Land nutzen. Sie können mich jederzeit unter dieser e-Mail Adresse erreichen: ( [EMAIL PROTECTED] ) Ich bitte Sie jedoch um Ihre absolute Verschwiegenheit in dieser Angelegenheit Dritten gegenüber. Gott schutze Sie! Hochachtungsvoll, Ihr ergebener, Ehret Olds. __ 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] putting a column name on a zoo object
does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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] putting a column name on a zoo object
Mark, What's wrong with the following, head(sp.z) OpenHigh Low Close Volume Adj..Close. 2000-01-03 1469.25 1478.00 1438.36 1455.22 93180 1455.22 2000-01-04 1455.22 1455.22 1397.43 1399.42 100900 1399.42 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032 1402.11 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032 1403.45 2000-01-07 1403.45 1441.47 1400.73 1441.47 122520 1441.47 2000-01-10 1441.47 1464.36 1441.47 1457.60 106480 1457.60 colnames(sp.z) [1] OpenHighLow Close Volume [6] Adj..Close. colnames(sp.z)[1] = OPEN colnames(sp.z) [1] OPENHighLow Close Volume [6] Adj..Close. HTH. Horace W. Tso Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:21:33 PM does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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. __ 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] putting a column name on a zoo object
let me try colnames. I thought I tried that earlier and got an error but I've been wrong before. Thanks. -Original Message- From: Horace Tso [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 4:29 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: Re: [R] putting a column name on a zoo object Mark, What's wrong with the following, head(sp.z) OpenHigh Low Close Volume Adj..Close. 2000-01-03 1469.25 1478.00 1438.36 1455.22 93180 1455.22 2000-01-04 1455.22 1455.22 1397.43 1399.42 100900 1399.42 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032 1402.11 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032 1403.45 2000-01-07 1403.45 1441.47 1400.73 1441.47 122520 1441.47 2000-01-10 1441.47 1464.36 1441.47 1457.60 106480 1457.60 colnames(sp.z) [1] OpenHighLow Close Volume [6] Adj..Close. colnames(sp.z)[1] = OPEN colnames(sp.z) [1] OPENHighLow Close Volume [6] Adj..Close. HTH. Horace W. Tso Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:21:33 PM does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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. 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] Plot title with numeric variables
Thanks for your quick response. This works but the problem is that I can't define the title ahead before N is defined or changed. The idea is that the title is defined ahead, passed to a function that makes many plots, and N is incremented for each plot. One way to accomplish this would be to have the constant part of the title defined ahead: xxx - bquote(bold(Plot~C[max]~versus CrCl)) Bold is needed because the subscripted text max is too light (doesn't seem to follow font changes) but I could leave it out if needed. And then add this to the changing part at the time the plot is made (when the value of N is correct). The changing part is: ccc - bquote((Figure~.(N)) I just don't know how to concatenate both xxx and ccc to create the title. Thanks again, Rene -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 12:42 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Plot title with numeric variables The key thing is the function bquote(). E.g. N - 5 xxx - bquote(bold(Figure~.(N)~Plot~C[max]~versus CrCl)) plot(1:10,main=xxx) (Not sure about the ``bold'' business, but R doesn't object.) Or to take a simpler and clearer example: N - 5 plot(1:10,main=bquote(Figure~.(N)) 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.
Re: [R] putting a column name on a zoo object
I only have one column so when I try your suggestion, I get dsays, attempt to set colnames on object with less than two dimensions. It is of class zoo but I guess something changes during that addition that I am too much of a novice to understand. This is what a dput gives. There is no dim in the dput which is probably what the problem is but I don't know how to fix it. Thanks. structure(c(4.77126598671015, 4.7716359319335, 4.77176152623894, 4.77196709472722, 4.77218067995761, 4.77213077515643, 4.77200790109121, 4.77203963822312, 4.7719973218234, 4.771903278968, 4.77183227075241, 4.77182803831544, 4.77181216651724, 4.77182803831544, 4.77197193112401, 4.77198938729909, 4.77201612933324, 4.77202905929107, 4.7720184802471, 4.77188623275365, 4.77181745714463, 4.77187036187909, 4.77187036187909, 4.77187036187909, 4.77182803831544, 4.77182803831544, 4.77174338581391, 4.77179982161115, 4.77174338581391, 4.77182199194583, 4.77179417817475, 4.77174338581391, 4.77174338581391, 4.77179982161115, 4.77182803831544, 4.77182803831544, 4.77187036187909, 4.77191268365153, 4.7719338438661, 4.77191268365153, 4.77176690111649, 4.77188094249012, 4.77189857659306, 4.77212752040897, 4.77224143026734, 4.77240630536398), index = structure(c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220), class = c(POSIXt, POSIXct )), class = zoo, .Names = c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220)) -Original Message- From: Leeds, Mark (IED) Sent: Tuesday, November 14, 2006 4:39 PM To: 'Horace Tso'; r-help@stat.math.ethz.ch Subject: RE: [R] putting a column name on a zoo object let me try colnames. I thought I tried that earlier and got an error but I've been wrong before. Thanks. -Original Message- From: Horace Tso [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 4:29 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: Re: [R] putting a column name on a zoo object Mark, What's wrong with the following, head(sp.z) OpenHigh Low Close Volume Adj..Close. 2000-01-03 1469.25 1478.00 1438.36 1455.22 93180 1455.22 2000-01-04 1455.22 1455.22 1397.43 1399.42 100900 1399.42 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032 1402.11 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032 1403.45 2000-01-07 1403.45 1441.47 1400.73 1441.47 122520 1441.47 2000-01-10 1441.47 1464.36 1441.47 1457.60 106480 1457.60 colnames(sp.z) [1] OpenHighLow Close Volume [6] Adj..Close. colnames(sp.z)[1] = OPEN colnames(sp.z) [1] OPENHighLow Close Volume [6] Adj..Close. HTH. Horace W. Tso Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:21:33 PM does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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. 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] running R without X11
Laurence Darby wrote: Prof Brian Ripley wrote: On Tue, 14 Nov 2006, Laurence Darby wrote: Is there anyway to remove this dependency on X11? Please read the help page. R's png device uses X11 for its fonts. You need fonts from somewhere, and vanilla Unix systems don't come with any other sets. You can use ghostscript or libgdd or other resources for other graphics devices. I normally just use an Xvfb frame buffer (but, hint, it defaults to 12bit and you want a 24bit screen). Thanks for your prompt answer, although getting gs to work the way I want or setting up Xvfb, on top of learning R, is too many hoops to jump through, much more than reproducing a small R script I have in gnuplot. You can also use Simon Urbanek's GDD or Cairo packages, located on CRAN and on www.rosuda.org/R. They both create png's without an X server. Currently, there are issues with GDD: minimal truetype font support, an inability to draw lines thicker than lwd=1, and the worst is it's dependence on the neglected libgd graphics library, but apparently there's been some active development on it. Check www.libgd.org. I'm currently adding truetype font support and some antialiasing properties to the Cairo package, for the sole purpose of creating better graphics for the web. Cairo probably has a longer future as it depends on cairo (www.cairographics.org) which is used in the Firefox browser. 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] Plot title with numeric variables
cat doesn't work with bquoted arguments. At least not with the simple cat(xxx, ccc). Rene _ From: Jeffrey Robert Spies [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 1:58 PM To: Rene Braeckman Cc: r-help Subject: Re: [R] Plot title with numeric variables How about using the cat function to concatenate the constant string with the dynamic string and then bold the result of that? -- Jeff Spies http://www.nd.edu/~jspies/ http://www.nd.edu/~jspies/ On Nov 14, 2006, at 4:39 PM, Rene Braeckman wrote: Thanks for your quick response. This works but the problem is that I can't define the title ahead before N is defined or changed. The idea is that the title is defined ahead, passed to a function that makes many plots, and N is incremented for each plot. One way to accomplish this would be to have the constant part of the title defined ahead: xxx - bquote(bold(Plot~C[max]~versus CrCl)) Bold is needed because the subscripted text max is too light (doesn't seem to follow font changes) but I could leave it out if needed. And then add this to the changing part at the time the plot is made (when the value of N is correct). The changing part is: ccc - bquote((Figure~.(N)) I just don't know how to concatenate both xxx and ccc to create the title. Thanks again, Rene -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 12:42 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Plot title with numeric variables The key thing is the function bquote(). E.g. N - 5 xxx - bquote(bold(Figure~.(N)~Plot~C[max]~versus CrCl)) plot(1:10,main=xxx) (Not sure about the ``bold'' business, but R doesn't object.) Or to take a simpler and clearer example: N - 5 plot(1:10,main=bquote(Figure~.(N)) 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. [[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] gam() question
Hi everyone, I am fitting a bivariate smoothing model by using gam. But I got an error message like this: Error in eigen(hess1, symmetric = TRUE) : 0 x 0 matrix If anyone know how to figure it out, pleaselet me know. Thanks very much. [[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] Plot title with numeric variables
How about using the cat function to concatenate the constant string with the dynamic string and then bold the result of that? -- Jeff Spies http://www.nd.edu/~jspies/ On Nov 14, 2006, at 4:39 PM, Rene Braeckman wrote: Thanks for your quick response. This works but the problem is that I can't define the title ahead before N is defined or changed. The idea is that the title is defined ahead, passed to a function that makes many plots, and N is incremented for each plot. One way to accomplish this would be to have the constant part of the title defined ahead: xxx - bquote(bold(Plot~C[max]~versus CrCl)) Bold is needed because the subscripted text max is too light (doesn't seem to follow font changes) but I could leave it out if needed. And then add this to the changing part at the time the plot is made (when the value of N is correct). The changing part is: ccc - bquote((Figure~.(N)) I just don't know how to concatenate both xxx and ccc to create the title. Thanks again, Rene -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 12:42 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Plot title with numeric variables The key thing is the function bquote(). E.g. N - 5 xxx - bquote(bold(Figure~.(N)~Plot~C[max]~versus CrCl)) plot(1:10,main=xxx) (Not sure about the ``bold'' business, but R doesn't object.) Or to take a simpler and clearer example: N - 5 plot(1:10,main=bquote(Figure~.(N)) 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. [[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] gam() question
Hello, it's really difficult for anyone to make a constructive response based on your message. The problem could be in: 1) the function you fit (which one is it?, and which package?) 2) the arguments that you supplied (what did you tell it to do?) 3) the data that you gave it (what are they?) Try the following: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Good luck! Andrew On Tue, Nov 14, 2006 at 04:40:09PM -0500, seeTigers wrote: Hi everyone, I am fitting a bivariate smoothing model by using gam. But I got an error message like this: Error in eigen(hess1, symmetric = TRUE) : 0 x 0 matrix If anyone know how to figure it out, pleaselet me know. Thanks very much. [[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. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ 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] the secret (?) language of lists
A couple days ago, Mark Leeds asked about a solution that would basically stagger two lists, a and b, to return a list in the form of a[1], b[1], a[2], b[2], a[3] In particular, the summary of his question was in reference to lists defined by x - 5 tempin - seq(1,1411, by=30) a - tempin b - tempin + x I offered the following function everyOther - function(tempin, x){ tempout - array(data=NA, dim=length(tempin)*2) tempout[seq(1,length(tempin)*2, by=2)]-tempin tempout[seq(2,length(tempin)*2, by=2)]-tempin+x tempout } which did what it was supposed to, and Gavin Simpson offered a similar function. Peter Dalgaard, however, supplied a much more elegant solution: c(rbind(tempin,tempin+5)) or rep(tempin, each=2) + c(0,5) I thought I'd bring this up as a new topic because it's really no longer related to what Mark first asked, but is there a way, perhaps from the documentation, that a user would know that c() and lists in general behave as they do in these two lines? Or would we just need to dig into the code? I am reminded of quote by Byron Ellis: Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. Not exactly the point, but close. Thanks! Jeff Spies http://www.nd.edu/~jspies/ [[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] Fitting a survival curve
Richard Pitman richard.pitman3 at btopenworld.com writes: I am new to R and am trying to fit a survival curve with a weibull hazard function to a set of data giving the probability of survival to age x, given the year of birth, in the form: Probability of survival: Birth year 19801981... 2003 .2 0.900.89... 0.87 1 0.800.81... 0.79 age 2 0.750.74... 0.73 3 0.700.69... 0.68 5 0.500.49... 0.43 10 0.300.31... 0.26 I would like to be able to fit a curve to each birth cohort, extrapolate the curve a few years and be able to create a plot of the survival curves. You don't have enough data for a standard survival analysis, which is based on individual-level survival times. (You don't even know the total cohort size, which you would need to know to fit a binomial model.) However, you can compute the _expected_ probabilities of survival to age a using dweibull(a) [or, since your categories are fairly coarse, pweibull(a2)-pweibull(a1)]. As a starting point, you could try a least-squares fit through the data -- again, this is not quite right, but in the absence of information about sample size it's a little hard to know how to weight the different points. Hope that helps. Ben Bolker __ 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] Install problem(s)
I am trying to install R onto an Altix system running SuSE Enterprise Linux 9 SP3 with SGI ProPack 4 SP3. I end up with this error no matter what I try. Any suggestions on how to proceed would be appreciated! - gcc -shared -L/opt/local/lib -o methods.so do_substitute_direct.o init.o methods_list_dispatch.o slot.o class_support.o tests.o ../../../../library/methods/libs/methods.so is unchanged make[5]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods/src' make[4]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods/src' make[4]: Entering directory `/usr/local/src/R-2.4.0/src/library/methods' dumping R code in package 'methods' (null)Saving namespace image ... *** caught (null) *** address (nil), cause '(null)' Traceback: 0: (null) 0: (null) 0: (null) 0: (null)(null)(null)(null) 0: (null) 0: (null) aborting ... make[4]: *** [../../../library/methods/R/methods.rdb] Error 139 make[4]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods' make[3]: *** [all] Error 2 make[3]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods' make[2]: *** [R] Error 1 make[2]: Leaving directory `/usr/local/src/R-2.4.0/src/library' make[1]: *** [R] Error 1 make[1]: Leaving directory `/usr/local/src/R-2.4.0/src' make: *** [R] Error 1 __ 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] putting a column name on a zoo object
Mark, it's not the most elegant solution but here it is, I have a zoo with a vector of numeric values, head(spc.z) 2000-01-03 2000-01-04 2000-01-05 2000-01-06 2000-01-07 2000-01-10 1455.221399.421402.111403.451441.471457.60 class(spc.z) [1] zoo Now I want to give it a name, z = zoo(data.frame(mydata=coredata(spc.z)), index(spc.z)) head(z) mydata 2000-01-03 1455.22 2000-01-04 1399.42 2000-01-05 1402.11 2000-01-06 1403.45 2000-01-07 1441.47 2000-01-10 1457.60 HTH H. Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:49:24 PM I only have one column so when I try your suggestion, I get dsays, attempt to set colnames on object with less than two dimensions. It is of class zoo but I guess something changes during that addition that I am too much of a novice to understand. This is what a dput gives. There is no dim in the dput which is probably what the problem is but I don't know how to fix it. Thanks. structure(c(4.77126598671015, 4.7716359319335, 4.77176152623894, 4.77196709472722, 4.77218067995761, 4.77213077515643, 4.77200790109121, 4.77203963822312, 4.7719973218234, 4.771903278968, 4.77183227075241, 4.77182803831544, 4.77181216651724, 4.77182803831544, 4.77197193112401, 4.77198938729909, 4.77201612933324, 4.77202905929107, 4.7720184802471, 4.77188623275365, 4.77181745714463, 4.77187036187909, 4.77187036187909, 4.77187036187909, 4.77182803831544, 4.77182803831544, 4.77174338581391, 4.77179982161115, 4.77174338581391, 4.77182199194583, 4.77179417817475, 4.77174338581391, 4.77174338581391, 4.77179982161115, 4.77182803831544, 4.77182803831544, 4.77187036187909, 4.77191268365153, 4.7719338438661, 4.77191268365153, 4.77176690111649, 4.77188094249012, 4.77189857659306, 4.77212752040897, 4.77224143026734, 4.77240630536398), index = structure(c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220), class = c(POSIXt, POSIXct )), class = zoo, .Names = c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220)) -Original Message- From: Leeds, Mark (IED) Sent: Tuesday, November 14, 2006 4:39 PM To: 'Horace Tso'; r-help@stat.math.ethz.ch Subject: RE: [R] putting a column name on a zoo object let me try colnames. I thought I tried that earlier and got an error but I've been wrong before. Thanks. -Original Message- From: Horace Tso [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 4:29 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: Re: [R] putting a column name on a zoo object Mark, What's wrong with the following, head(sp.z) OpenHigh Low Close Volume Adj..Close. 2000-01-03 1469.25 1478.00 1438.36 1455.22 93180 1455.22 2000-01-04 1455.22 1455.22 1397.43 1399.42 100900 1399.42 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032 1402.11 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032 1403.45 2000-01-07 1403.45 1441.47 1400.73 1441.47 122520 1441.47 2000-01-10 1441.47 1464.36 1441.47 1457.60 106480 1457.60 colnames(sp.z) [1] OpenHighLow Close Volume [6] Adj..Close. colnames(sp.z)[1] = OPEN colnames(sp.z) [1] OPENHighLow Close Volume [6] Adj..Close. HTH. Horace W. Tso Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:21:33 PM does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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
[R] not sure if this intended behavior in column referencing
I made smaller zoo object with one column with the structure below smooththirtylogbidask-structure(c(4.77126598671015, 4.77127449545028, 4.77128569715842, 4.77129917), index = structure(c(1144022520, 1144022580, 1144022640, 1144022700), class = c(POSIXt, POSIXct)), class = zoo) And then I printed it out 3 different ways as below. print(smooththirtylogbidask[,]) print(smooththirtylogbidask[,logbidask]) print(smooththirtylogbidask[,xxx]) All of them worked in that they printed out the EXACT same correct thing which tells me that the column reference you put in is ignored when the object is just one column. I am unsure if this intended general R behavior, intended general zoo behavior or just unintended behavior but I figured I would send this info out. 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.
[R] Next useR conference date/location
Are there any tentative plans for the next useR conference? I ask because I will soon need to develop an expense budget for 2007 and wondered if the conference is switching to an annual meeting or will continue every two years. Thanks for any information K Wright __ 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] saving (and loading) environment to/from a connection?
Hi, I apologize if this is an FAQ but I could not find references to it anywhere. I am trying to send the entire environment from one R session to another (on a remote machine) using socketConnections. However, I cannot get around this error: On host machine: con1=socketConnection(port=6011,server=T,open=w+b,blocking=T) save(list=ls(),file=con1) On client machine: con2=socketConnection(localhost,port=6011,open=r+b,blocking=T) load(con2) Error in gzcon(con, level, allowNonCompressed) : can only use read- or write- binary connections I seem to get this error even if I use the compress=F option in save(). Also, it doesnt matter if I use r+b or rb (and w+b vs. wb), or whether I use blocking or not. I am able to see that the data is getting sent, as when I use readBin(con2...). Does anyone know how to do this? thanks very much. -David __ 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] names of arguments in function for optimize
Dear All, I noticed that optimize in R 2.4.0 on Windows XP does not seem to work if I use m as an argument in my function for example: optimize(function(x,m) x^m,interval=c(0,1),m=2) Error in f(arg, ...) : argument m is missing, with no default But! If I change the argument to a then it works. optimize(function(x,a) x^a,interval=c(0,1),a=2) $minimum [1] 6.610696e-05 $objective [1] 4.37013e-09 Why? Steve. [[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] the secret (?) language of lists
Jeffrey Robert Spies [EMAIL PROTECTED] writes: A couple days ago, Mark Leeds asked about a solution that would basically stagger two lists, a and b, to return a list in the form of a[1], b[1], a[2], b[2], a[3] In particular, the summary of his question was in reference to lists defined by x - 5 tempin - seq(1,1411, by=30) a - tempin b - tempin + x I offered the following function everyOther - function(tempin, x){ tempout - array(data=NA, dim=length(tempin)*2) tempout[seq(1,length(tempin)*2, by=2)]-tempin tempout[seq(2,length(tempin)*2, by=2)]-tempin+x tempout } which did what it was supposed to, and Gavin Simpson offered a similar function. Peter Dalgaard, however, supplied a much more elegant solution: c(rbind(tempin,tempin+5)) or rep(tempin, each=2) + c(0,5) I thought I'd bring this up as a new topic because it's really no longer related to what Mark first asked, but is there a way, perhaps from the documentation, that a user would know that c() and lists in general behave as they do in these two lines? Or would we just need to dig into the code? (What lists? I see only vectors. Lists in R is a different kind of object.) There are a few basic principles in play here, once you know them, the rest follows; I'm not sure exactly where they are documented, but I'd guess at Venables Ripley's books (MASS, S Programming) at least, the Blue Book on S, and possibly others. The first suggestion requires that you know or now about the following - matrices are vectors with dim attibutes, stored column-major — binding rows into matrices with rbind() - c() removes attributes The second one requires - rep function, and its each= - vector recycling in arithmetic I am reminded of quote by Byron Ellis: Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. Not exactly the point, but close. Thanks! Jeff Spies http://www.nd.edu/~jspies/ [[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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] names of arguments in function for optimize
On 11/14/2006 6:00 PM, Steve Su wrote: Dear All, I noticed that optimize in R 2.4.0 on Windows XP does not seem to work if I use m as an argument in my function for example: optimize(function(x,m) x^m,interval=c(0,1),m=2) Error in f(arg, ...) : argument m is missing, with no default Take a look at the header for optimize: optimize function (f, interval, lower = min(interval), upper = max(interval), maximum = FALSE, tol = .Machine$double.eps^0.25, ...) Unfortunately, the ... comes after the other arguments, so partial name matching will be attempted. By saying m=2 you've set the maximum arg to 2. You can avoid this by specifying maximum explicitly, e.g. optimize(function(x, m) x^m, interval=c(0,1), maximum=FALSE, m=2) $minimum [1] 6.610696e-05 $objective [1] 4.37013e-09 Duncan Murdoch But! If I change the argument to a then it works. optimize(function(x,a) x^a,interval=c(0,1),a=2) $minimum [1] 6.610696e-05 $objective [1] 4.37013e-09 Why? Steve. [[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] Install problem(s)
Steve Greenfield [EMAIL PROTECTED] writes: I am trying to install R onto an Altix system running SuSE Enterprise Linux 9 SP3 with SGI ProPack 4 SP3. I end up with this error no matter what I try. Any suggestions on how to proceed would be appreciated! Doesn't look nice. Question/ideas: What is you compiler toolchain? (Versions of C compiler, Fortran compiler, etc.) Altix'en appear to be Itanium systems; if so, then there's not a lot of experience to go around. Are you doing a clean build? It is usually a good idea to build in a separate build directory, so that you don't get sources and compiled files mixed up. You could check out R-2.4.0-patched. One or two potential buffer overruns were caught in 2.4.0 and they might be important on Itanium. - gcc -shared -L/opt/local/lib -o methods.so do_substitute_direct.o init.o methods_list_dispatch.o slot.o class_support.o tests.o ../../../../library/methods/libs/methods.so is unchanged make[5]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods/src' make[4]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods/src' make[4]: Entering directory `/usr/local/src/R-2.4.0/src/library/methods' dumping R code in package 'methods' (null)Saving namespace image ... *** caught (null) *** address (nil), cause '(null)' Traceback: 0: (null) 0: (null) 0: (null) 0: (null)(null)(null)(null) 0: (null) 0: (null) aborting ... make[4]: *** [../../../library/methods/R/methods.rdb] Error 139 make[4]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods' make[3]: *** [all] Error 2 make[3]: Leaving directory `/usr/local/src/R-2.4.0/src/library/methods' make[2]: *** [R] Error 1 make[2]: Leaving directory `/usr/local/src/R-2.4.0/src/library' make[1]: *** [R] Error 1 make[1]: Leaving directory `/usr/local/src/R-2.4.0/src' make: *** [R] Error 1 __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] I think a simple question
A couple of possibilities: sort( c(tempin, tempin+5) ) Or c( rbind(tempin, tempin+5) ) HTH, -- 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 Leeds, Mark (IED) Sent: Sunday, November 12, 2006 3:20 PM To: r-help@stat.math.ethz.ch Subject: [R] I think a simple question I have index ( of a vector ) values of say tempin-c(1 31 61 91 121 all the way upto 1411) What I want is a function that takes in a number say, x = 5, and gives me an new vector of tempout-1 6 31 36 91 96 121 126 .. 1411 1416 This can't be so hard but I can't get it and I've honestly tried. Obviously, tempin + 5 gives me the missing values but I don't know how to interwine them in the order above. Thanks for any help you can provide. mark 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. __ 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] __ 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] lpSolve and mixed signs
Hi R People: If you have a linear programming problem in which some of the constraints have the =, some have = and some have =, all in the same problem, should the solver work? I'm having trouble with that. Any help much appreciated! Sincerely, Erin Hodgess mailto: [EMAIL PROTECTED] whoops! mailto: [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] the secret (?) language of lists
Peter Dalgaard wrote: There are a few basic principles in play here, once you know them, the rest follows; I'm not sure exactly where they are documented, but I'd guess at Venables Ripley's books (MASS, S Programming) at least, the Blue Book on S, and possibly others. The first suggestion requires that you know or now about the following - matrices are vectors with dim attibutes, stored column-major ** This is clearly documented in AN Introduction to R binding rows into matrices with rbind() ** Documented in rbind's Help file. - c() removes attributes ** Documented in c()'s Help file The second one requires - rep function, and its each= ** Documented in rep's Help file - vector recycling in arithmetic ** Documented in Introduction to R and many Help files So, in fact, one does not need to go so far as MASS or S Programming -- or heaven forfend! -- the Blue Book. Indeed I learned about all of this by just reading the basic stuff before I even knew about these other (excellent and valuable, I grant) resources. Of course, cleverness in using R's well-documented capabilities is never guaranteed, but it is important to recognize that one need not hunt for the docs: they're where they should be. Which, I regret to say, leads me to echo Brian Ripley's pungent plea: install.packages(fortunes); library(fortunes); fortune(WTFM) Cheers, Bert Gunter I am reminded of quote by Byron Ellis: Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. Not exactly the point, but close. Thanks! Jeff Spies http://www.nd.edu/~jspies/ [[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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] putting a column name on a zoo object
First, read the last line of every message to r-help. The code below is not self contained nor reproducible. You can only put a column name on a zoo object that has columns! That means its data portion must be an nx1 matrix, not a vector. On 11/14/06, Leeds, Mark (IED) [EMAIL PROTECTED] wrote: does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object. 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. __ 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] putting a column name on a zoo object
Unfortunately that's wrong. Look at ?zoo . The first argument must be a numeric vector, matrix or factor. A data frame is not allowed. On 11/14/06, Horace Tso [EMAIL PROTECTED] wrote: Mark, it's not the most elegant solution but here it is, I have a zoo with a vector of numeric values, head(spc.z) 2000-01-03 2000-01-04 2000-01-05 2000-01-06 2000-01-07 2000-01-10 1455.221399.421402.111403.451441.471457.60 class(spc.z) [1] zoo Now I want to give it a name, z = zoo(data.frame(mydata=coredata(spc.z)), index(spc.z)) head(z) mydata 2000-01-03 1455.22 2000-01-04 1399.42 2000-01-05 1402.11 2000-01-06 1403.45 2000-01-07 1441.47 2000-01-10 1457.60 HTH H. Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:49:24 PM I only have one column so when I try your suggestion, I get dsays, attempt to set colnames on object with less than two dimensions. It is of class zoo but I guess something changes during that addition that I am too much of a novice to understand. This is what a dput gives. There is no dim in the dput which is probably what the problem is but I don't know how to fix it. Thanks. structure(c(4.77126598671015, 4.7716359319335, 4.77176152623894, 4.77196709472722, 4.77218067995761, 4.77213077515643, 4.77200790109121, 4.77203963822312, 4.7719973218234, 4.771903278968, 4.77183227075241, 4.77182803831544, 4.77181216651724, 4.77182803831544, 4.77197193112401, 4.77198938729909, 4.77201612933324, 4.77202905929107, 4.7720184802471, 4.77188623275365, 4.77181745714463, 4.77187036187909, 4.77187036187909, 4.77187036187909, 4.77182803831544, 4.77182803831544, 4.77174338581391, 4.77179982161115, 4.77174338581391, 4.77182199194583, 4.77179417817475, 4.77174338581391, 4.77174338581391, 4.77179982161115, 4.77182803831544, 4.77182803831544, 4.77187036187909, 4.77191268365153, 4.7719338438661, 4.77191268365153, 4.77176690111649, 4.77188094249012, 4.77189857659306, 4.77212752040897, 4.77224143026734, 4.77240630536398), index = structure(c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220), class = c(POSIXt, POSIXct )), class = zoo, .Names = c(1144022520, 1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 1144025100, 1144025160, 1144025220)) -Original Message- From: Leeds, Mark (IED) Sent: Tuesday, November 14, 2006 4:39 PM To: 'Horace Tso'; r-help@stat.math.ethz.ch Subject: RE: [R] putting a column name on a zoo object let me try colnames. I thought I tried that earlier and got an error but I've been wrong before. Thanks. -Original Message- From: Horace Tso [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 4:29 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: Re: [R] putting a column name on a zoo object Mark, What's wrong with the following, head(sp.z) OpenHigh Low Close Volume Adj..Close. 2000-01-03 1469.25 1478.00 1438.36 1455.22 93180 1455.22 2000-01-04 1455.22 1455.22 1397.43 1399.42 100900 1399.42 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032 1402.11 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032 1403.45 2000-01-07 1403.45 1441.47 1400.73 1441.47 122520 1441.47 2000-01-10 1441.47 1464.36 1441.47 1457.60 106480 1457.60 colnames(sp.z) [1] OpenHighLow Close Volume [6] Adj..Close. colnames(sp.z)[1] = OPEN colnames(sp.z) [1] OPENHighLow Close Volume [6] Adj..Close. HTH. Horace W. Tso Leeds, Mark (IED) [EMAIL PROTECTED] 11/14/2006 1:21:33 PM does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask-log((aggfxdata[,bid] + aggfxdata[,ask])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object.
Re: [R] the secret (?) language of lists
Thanks for the responses; and Gunter, I apologize if you feel you WTFM again in responding. The two issues that I originally had in understanding why the operations behaved as they did were in (1) c() reducing an rbind the way it did, and (2) vector recycling, as Peter mentioned. Issue (1) I'm hard pressed to find in any documentation that this is the way c would behave in this situation and would appreciate a pointer if it does exist in the basic stuff. Issue (2) is in deed in the intro; I was unfamiliar with the term recycling. I've been following the list for a while and these seem like things that those of us less familiar with vector-based programming, even having RTFM, might not immediately think of when it comes time to implementing them. Although, (as you mentioned, Gunter) R is very well documented overall, this is where some of Peter's references might be ideal. Thanks again, Jeff. On Nov 14, 2006, at 6:43 PM, Berton Gunter wrote: Peter Dalgaard wrote: There are a few basic principles in play here, once you know them, the rest follows; I'm not sure exactly where they are documented, but I'd guess at Venables Ripley's books (MASS, S Programming) at least, the Blue Book on S, and possibly others. The first suggestion requires that you know or now about the following - matrices are vectors with dim attibutes, stored column-major ** This is clearly documented in AN Introduction to R — binding rows into matrices with rbind() ** Documented in rbind's Help file. - c() removes attributes ** Documented in c()'s Help file The second one requires - rep function, and its each= ** Documented in rep's Help file - vector recycling in arithmetic ** Documented in Introduction to R and many Help files So, in fact, one does not need to go so far as MASS or S Programming -- or heaven forfend! -- the Blue Book. Indeed I learned about all of this by just reading the basic stuff before I even knew about these other (excellent and valuable, I grant) resources. Of course, cleverness in using R's well-documented capabilities is never guaranteed, but it is important to recognize that one need not hunt for the docs: they're where they should be. Which, I regret to say, leads me to echo Brian Ripley's pungent plea: install.packages(fortunes); library(fortunes); fortune(WTFM) Cheers, Bert Gunter I am reminded of quote by Byron Ellis: Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. Not exactly the point, but close. Thanks! Jeff Spies http://www.nd.edu/~jspies/ [[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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] not sure if this intended behavior in column referencing
Please make your examples minimal. That includes not using huge variable names that make it harder to work with. This is not a zoo object with one column. Its is a zoo object based on a vector. zoo(matrix(1:3, 3, 1)) is not the same as zoo(1:3) The former has one column but the latter does not have two dimensions therefore the idea of columns is meaningless. On 11/14/06, Leeds, Mark (IED) [EMAIL PROTECTED] wrote: I made smaller zoo object with one column with the structure below smooththirtylogbidask-structure(c(4.77126598671015, 4.77127449545028, 4.77128569715842, 4.77129917), index = structure(c(1144022520, 1144022580, 1144022640, 1144022700), class = c(POSIXt, POSIXct)), class = zoo) And then I printed it out 3 different ways as below. print(smooththirtylogbidask[,]) print(smooththirtylogbidask[,logbidask]) print(smooththirtylogbidask[,xxx]) All of them worked in that they printed out the EXACT same correct thing which tells me that the column reference you put in is ignored when the object is just one column. I am unsure if this intended general R behavior, intended general zoo behavior or just unintended behavior but I figured I would send this info out. 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. __ 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] the secret (?) language of lists
Berton Gunter wrote: - c() removes attributes ** Documented in c()'s Help file ***REALLY*** ??? Where? The only use of the word ``attribute'' in the help file is in ``See Also: 'unlist' and 'as.vector' to produce attribute-free vectors.'' Unless you already knew the fact that when m is a matrix c(m) gives a vector strung out in column order, you'd be very unlikely to discern that fact from the help file for c(). The only hint is that the output is described as being a vector. This is not exactly spoon-feeding the user. (Especially in view of the fact that a matrix ***is*** a vector --- with a dim attribute. Or so you keep telling us.) The help file talks about catenation (which is the essential role of c()) and expounds at length about the type of the result. The user is going to think in terms of c(v1,v2,v3), usw, where v1, v2 and v3 are ``genuine'' vectors''; it would never occur to him or her to apply c() to a matrix. There is no way on God's green earth that even the most diligent of neophytes is going to work out that c() has the effect on matrices that it does. EVEN IF the poor neophyte is so sophisticated as to have absorbed the idea that a matrix is a vector with a dim attribute. Which is perhaps a neat trick in designing data structures but is not, to put it mildly, intuitive. All too often it is useful to RTFM only if you already know the answer to your question. 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.
Re: [R] Plot title with numeric variables
This works for the original posted question: n-5 title - bquote(bold(paste(Figure , .(n), : Plot , C[max], versus CrCl))) plot(1, main=title) However, my problem is that I want to define the text before the value of n is known. The idea is that the title is defined ahead, passed to a function that makes many plots, and n is incremented for each plot. One way to accomplish this would be to have the constant part of the title defined ahead: fff - bquote(paste(Plot , C[max], versus CrCl)) Unfortunanely, I need to use bquote() or expression() in order to get the subscript correctly (subscript in the wordprocessing sense = text placed a little bit lower than normal). And then add to this the changing part at the time the plot is made (when the value of n is correct). The changing part is: ccc - bquote(paste(Figure , .(n), :)) Unfortunatley, I need to use bquote() or substitute() here to replace n with it's numeric value. This can actually be done simplier: paste(Figure, n, :) I just don't know how to concatenate both fff and ccc to create the title. I am wondering whether it is possible to construct variables or strings that contain the text plus the special charaters for subscript (square brackets) and the code for replacement of n by its numeric value, and then evaluate the combination as part of a substitute() function. As a try that does not work: fff - expression(paste(Plot ,C[max], versus CrCl)) # Need expression() for subscript text n-5 ccc - bquote(paste(Figure , .(n), :)) # Need bquote() for replacement of n; can be done with substitute() also, or simple: paste(Figure, n, :) title - paste(fff, ccc) # Does not work; produces strange results in plot title # plot(1, main=title) LARGER PEROBLEM: My larger problem is to construct a number of plots in sets with the same title per set (fixed part per set) but with the title number incremented with 1 starting with 1 (variable part). I wanted to define the fixed part of the title in the main loop but have the figure counter rolling in a function just before each plot is constructed at which time the figure number is known. Very ackward, but this works as the main loop: numSetsOfPlots - 1:2 numPlotsPerSet - 1:3 n - 0 for (setNo in numSetsOfPlots) { for (plotInSetNo in numPlotsPerSet) { n - n + 1 if (setNo == 1) myTitle - bquote(paste(Figure , .(n), : , C[max])) if (setNo == 2) myTitle - bquote(paste(Figure , .(n), : , AUC)) plot(1, main=myTitle) # Will be a call to a more complex plot function readline('Press Enter to proceed...') } } At this point, I can NOT separate a Figure counter from the fixed part of the title. Both have to be combined in the same main loop. The need for the subscript for which a PlotMath function is needed causes this problem. -- Rene Braeckman, PhD (RMan54) Irvine, CA RMan54 wrote: I am trying to create a plot title in R with substitution by a numeric variable (Figure number N) within the text which is bold and has a subcripted part as well. Here is what I have: title - expression(bold(paste(Figure , N, : Plot , C[max], versus CrCL))) plot(1, main=) # Simple plot for testing N - 5 mtext(title, line=3, font=2, cex=1.25) I have the bold part and the subscripted text worked out but how do I replace the text N in the title by its numeric value (5 in this example)? I tried all kinds of stuff with substitute, etc. but can't figure it out. The last 3 lines are actually from a function with title as argument. N is internal to the function and changes. Any help is much appreciated. Thanks. Rene -- View this message in context: http://www.nabble.com/Plot-title-with-numeric-variables-tf2631678.html#a7350682 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.
[R] splineDesign and not-a-knot conditions
Hi, I would like to fit an (interpolating) spline to data where the derivatives at the endpoints of the interval are nonzero, thus the natural spline endpoint-specification does not make sense. Books (de Boor, etc) suggest that in this case I use not-a-knot splines. I know what not-a-knot splines are (so if I were solving for the coefficients directly I knew how to do this), but I don't know how to sensibly enforce this restriction on the B-spline basis. I would appreciate any advice, references or example code. Thanks, Tamas __ 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 compute p-value?
Hi all, I just want to understand how R computes p-value in a simple linear regression model? The reason is that in Matlab in the function which evaluate standard errors for multivariate normal regression, it just provide estimates and standard errors, without giving out p-value, It computes t-statistics as follows: abs(beta_hat/std_beta_hat) how to go further to get p-value? Thanks [[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] how to create this design matrix?
Hi all, I have a multiple-linear regression problem. There are 13 columns of data, the whole data matrix is: n x 13, where n is the number of samples. Now I want to regress EACH of the first 12 columns onto the 13th column, with 2-parameter linear model y_i = b0 + b1 * x_i, where i goes from 1 to n, and b0 is the intercept. How do I create a design matrix to do the 12-column regression collectively all at once using multiple linear regressions? Thanks a lot [[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] the secret (?) language of lists
Please, these are NOT lists. They are vectors: the difference should be clear even from 'An Introduction to R'. What Peter's first solution does is to create a matrix and then read it out in the default column-major order. This is again all discussed in 'An Introduction to R'. Using c() in this way is often frowned on: as.vector() is clearer. On Tue, 14 Nov 2006, Jeffrey Robert Spies wrote: A couple days ago, Mark Leeds asked about a solution that would basically stagger two lists, a and b, to return a list in the form of a[1], b[1], a[2], b[2], a[3] In particular, the summary of his question was in reference to lists defined by x - 5 tempin - seq(1,1411, by=30) a - tempin b - tempin + x I offered the following function everyOther - function(tempin, x){ tempout - array(data=NA, dim=length(tempin)*2) tempout[seq(1,length(tempin)*2, by=2)]-tempin tempout[seq(2,length(tempin)*2, by=2)]-tempin+x tempout } which did what it was supposed to, and Gavin Simpson offered a similar function. Peter Dalgaard, however, supplied a much more elegant solution: c(rbind(tempin,tempin+5)) or rep(tempin, each=2) + c(0,5) I thought I'd bring this up as a new topic because it's really no longer related to what Mark first asked, but is there a way, perhaps from the documentation, that a user would know that c() and lists in general behave as they do in these two lines? Or would we just need to dig into the code? I am reminded of quote by Byron Ellis: Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. Not exactly the point, but close. Thanks! Jeff Spies http://www.nd.edu/~jspies/ [[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.