[R] R equivalent of linux cut, paste, and grep ?
Hi, What functions should I use in order to perform the following steps: 1) Load a particular column (e.g., column 5) from a csv file 2) Append the column 5 to another csv file 3) select those rows that match specific keywords in column 5 [[alternative HTML version deleted]] __ R-help@r-project.org 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] shaded area graph and extra plot
R-help, I'm using the code below to plot a shaded area graph. At the same time I want to plot a second series on the y-axis (from par(new=T) on) but as the two series have different x-axis range (first 1994:2007 and second 1996:2007) the corresponding x's do not match. How can this be sorted out? Thanks in advance # plot.new() plot.window(xlim=c(1993,2008), xaxs=i, ylim=c(0,400), yaxs=i) x=1994:2007 xx = c(1994, x, 2007) yy1 = c(0, indexSp[,Xhat5Sp]+indexSp[,seA], 0 ) yy2 = c(0, indexSp[,Xhat5Sp]-indexSp[,seA], 0 ) polygon(xx, yy1, col=grey, lty=0) polygon(xx, yy2, col=white, lty=0) lines(x, indexSp[,Xhat5Sp], type=l) axis(1) axis(2) par(new=T) plot(1996:2007, c(0,0,indexSu[,Xhat5Su]), type=p, col=2, lwd=2, cex=1,ann=T,axes=F) axis(4) # __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R equivalent of linux cut, paste, and grep ?
Hi, If you are on a linux system, you can use these linux commands through pipe. Otherwise : - perl would do a great job on this. - if you are familiar enough with SQL syntax, you can use the development version of the sqldf package to work on csv files as if they were database tables. See example 8 in http://code.google.com/p/sqldf/ Cheers, Romain Ng Stanley wrote: Hi, What functions should I use in order to perform the following steps: 1) Load a particular column (e.g., column 5) from a csv file 2) Append the column 5 to another csv file 3) select those rows that match specific keywords in column 5 -- Mango Solutions data analysis that delivers Introduction to R training course :: London :: 06-07 March 2008 http://www.mango-solutions.com/services/rtraining/r_intro.html __ R-help@r-project.org 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] Does the t.test in R uses Welch procedure or ordinary student t-test?
On Thu, 2008-02-14 at 11:51 +0100, Kes Knave wrote: Dear all I have run t.test(), and get a output similar to this: t.test(extra ~ group, data = sleep) Welch Two Sample t-test ^ Pretty big hint don't you think? data: extra by group t = -1.8608, df = 17.776, p-value = 0.0794 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -3.3654832 0.2054832 sample estimates: mean in group 1 mean in group 2 0.752.33 Should this be refered as a Welch procedure or ordinary student t-test? Regards Kes Please, Kes, read the help pages (written by volunteers giving of their own free time) instead of expecting others to do this for you. ?t.test tells you what you want to know. This isn't that difficult to find, is it? The posting guide asks you to do this before posting to the list. If for no other reason than saving yourself time waiting for replies, you should learn how to find out information for yourself in R, and the posting guide shows you how. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org 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] Any mountain clustering method in R?
Dear all, I wonder which R algorithm could perform a mountain clustering in an spatial grid, in other words, having the coordinates of a map (x,y ... or even more) and then the altitude/height at each point I would like to localise the peaks of that topological surface. Which R algorithm can perform this? I see it as a clustering problem where the peak should be at the center of each cluster. Thanks a lot, Josep Maria, - Josep Maria Campanera Alsina Investigador Juan de la Cierva Departament de Fisicoquímica Facultat de Farmàcia Avgda Joan XXIII, s/n 08028 Barcelona · Catalonia · Spain Tel: +34 93 4035988 Fax: +34 93 4035987 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org 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] contingency table
Hello! May you help me? I'm trying to do a contingency table using this data(iris) library(rpart) modelo - rpart(Species ~., iris) prev - predict(modelo, iris) Finally the contingency table table(iris$Species, prev) But an error occurs: Error in table(iris$Species, prev) : all arguments must have the same length And I do not understand why, may you help me? Thank You! __ R-help@r-project.org 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] contingency table
I don't know if this you want but, you can try: table(data.frame(prev, iris$Species)) On 14/02/2008, Carla Rebelo [EMAIL PROTECTED] wrote: Hello! May you help me? I'm trying to do a contingency table using this data(iris) library(rpart) modelo - rpart(Species ~., iris) prev - predict(modelo, iris) Finally the contingency table table(iris$Species, prev) But an error occurs: Error in table(iris$Species, prev) : all arguments must have the same length And I do not understand why, may you help me? Thank You! __ R-help@r-project.org 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org 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 cy5 and cy3 values were lowess normalized
Hi, I have some microarray data, cy5 and cy3 values are in log2. Is there a way to check they have undergone lowess normalization ? Thanks Stanley [[alternative HTML version deleted]] __ R-help@r-project.org 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] Random termination of R with RODBC and PostgreSQL 8.2.6
Dear list, I get random terminations of R when using RODBC with a remote PostgreSQL 8.2.6 database under Ubuntu Linux 7.10 32bit client. The exact messages can be seen below. It seems that there is some memory corruption going on. But it seems random to me and can neither be related to addPK=T/F or fast=T/F. It can happend for all possible combinations. Besides I do not really understand what these messages mean. Any idea to what it is related exactly? Thanks in advance, Ulrich Leopold Session details: library(RODBC) channel = odbcConnect(crtedb, uid = uleopold) channel RODB Connection 1 Details: case=tolower DSN=crtedb DATABASE=valid SERVER=10.3.1.91 PORT=5432 SSLMODE=prefer UID=uleopold PWD=** ReadOnly=Yes FakeOidIndex=No ShowOidColumn=No RowVersioning=No ShowSystemTables=No ConnSettings= Fetch=100 Socket=8192 UnknownSizes=0 MaxVarcharSize=254 MaxLongVarcharSize=8190 Debug=0 CommLog=0 Optimizer=1 Ksqo=1 UseDeclareFetch=0 TextAsLongVarchar=1 UnknownsAsLongVarchar=0 BoolsAsChar=1 Parse=0 CancelAsFreeStmt=0 ExtraSysTablePrefixes=dd_ LFConversion=0 UpdatableCursors=0 DisallowPremature=0 TrueIsMinus1=0 BI=0 ByteaAsLongVarBinary=0 UseServerSidePrepare=0 LowerCaseIdentifier=0 sqlDrop(channel, clx_test) character(0) sqlSave(channel, clx_test, varTypes=varspec, addPK=TRUE, fast=TRUE) sessionInfo() R version 2.6.2 (2008-02-08) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RODBC_1.2-3 loaded via a namespace (and not attached): [1] rcompgen_0.1-17 odbcClose(channel) *** glibc detected *** /usr/lib/R/bin/exec/R: corrupted double-linked list: 0x082dd498 *** === Backtrace: = /lib/tls/i686/cmov/libc.so.6[0xb7b8c3f9] /lib/tls/i686/cmov/libc.so.6[0xb7b8db6e] /lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7b91800] /usr/lib/R/lib/libR.so(R_chk_free+0x21)[0xb7d687c1] /usr/local/lib/R/site-library/RODBC/libs/RODBC.so[0xb742db8d] /usr/local/lib/R/site-library/RODBC/libs/RODBC.so(RODBCClose+0x2a)[0xb742dd5a] /usr/lib/R/lib/libR.so[0xb7d13ea2] /usr/lib/R/lib/libR.so(Rf_eval+0x707)[0xb7d406a7] /usr/lib/R/lib/libR.so[0xb7d43037] /usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4] /usr/lib/R/lib/libR.so[0xb7d41967] /usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4] /usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0xb7d439b7] /usr/lib/R/lib/libR.so(Rf_eval+0x2e2)[0xb7d40282] /usr/lib/R/lib/libR.so(Rf_ReplIteration+0x19b)[0xb7d6632b] /usr/lib/R/lib/libR.so(run_Rmainloop+0x107)[0xb7d666f7] /usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0xb7d6674c] /usr/lib/R/bin/exec/R(main+0x46)[0x8048776] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7b3a050] /usr/lib/R/bin/exec/R[0x8048691] === Memory map: 08048000-08049000 r-xp 08:03 422045 /usr/lib/R/bin/exec/R 08049000-0804a000 rw-p 08:03 422045 /usr/lib/R/bin/exec/R 0804a000-09941000 rw-p 0804a000 00:00 0 [heap] a770-a7721000 rw-p a770 00:00 0 a7721000-a780 ---p a7721000 00:00 0 a78ef000-a793e000 r-xp 08:03 259109 /usr/lib/libgcrypt.so.11.2.3 a793e000-a794 rw-p 0004e000 08:03 259109 /usr/lib/libgcrypt.so.11.2.3 a794-a7943000 r-xp 08:03 259082 /usr/lib/libgpg-error.so.0.3.0 a7943000-a7944000 rw-p 2000 08:03 259082 /usr/lib/libgpg-error.so.0.3.0 a7944000-a7953000 r-xp 08:03 266851 /usr/lib/libtasn1.so.3.0.9 a7953000-a7954000 rw-p e000 08:03 266851 /usr/lib/libtasn1.so.3.0.9 a7954000-a79be000 r-xp 08:03 730108 /usr/lib/libgnutls.so.13.3.0 a79be000-a79c4000 rw-p 0006a000 08:03 730108 /usr/lib/libgnutls.so.13.3.0 a79c4000-a79da000 r-xp 08:03 732700 /usr/lib/libsasl2.so.2.0.22 a79da000-a79db000 rw-p 00015000 08:03 732700 /usr/lib/libsasl2.so.2.0.22 a79db000-a79e6000 r-xp 08:03 732704 /usr/lib/liblber.so.2.0.130 a79e6000-a79e7000 rw-p b000 08:03 732704 /usr/lib/liblber.so.2.0.130 a79e7000-a79f6000 r-xp 08:03 712558 /lib/tls/i686/cmov/libresolv-2.6.1.so a79f6000-a79f8000 rw-p f000 08:03 712558 /lib/tls/i686/cmov/libresolv-2.6.1.so a79f8000-a79fa000 rw-p a79f8000 00:00 0 a79fa000-a7a01000 r-xp 08:03 259121 /usr/lib/libkrb5support.so.0.1 a7a01000-a7a02000 rw-p 6000 08:03 259121 /usr/lib/libkrb5support.so.0.1 a7a02000-a7a26000 r-xp 08:03 259108 /usr/lib/libk5crypto.so.3.1 a7a26000-a7a27000 rw-p 00024000 08:03 259108 /usr/lib/libk5crypto.so.3.1 a7a27000-a7a5b000 r-xp 08:03 732705 /usr/lib/libldap_r.so.2.0.130 a7a5b000-a7a5c000 rw-p 00034000 08:03 732705 /usr/lib/libldap_r.so.2.0.130 a7a5c000-a7a61000 r-xp 08:03
[R] Removing columns that are all NA from a matrix
Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? Thanks, Martin __ R-help@r-project.org 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] Removing columns that are all NA from a matrix
data - data[ , !apply(is.na(data), 2, all)] (or something like that) G. On Thu, Feb 14, 2008 at 12:59:46PM +, Martin Waller wrote: Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? Thanks, Martin __ R-help@r-project.org 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. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org 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] contingency table
Try looking at 'prev' (it is a matrix) and then reading ?predict.rpart to see why. My guess is that you intended type=class. On Thu, 14 Feb 2008, Carla Rebelo wrote: Hello! May you help me? I'm trying to do a contingency table using this data(iris) library(rpart) modelo - rpart(Species ~., iris) prev - predict(modelo, iris) Finally the contingency table table(iris$Species, prev) But an error occurs: Error in table(iris$Species, prev) : all arguments must have the same length And I do not understand why, may you help me? Thank You! __ R-help@r-project.org 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@r-project.org 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] Removing columns that are all NA from a matrix
On 2/14/2008 7:59 AM, Martin Waller wrote: Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? mymat[,which(colMeans(is.na(mymat)) 1)] Thanks, Martin __ R-help@r-project.org 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org 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] Removing columns that are all NA from a matrix
try this: mat - matrix(rnorm(42), 6, 7) mat[sample(42, 10)] - NA mat[, c(3,5)] - NA ind - colSums(is.na(mat)) != nrow(mat) mat mat[, 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: Martin Waller [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 14, 2008 1:59 PM Subject: [R] Removing columns that are all NA from a matrix Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? Thanks, Martin __ R-help@r-project.org 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@r-project.org 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] Removing columns that are all NA from a matrix
On 14-Feb-08 12:59:46, Martin Waller wrote: Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? Thanks, Martin It probably isn't a FAQ (it's a somewhat special question) but the following illustrates one way to do it: M-cbind(c(1,2,3,4),c(1,2,NA,4),c(NA,NA,NA,NA)) M ## [,1] [,2] [,3] ##[1,]11 NA ##[2,]22 NA ##[3,]3 NA NA ##[4,]44 NA apply(M,2,function(x){!all(is.na(x))}) ##[1] TRUE TRUE FALSE M[,apply(M,2,function(x){!all(is.na(x))})] ## [,1] [,2] ##[1,]11 ##[2,]22 ##[3,]3 NA ##[4,]44 Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 14-Feb-08 Time: 13:14:20 -- XFMail -- __ R-help@r-project.org 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 loading a new package
I am using R Version 2.3.1 (2006-06-01) in Linux with Ubuntu 7.4. I installed a new package with R CMD INSTALL -l /usr/lib/R/library newpackage.tar.gz Each time I run R I need to load this new package typing library(newpackage). My question is: how can I automatically load this new package once for ever? I read the manual but I have not been able to find the solution to that. thank you Stefano [[alternative HTML version deleted]] __ R-help@r-project.org 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] (RESOLVED) Re: Removing columns that are all NA from a matrix
Thanks to all who responded - great stuff! Martin Martin Waller wrote: Hi, I guess this might be a FAQ or something, and there's probably a nice simple way to do it, but I can't think of it: Given a matrix, I want to remove columns that are _entirely_ filled with NAs (partial NAs are fine). How please? Thanks, Martin __ R-help@r-project.org 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@r-project.org 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] Question: about loading a new package
On 14-Feb-08 13:23:17, Stefano Sofia wrote: I am using R Version 2.3.1 (2006-06-01) in Linux with Ubuntu 7.4. I installed a new package with R CMD INSTALL -l /usr/lib/R/library newpackage.tar.gz Each time I run R I need to load this new package typing library(newpackage). My question is: how can I automatically load this new package once for ever? I read the manual but I have not been able to find the solution to that. thank you Stefano Since you are using Linux, your home directory (e.g. /home/stefano) will contain a file .Rprofile (which you won't normally see unless you run the Linux command ls -a). Edit this file so that it includes the line library(newpackage) (and, while you're at it, anything else that you would like to be done every time you start R). Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 14-Feb-08 Time: 13:48:30 -- XFMail -- __ R-help@r-project.org 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] Tinn-R not working well with latest R
Hello, These are *warnings*. So, the functions should still work. However, there are changes made in R that probably need some lifting in the svIDE package. The whole SciViews bundle is currently reworked. Unfortunately, I now work on Mac OS X, and it is a little bit more difficult for me to test this with Tinn-R. Could you give me more infos about the great features in Tinn-R that stop working in R 2.6.2, please? Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Farrel Buchinsky wrote: I recently installed R 2.6.2 and am getting errors on startup that relate to svIDE being loaded by Tinn-R. Loading required package: tcltk Loading Tcl/Tk interface ... done Warning messages: 1: '\A' is an unrecognized escape in a character string 2: unrecognized escape removed from ;for Options\AutoIndent: 0=Off, 1=follow language scoping and 2=copy from previous line\n 3: In grep(paste([{]TclEval , topic, [}], sep = ), tclvalue(.Tcl(dde services TclEval {})), : argument 'useBytes = TRUE' will be ignored Loading required package: svMisc Loading required package: R2HTML Any idea what is going on. I use R 2.6.2 on windows xp I also started R without the profile that Tinn-R made. If I manualy enter library(svIDE) then I get. library(svIDE) Warning messages: 1: '\A' is an unrecognized escape in a character string 2: unrecognized escape removed from ;for Options\AutoIndent: 0=Off, 1=follow language scoping and 2=copy from previous line\n So the underlying problem may be svIDE see: http://tolstoy.newcastle.edu.au/R/e2/help/07/04/15738.html Apparently, because of this error, several great features in Tinn-R are not working properly. Any solutions or workarounds? -- Farrel __ R-help@r-project.org 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] Analysis with spatstat and Kcross() requires to much memory
Hi I am running analysis with Kcross from the package spatstat and I am getting a message that R can not allocate enough memory for a vector of 900MB. R seems to be running towards the 2GB limit per process. The dataset is not to big (ca 3000 points) but the mask for the points is extremely irregular (a buffer around roads which have been sampled) and I can do trhe analysis if I use a rectangular mask covering the whole area (which is obviously not correct). My question is: is there a way of splitting the dataset or changing the mask son that I can do the analysis, as I don't want to move to a 64bit computer (if not necessary). Thanks, Rainer My computrer: SuSE 10, 32 bit, 1GB ram, 1GB swap. R: version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 6.2 year 2008 month 02 day08 svn rev44383 language R version.string R version 2.6.2 (2008-02-08) -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Plant Conservation Unit Department of Botany University of Cape Town Rondebosch 7701 South Africa [[alternative HTML version deleted]] __ R-help@r-project.org 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] Kaplan Meier function
Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni [[alternative HTML version deleted]] __ R-help@r-project.org 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] Kaplan Meier function
See the survfit() in the survival package which is one on the recommended packages that should (I think) have come with R. Eleni Christodoulou wrote: Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni -- 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.864.5776 Fax: 416.864.6057 __ R-help@r-project.org 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] Kaplan Meier function
Eleni Christodoulou elenichri at gmail.com writes: I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. The standard survival package is package survival. Try survfit, plot.survfit, and summary(survfit). There are some fancy extension in package Design, but better start with survival, Design-based KM have huge options list that can be confusing at first. Dieter __ R-help@r-project.org 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] Any mountain clustering method in R?
Dear Josep Maria, Maybe this is way too naive, but what about a hill-climbing algorithm started from different places, and without (almost) any attempt to avoid local maxima? I think that if you formulate your question like a clustering problem, then you'll be using techniques that attempt to solve problems that are not really of any concern for you original question. Regardless, I think you'll need to carefully think what constitute legitimate peaks for you. Suppose the 1D data 2, 3, 4, 3, 4, 5, 4, 3, 2 is the first 4 a peak or not? Best, R. On Thu, Feb 14, 2008 at 12:08 PM, Josep Maria Campanera Alsina [EMAIL PROTECTED] wrote: Dear all, I wonder which R algorithm could perform a mountain clustering in an spatial grid, in other words, having the coordinates of a map (x,y ... or even more) and then the altitude/height at each point I would like to localise the peaks of that topological surface. Which R algorithm can perform this? I see it as a clustering problem where the peak should be at the center of each cluster. Thanks a lot, Josep Maria, - Josep Maria Campanera Alsina Investigador Juan de la Cierva Departament de Fisicoquímica Facultat de Farmàcia Avgda Joan XXIII, s/n 08028 Barcelona · Catalonia · Spain Tel: +34 93 4035988 Fax: +34 93 4035987 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org 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. -- Ramon Diaz-Uriarte Statistical Computing Team Structural Biology and Biocomputing Programme Spanish National Cancer Centre (CNIO) http://ligarto.org/rdiaz __ R-help@r-project.org 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] Kaplan Meier function
check function survfit() in package survival. 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: Eleni Christodoulou [EMAIL PROTECTED] To: r-help@r-project.org Sent: Thursday, February 14, 2008 2:50 PM Subject: [R] Kaplan Meier function Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Transposing by a group variable
Hi R, Can I transpose a data frame by a particular group variable? For example: d=data.frame(group=c(1,1,2,2,2),val=c(6,4,6,3,5)) And my output should be: data.frame(group=c(1,2),v1=c(6,6),v2=c(4,3),v3=c(NA,5)) Many thanks, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org 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] Kaplan Meier function
Thank you all for the replies! Eleni On Thu, Feb 14, 2008 at 4:10 PM, Dimitris Rizopoulos [EMAIL PROTECTED] wrote: check function survfit() in package survival. 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.htmhttp://www.student.kuleuven.be/%7Em0390867/dimitris.htm - Original Message - From: Eleni Christodoulou [EMAIL PROTECTED] To: r-help@r-project.org Sent: Thursday, February 14, 2008 2:50 PM Subject: [R] Kaplan Meier function Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni [[alternative HTML version deleted]] __ R-help@r-project.org 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 [[alternative HTML version deleted]] __ R-help@r-project.org 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] User defined split function in Rpart
The question is about the direction vector in rpart. There are (at least) two preferred ways to lay out a tree, wrt the question of which obs are sent left and which right. 1. Send the smaller y values to the left. In the final tree, there will be a graphical ordering with smaller y's to the left and larger ones to the right. One has a left bad, right good orientation when traversing the tree. I find that medical researchers often like this. 2. Send observations with x cutpoint to the left. Setting all elements of the direction vector to -1 will give this behavior. I happen to slightly prefer option 1, which of course means that it became the default behavior in rpart. (For a categorical y with many levels, however, rpart orders on the percent of observations in category 1, which may not be particularly useful.) Terry Therneau __ R-help@r-project.org 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] data manipulation for plotting
Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) I want values-c(1,4,5,6) freq-c(3,1,2,1) in order to enable me to plot this. Sorry, i'm new to R. What is standard procedure here for plotting the data vector? cheers Rich __ R-help@r-project.org 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] Kaplan Meier function
Hi Eleni, hi list, here is small sample program, the library is survival, it is included in the standard R distribution. data(colon) s = survfit(Surv(time, status) ~ rx, data=colon) plot(s) plot(s, col=1:3) By the way: Does anyone know a neat way to indicate the number of patients under risk in the curve? Like here: http://www.drugs.com/pro/images/8c3bb783-1c3c-4d75-a502-2f7ee3632f41/inspra-image02.jpg Best wishes, Matthias Eleni Christodoulou schrieb: Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Transposing by a group variable
try this: d - data.frame(group = c(1,1,2,2,2), val = c(6,4,6,3,5)) d$time - unlist(tapply(d$group, d$group, function (x) seq(1, len = length(x reshape(d, idvar = group, direction = wide) 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: Shubha Vishwanath Karanth [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 14, 2008 3:22 PM Subject: [R] Transposing by a group variable Hi R, Can I transpose a data frame by a particular group variable? For example: d=data.frame(group=c(1,1,2,2,2),val=c(6,4,6,3,5)) And my output should be: data.frame(group=c(1,2),v1=c(6,6),v2=c(4,3),v3=c(NA,5)) Many thanks, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org 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@r-project.org 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] Levene's test for homogeneity of variances (befor using ANOVA)
Dear all I have tried to find this function in R, but don't find it by searching in the help function. Anybody who knows if R has the function Levene's test for homogeneity of variances? Note: Im a R-begginer Regards Kes [[alternative HTML version deleted]] __ R-help@r-project.org 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] data manipulation for plotting
On Thu, 2008-02-14 at 14:35 +, [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) Don't call your data 'data' ;-) install.packages(fortunes) library(fortunes) fortune(dog) I want values-c(1,4,5,6) freq-c(3,1,2,1) use ?unique and ?table my.dat - c(1,1,1,4,5,5,6) values - unique(my.dat) values tab - table(dat) tab freq - as.numeric(tab) freq plot(tab) # for one way of plotting what you want plot(freq ~ values) # for another HTH G in order to enable me to plot this. Sorry, i'm new to R. What is standard procedure here for plotting the data vector? cheers Rich __ R-help@r-project.org 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org 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] Kaplan Meier function
Matthias Gondan wrote: Hi Eleni, hi list, here is small sample program, the library is survival, it is included in the standard R distribution. data(colon) s = survfit(Surv(time, status) ~ rx, data=colon) plot(s) plot(s, col=1:3) By the way: Does anyone know a neat way to indicate the number of patients under risk in the curve? Like here: That's one of many options in the survplot function in the Design package, which uses the survival package. Frank http://www.drugs.com/pro/images/8c3bb783-1c3c-4d75-a502-2f7ee3632f41/inspra-image02.jpg Best wishes, Matthias Eleni Christodoulou schrieb: Hi all, I am trying to draw a Kaplan-Meier curve and I found online that Kaplan - Meier estimates are computed with a function called km in the event package. Is there an update for that because when I choose to download packages in R,. there is no package called event, even though I have selected all the repositories. Thanks in advance, Eleni [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org 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] Modelling disease spread
Thanks Marcel, In addition to your program and the reference to simecol, someone had replied to my private email pointing out RLadyBug: An R package for stochastic epidemic models which is on CRAN and which seems one of the most relevant. I write it here as a reference for users doing a future search in this archive. Regards. Bio7 wrote: The simecol package is maybe what you want. http://hhbio.wasser.tu-dresden.de/projects/simecol/ http://hhbio.wasser.tu-dresden.de/projects/simecol/ Another possibility is to use a program i've written. Here is a flash presentation maybe also interesting for you. http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/flashtut/animaterplot.htm http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/flashtut/animaterplot.htm -- View this message in context: http://www.nabble.com/Modelling-disease-spread-tp15459834p15480798.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] RFC for package PopCon: a popularity contest for R and packages
(I posted this to the R-devel list yesterday, but I thought others on this list would be interested, so sorry for those who get it twice.) Hello all, I've developed a prototype package called PopCon (short for popularity contest), a package for tracking the popularity of R and its packages. I'd like this work to be similar in spirit to the Debian package popularity-contest: http://popcon.debian.org/. Once Popcon is loaded, it captures two kinds of information from the user and stores it into a cache: the names of the libraries he/she loads, and the names of symbols requested from his/her code. Once the cache is full, the goal is to flush the data to a central server for storage, free for anyone to download and analyze. That's it. Pretty simple use and works behind the scenes. You can get the prototype here: http://biostat.mc.vanderbilt.edu/twiki/pub/Main/JeffreyHorner/PopCon_0.1.tar.gz And note that flushing of the cache is NOT TURNED ON and IT WON'T FORWARD ANY DATA ANYWHERE! It only gets deleted. So, I envision all the software and data generated and stored to be licensed under a GPL and a Creative Commons license, or even public domain. Thoughts? I'm looking for volunteers, because there are many issues to hash out. Here's a few of them: 1. Obviously storing IP addresses or any bit of personal information is out, but I'm interested in generating a permanent random key of some sort so that data from the same R installs can be tracked. I'm wondering if just md5 hashing the combination of R version, platform, and IP address would be appropriate and reproducible per R install. The debian package popularity-contest has the benefit of installing an '/etc' config file and generating the key once, while I'd like PopCon users to just call 'library(PopCon)' and do nothing else. 2. I'm willing to maintain the central server and work on the infrastructure, but help will definitely be needed. Also, if there's significant interested, maybe R core would be interested in this. 3. What exactly is PopCon tracking as far as symbol names go? It currently used an R_ObjectTable object attached to the search path to capture names, but is this the best way? see http://www.omegahat.org/RObjectTables/. It's also replacing base::getHook to trap library loads. 4. What else would be interesting to track? Some folks have suggested various bits of R.Version() output. Here's what PopCon can currently do: library(PopCon) search() [1] .GlobalEnvpackage:PopCon.pcUDB [4] package:stats package:graphics package:grDevices [7] package:utils package:datasets package:methods [10] Autoloads package:base # Notice the above search entry .pcUDB. That's the R Object Table typeof(PopCon::getCache()) [1] character PopCon::getCache() [1] .conflicts.OK search:: # Now the cache contains the name 'search', which I called above, # and the double colon operator. library(cluster) any(PopCon::getCache()=='package:cluster') [1] TRUE # Package names are represented in the PopCon cache just like # their name on the search path. PopCon::getCache() [1] .conflicts.OKsearch [3] :: $.data.frame [5] $.default$.data.frame [7] $.defaultunique.integer [9] unique.numeric $.data.frame [11] $.defaultunique.integer [13] unique.numeric unique.character [15] unique.integer unique.numeric [17] close.gzfile $.packageDescription2 [19] $.default$.data.frame [21] $.defaultunique.integer [23] unique.numeric unique.character [25] unique.integer unique.numeric [27] close.gzfile $.packageDescription2 [29] $.defaultunique.integer [31] unique.numeric close.gzfile [33] names.simple.listnames.default [35] [.defaultas.character.simple.list [37] as.vector.simple.listas.vector.default [39] unique.character $.packageDescription2 [41] $.default=.R_system_version [43] Ops.R_system_version =.package_version [45] Ops.package_version =.numeric_version [47] =.package_version Ops.package_version [49] =.numeric_version unlist.R_system_version [51] unlist.package_version unlist.numeric_version [53] unlist.default unlist.package_version [55] unlist.numeric_version unlist.default [57] as.list.R_system_version as.list.package_version [59] unique.integer unique.numeric [61] as.list.R_system_version as.list.package_version [63] unique.integer unique.numeric [65] as.list.package_version unique.integer [67] unique.numeric as.list.package_version [69] unique.integer unique.numeric [71] =.default $.packageDescription2 [73] $.default.R_system_version [75]
[R] plot each column of a matrix or dataframe versus x in a single plot
How do a plot several columns of a matrix at once in a single plot versus a single x-variable? The default plot.matrix or plot.dataframe commands plot each column versus each other column in several sub-plots. I want to plot each column versus a single other vector (x) as several lines or points in one plot. I can do it by hand: get the range of all variables (i.e. columns of the matrix or dataframe), initiate an empty plot command, loop through all the columns and issue a lines or points command. I guess there is a predefined sophisticated function for that, however, I was not able to find it. Does someone know where I find such a function? Best regards tomaschwutz __ R-help@r-project.org 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] Levene's test for homogeneity of variances (befor using ANOVA)
On 2/14/2008 9:47 AM, Kes Knave wrote: Dear all I have tried to find this function in R, but don't find it by searching in the help function. Anybody who knows if R has the function Levene's test for homogeneity of variances? Note: Im a R-begginer I wonder how you searched for a function. For example, when I do the following: RSiteSearch(levene, restrict=function) levene.test() functions in the car and lawstat packages are the first two hits. Regards Kes [[alternative HTML version deleted]] __ R-help@r-project.org 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org 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] Levene's test for homogeneity of variances (befor using ANOVA)
On Thu, Feb 14, 2008 at 03:47:35PM +0100, Kes Knave wrote: Dear all I have tried to find this function in R, but don't find it by searching in the help function. Take a look at in R: ?RSiteSearch Use this to search for it. Anybody who knows if R has the function Levene's test for homogeneity of variances? Yes. David Note: Im a R-begginer Regards Kes [[alternative HTML version deleted]] __ R-help@r-project.org 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 Whiting, Ph.D. Advancing Research in Chronic Disease Epidemiology (ARCHEPI) programme Institute of Health and Society, The Medical School, Newcastle University, Framlington Place, Newcastle upon Tyne, NE2 4HH. Tel: +44 191 222 7045; Extn: 7375; Fax: +44 191 222 8211. http://research.ncl.ac.uk/archepi www.ncl.ac.uk/ihs __ R-help@r-project.org 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 model.frame.default: invalid type (list) for variable ...
I got it right now, It wasn't working because the matrix of predictors had the same name as the dataset, so I modified the call creating a dataset with the response and predictors and keeping the data.frame using the same name metodocentrod - data.frame(metodocentro) resultadocentro - glm(Ycentro ~ metodocentro-1, family = binomial(link = logit), data=metodocentrod) Thanks for the help, because of your e-mail I could figure this out. [[alternative HTML version deleted]] __ R-help@r-project.org 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 each column of a matrix or dataframe versus x in a singleplot
you could use the function matplot(), e.g., x - 1:20 vals - 2 + rep(1:5, each = 20) * rep(x, 5) + rnorm(100) dim(vals) - c(20, 5) matplot(x, vals, type = l, lty = 1) 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: tomaschwutz [EMAIL PROTECTED] To: r-help@r-project.org Sent: Thursday, February 14, 2008 3:55 PM Subject: [R] plot each column of a matrix or dataframe versus x in a singleplot How do a plot several columns of a matrix at once in a single plot versus a single x-variable? The default plot.matrix or plot.dataframe commands plot each column versus each other column in several sub-plots. I want to plot each column versus a single other vector (x) as several lines or points in one plot. I can do it by hand: get the range of all variables (i.e. columns of the matrix or dataframe), initiate an empty plot command, loop through all the columns and issue a lines or points command. I guess there is a predefined sophisticated function for that, however, I was not able to find it. Does someone know where I find such a function? Best regards tomaschwutz __ R-help@r-project.org 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@r-project.org 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] Transposing by a group variable
Try also: reshape(cbind(d, time=unlist(sapply(table(d$group), seq))), idvar=group, direction=wide) On 14/02/2008, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Can I transpose a data frame by a particular group variable? For example: d=data.frame(group=c(1,1,2,2,2),val=c(6,4,6,3,5)) And my output should be: data.frame(group=c(1,2),v1=c(6,6),v2=c(4,3),v3=c(NA,5)) Many thanks, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] {lattice/grid} Error using packet 1 and traceback
You can tell Lattice to stop when an error occurs, like this: lattice.options(panel.error=stop) xyplot(1:10 ~ 1:10, panel=function(...) stop(foo)) # - Error in panel(x = 1:10, y = 1:10) : foo That is a little more informative than the default panel.error, because it tells you the conditionCall as well as the conditionMessage. But unfortunately, traceback() will still not work as you expect, it will say something unhelpful about tryCatch() inside print.trellis(). As far as I know there is no way to recover the call stack from an error once it has been caught by tryCatch. (I would be very happy to be proved wrong...) As a work-around, you could call the panel function directly. Probably the best way to do that is to start with a lattice plot using the default panel function, and then trellis.focus() do.call(my.panel.xyplot, trellis.panelArgs()) Felix On Thu, Feb 14, 2008 at 9:14 PM, Wolfram Fischer [EMAIL PROTECTED] wrote: On some errors during the plot of a lattice/grid graphics, there is written a message like Error using packet 1: missing value where TRUE/FALSE needed into the concering panel and the next panel is plotted. Which option I could use to stop the execution to have a look at the error by a traceback? Regards - Wolfram __ R-help@r-project.org 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. -- Felix Andrews / 安福立 PhD candidate Integrated Catchment Assessment and Management Centre The Fenner School of Environment and Society The Australian National University (Building 48A), ACT 0200 Beijing Bag, Locked Bag 40, Kingston ACT 2604 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@r-project.org 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 each column of a matrix or dataframe versus x in a single plot
Hi Thomas, Ckeck ?matplot. Here's a simple example: # Data set x=runif(100)# Axis x1=rnorm(100,25,2) # Variable x_i x2=rnorm(100,10,1) x3=rnorm(100,15,4) x4=rnorm(100,30,4) DATA=cbind(x,x1,x2,x3,x4) # Plot matplot(x,DATA[,2:5],col=1:5,pch=1:5) I hope this helps. Jorge On 2/14/08, tomaschwutz [EMAIL PROTECTED] wrote: How do a plot several columns of a matrix at once in a single plot versus a single x-variable? The default plot.matrix or plot.dataframe commands plot each column versus each other column in several sub-plots. I want to plot each column versus a single other vector (x) as several lines or points in one plot. I can do it by hand: get the range of all variables (i.e. columns of the matrix or dataframe), initiate an empty plot command, loop through all the columns and issue a lines or points command. I guess there is a predefined sophisticated function for that, however, I was not able to find it. Does someone know where I find such a function? Best regards tomaschwutz __ R-help@r-project.org 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@r-project.org 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] data manipulation for plotting
Hi rich, data - c(1,1,1,4,5,5,6) table(data) data 1 4 5 6 3 1 2 1 hope it helps josephine [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) I want values-c(1,4,5,6) freq-c(3,1,2,1) in order to enable me to plot this. Sorry, i'm new to R. What is standard procedure here for plotting the data vector? cheers Rich __ R-help@r-project.org 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@r-project.org 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] write output in a custom format
Hi, I need to create a text file in the following format, 1 100.0 0 0 0 1 1 0 0 1 1 # 1 100.0 0 0 0 0 1 1 0 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) print(particle) I'd like to establish a connection to a file and append to it a particle block in the format above, or even write the whole file at once. Because different lines have a different number of elements, I couldn't get write.table to work in this case, and my attempts at sink (), dump(), writeLines(), writeChar() all turn into really dirty solutions. I have this feeling I'm overlooking a simple solution. Any help welcome, baptiste _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R equivalent of linux cut, paste, and grep ?
Depending on what your final goal is, there may be a better approach, but to do as you state below, here is one set of options: 1) use read.csv (or read.table) and use the colClasses argument to specify keeping only column 5 2) use cbind to bind column 5 (now a data.frame) to another data.frame (possibly read in using read.csv), this assumes that the row order matches, merge is a possibility if they don't match. 3) use the subset command to select the rows, use the %in% operator to compare col 5 to your list of desired values. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ng Stanley Sent: Thursday, February 14, 2008 1:03 AM To: r-help Subject: [R] R equivalent of linux cut, paste, and grep ? Hi, What functions should I use in order to perform the following steps: 1) Load a particular column (e.g., column 5) from a csv file 2) Append the column 5 to another csv file 3) select those rows that match specific keywords in column 5 [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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 each column of a matrix or dataframe versus x in a single plot
Thank you Dimitris, Jorge, and Mark (personal mail), for the hint to matplot and the examples. This was exactly what I was thinking of. Thomas __ R-help@r-project.org 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 cy5 and cy3 values were lowess normalized
On Thu, Feb 14, 2008 at 4:57 AM, Ng Stanley [EMAIL PROTECTED] wrote: Hi, I have some microarray data, cy5 and cy3 values are in log2. Is there a way to check they have undergone lowess normalization ? Yes, go back ask the one who you got the data from. Honestly, this is a serious reply, because why waste time second guessing what data you are working with. I've seen people (including me) spending way too much time to knowing exactly what data I am working with. It is just a waste of time and in the end of the day it should be possible to find out from the source. To answer your question as is, if you know that the data is *either* curve-fit (lowess is one of them) normalized *or* not at all, then a log-ratio log-intensity scatter plot *might* show symptoms that are very specific to curve-fit normalized data. These symptoms are stronger the more curvature there was in the log-ratio log-intensity plot for the beginning. The best way I illustrate this symptom is to look at the symmetry of the normalized data down at the lower intensities. See Panel B (curve-fit) on Slide 16 in http://www.stat.berkeley.edu/hb/talks/BengtssonH_20080208-YetAnotherAffinePresentation.pdf Going back to the (R,G) space on intensity scale will also reveal the same symptoms, cf. Slide 11. You'll find all the background in: H. Bengtsson and O. Hössjer, Methodological study of affine transformations of gene expression data with proposed robust non-parametric multi-dimensional normalization method, BMC Bioinformatics, 2006, 7:100. Finally, you reach more bioinformaticians/statisticians in the field if you send these questions to the http://www.bioconductor.org/ mailing list instead. Please continue the thread there if you have follow-up questions. Cheers /Henrik Thanks Stanley [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] write output in a custom format
Here is a start. You basically have to interate through your data and use 'cat' to write it out: particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c(0,1,0,1))) output - file(/tempxx.txt, w) cat(particle$dose, \n, file=output, sep= ) for (i in 1:nrow(particle$pos)){ cat(particle$pos$x[i], particle$pos$y[i], \n, file=output, sep= ) } cat(#\n, file=output, sep= ) close(output) Here is what the file looks like: 1 100 0 0 0 1 1 0 0 1 1 # On 2/14/08, baptiste Auguié [EMAIL PROTECTED] wrote: Hi, I need to create a text file in the following format, 1 100.0 0 0 0 1 1 0 0 1 1 # 1 100.0 0 0 0 0 1 1 0 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) print(particle) I'd like to establish a connection to a file and append to it a particle block in the format above, or even write the whole file at once. Because different lines have a different number of elements, I couldn't get write.table to work in this case, and my attempts at sink (), dump(), writeLines(), writeChar() all turn into really dirty solutions. I have this feeling I'm overlooking a simple solution. Any help welcome, baptiste _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] {lattice/grid} Error using packet 1 and traceback
On 2/14/08, Felix Andrews [EMAIL PROTECTED] wrote: You can tell Lattice to stop when an error occurs, like this: lattice.options(panel.error=stop) xyplot(1:10 ~ 1:10, panel=function(...) stop(foo)) # - Error in panel(x = 1:10, y = 1:10) : foo That is a little more informative than the default panel.error, because it tells you the conditionCall as well as the conditionMessage. But unfortunately, traceback() will still not work as you expect, it will say something unhelpful about tryCatch() inside print.trellis(). As far as I know there is no way to recover the call stack from an error once it has been caught by tryCatch. (I would be very happy to be proved wrong...) Right, and I've also thought that this was a bad thing. I'll see if I can figure out a way to restore traceback functionality. If all else fails, I'll just another option that disables the tryCatch mechanism. -Deepayan __ R-help@r-project.org 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] Levene's test for homogeneity of variances (befor using ANOVA)
Hi Kes, Try library(help=car) ?levene.test or levene in http://www.rseek.org/ (first hit). I hope this helps, Jorge On 2/14/08, Kes Knave [EMAIL PROTECTED] wrote: Dear all I have tried to find this function in R, but don't find it by searching in the help function. Anybody who knows if R has the function Levene's test for homogeneity of variances? Note: Im a R-begginer Regards Kes [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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 matrix
Dear R users, I like to plot a matrix A which looks like this: ,1 ,2 ,3 ,4 1, 1 10 100 1000 2, 0.5 0.2 1.0 4.3 3, 0.1 0.2 0.3 0.5 . where the 1st row is representing the X-axis values. The subsequent rows should be plotted on the y-axis. I would prefer to use the smoothScatter plotting function of the geneplotter package, but to begin with R I'd be happy to use any scatterplot with the given dataset provided in the matrix A. So I tried: plot(A[1,],A[2:3,]) or plot(A[1,],A[2-3,]) both result in : Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ What do I have to do? Marek __ R-help@r-project.org 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] Cholmod error `matrix not positive definite'
Dear R-users, I'm new to R, so my apologies if this question doesn't make sense. I've tried the following model in lmer, and it works perfectly: model-lmer(aphids~densroot+zone+(1|zone/site), family=quasipoisson) But if I try the exact same model with a different variable, totmas, the model looks as follows: model-lmer(aphids~totmas+zone+(1|zone/site), family=quasipoisson) Totmas is also a continuous variable just like densroot, but in this case I receive the following message: CHOLMOD warning: Ãâ e Error in objective(.par, ...) : Cholmod error `matrix not positive definite' at file:../Supernodal/t_cholmod_super_numeric.c, line 613 Moreover, if I test yet another continuous variable vitality, to my surprise R just crashes completely. This is a mystery to me, especially because the variables totmas or vitality don't give any problem when I build the exact same models in SAS with proc glimmix... Does someone have experience with this type of problem? Thank you in advance, Martijn. -- Martijn Vandegehuchte Ghent University Department Biology Terrestrial Ecology Unit K.L.Ledeganckstraat 35 B-9000 Ghent telephone: +32 (0)9/264 50 84 e-mail: [EMAIL PROTECTED] website TEREC: www.ecology.ugent.be/terec [[alternative HTML version deleted]] __ R-help@r-project.org 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] data frame question
Hi I have a data frame df1 in which I would like to multiply col1 by 2. The way I did it does not allow me to keep the old data frame. How can I do this and be able to create a new data frame df2? df1= data.frame(col1= c(3, 5, NA, 1), col2= c(4, NA,6, 2)) df1 col1 col2 134 25 NA 3 NA6 412 df1$col1=df1$col1*2 df1 col1 col2 164 2 10 NA 3 NA6 422 Be a better friend, newshound, and [[alternative HTML version deleted]] __ R-help@r-project.org 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] Problems with Rcmdr unter JGR (Windows XP)
I try to start Rmcdr from JGR. The Rmcdr-Windows comes up correctly; but the Menu-Bar in the Rcmdr-Window goes away, if I try to go into the Rmcdr-Window. I hope, someone has a solution. Regards, willi -- 0(049)753124283 privat 0(049)7531882641 büro [[alternative HTML version deleted]] __ R-help@r-project.org 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] Replacing a character string when finding substring match
Try this: x[grep(vehicle, x, ignore=T)] - Vehicle On 14/02/2008, Judith Flores [EMAIL PROTECTED] wrote: Dear R-experts, I need to replace the values of a vector(tx) with a word ('Vehicle') when the value of the vector contains the word 'vehicle'. Sometimes, the value could be 'MCT vehicle', or 'control-vehicle', etc. I tried gsub like this treatment-gsub('vehicle','Vehicle', tx, ignore.case=T) But then I end up with values like 'MCT Vehicle' or 'control-Vehicle'. I want the values to be one word: 'Vehicle'. Thank you in advance for any help. Be a better friend, newshound, and __ R-help@r-project.org 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org 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] data manipulation for plotting
Here are a couple of ways depending on what you want. data1=c(1,1,1,4,5,5,6) plot(table(data1)) --- plotvec - as.vector(aa) nns - names(aa) plot(plotvec, xaxt=n) mtext(nns, at=1:4, side=1) --- --- [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) I want values-c(1,4,5,6) freq-c(3,1,2,1) in order to enable me to plot this. Sorry, i'm new to R. What is standard procedure here for plotting the data vector? cheers Rich __ R-help@r-project.org 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. [[elided trailing spam]] __ R-help@r-project.org 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] Replacing a character string when finding substring match
Dear R-experts, I need to replace the values of a vector(tx) with a word ('Vehicle') when the value of the vector contains the word 'vehicle'. Sometimes, the value could be 'MCT vehicle', or 'control-vehicle', etc. I tried gsub like this treatment-gsub('vehicle','Vehicle', tx, ignore.case=T) But then I end up with values like 'MCT Vehicle' or 'control-Vehicle'. I want the values to be one word: 'Vehicle'. Thank you in advance for any help. Be a better friend, newshound, and __ R-help@r-project.org 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] apply on large arrays
system.time({ + tab2 - tab1 - with(pisa1, table(CNT,GENDER,ISCOF,ISCOM)) + tab2[] - 0 + tab2[which(tab1 == 1, arr.ind = TRUE)] - 1 + tab3 - rowSums(tab2) + }) user system elapsed 3.170.994.17 system.time({ + tab4 - rowSums(tab1 == 1) + }) user system elapsed 1.020.181.20 And yes, the results were identical. [EMAIL PROTECTED] wrote: Was the answer the same as the one you were getting with the original code? How long did the original code take compared to these two versions? Cheers, Bill V. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: Erich Neuwirth [mailto:[EMAIL PROTECTED] Sent: Thursday, 14 February 2008 5:08 PM To: Venables, Bill (CMIS, Cleveland) Subject: Re: [R] apply on large arrays Thanks, this version is definitely faster than the first one. system.time gives 0.13 instead of 0.79 seconds. [EMAIL PROTECTED] wrote: Hmm. I think this could be faster still: tab1 - with(pisa1, table(CNT,GENDER,ISCOF,ISCOM)) tab3 - rowSums(tab1 == 1) but check it... Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Venables, Bill (CMIS, Cleveland) Sent: Thursday, 14 February 2008 10:30 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [R] apply on large arrays Your code is tab1 - with(pisa1, table(CNT,GENDER,ISCOF,ISCOM)) tab2 - apply(tab1, 1:4, function(x) ifelse(sum(x) == 1, 1, 0)) tab3 - apply(tab2, 1, sum) As far as I can see, step 2, (the problematic one), merely replaces any entries in tab1 that are not equal to one by zeros. I think this would do the same job a bit faster: tab2 - tab1 - with(pisa1, table(CNT,GENDER,ISCOF,ISCOM)) tab2[] - 0 tab2[which(tab1 == 1, arr.ind = TRUE)] - 1 tab3 - rowSums(tab2) If you don't need to keep tab1, you would make things even better by removing it. Bill Venables. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erich Neuwirth Sent: Thursday, 14 February 2008 9:52 AM To: r-help Subject: [R] apply on large arrays I have a big contingency table, approximately of size 60*2*500*500, and I need to count the number of cells containing a count of 1 for each of the factors values defining the first dimension. Here is my attempt: tab1-with(pisa1,table(CNT,GENDER,ISCOF,ISCOM)) tab2-apply(tab1,1:4,function(x)ifelse(sum(x)==1,1,0)) tab3-apply(tab2,1,sum) Computing tab2 is very slow. Is there a faster and/or more elegant way of doing this? -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@r-project.org 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] Generalized nonlinear mixed model function?
Hi Philip, your data are event times because you're monitoring the same trees in each plot over time, the event being death of a tree. Therefore methods from survival analysis are more appropriate. Start out having a look at the package survival, possibly considering a Cox model with adjustment for clusters or with strata (the function coxph()) or a parametric model using the function survreg(). Christian __ R-help@r-project.org 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] data manipulation for plotting
Try this: values - c(1,1,1,4,5,5,6) with(rle(values), plot(values, lengths)) But I think that you can use barplot: barplot(table(values)) On 14/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) I want values-c(1,4,5,6) freq-c(3,1,2,1) in order to enable me to plot this. Sorry, i'm new to R. What is standard procedure here for plotting the data vector? cheers Rich __ R-help@r-project.org 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org 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] Advice on analyzing a mixed effects survival model?
I have an experiment I'm trying to analyze that's turning out to be more complicated than I anticipated, so I was hoping for some suggestions about how to handle it. The lab experiment is a comparison between two search interfaces. After a little training, each subject performs 12 information search tasks, 6 with one interface and 6 with the other, and we measure time to complete and number of clicks. The overall design is a latin square: with 12 subjects, the design has each task done before and after each other one the same number of times, and each is done 6 times with one interface and 6 with the other. Maybe a table will make it clearer what is happening: RunTasks 1- 1281 117546 10392 2-1127 8411105 9623 3-9102 43761 512118 4-326 9510114 87121 5-635 2119810 12417 6-5611 382129 11074 7-714 12108911 2536 8-81112 51673 42109 9-1049 721312 68511 10 -1158 612312 79410 11 -293 106457 111812 12 -4710 191228 31165 RunInterface 1-00111 1000110 2-10101 0101010 3-01010 1010101 4-10101 0101010 5-01010 1010101 6-10101 0101010 7-01010 1010101 8-10101 0011100 9-11100 0101001 10 -000101 010111 11 -110110 101000 12 -010001 110011 The resulting data look something like subject run seq task interface time clicks 1 1 1 120123 18 1 1 280 197 23 1 1 311 156 21 2 2 1 1 1 8710 . I was planning originally to analyze the data with ANOVA: time (or probably log(time)) ~ task + subject + interface. Some tasks are harder than others, some subjects slower, but we control for those to see the effect of the interface. I did not plan to include an interaction
Re: [R] Transposing by a group variable
How do we know what value corresponds to what new variable? library(reshape) mm - melt(d, id=group) cast(mm, group~value) will give you something but not quite what you want. --- Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Can I transpose a data frame by a particular group variable? For example: d=data.frame(group=c(1,1,2,2,2),val=c(6,4,6,3,5)) And my output should be: data.frame(group=c(1,2),v1=c(6,6),v2=c(4,3),v3=c(NA,5)) Many thanks, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org 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@r-project.org 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] Advice on analyzing a mixed effects survival model?
Small correction: I meant to say that I had been reading: J. C. Pinheiro and D. M. Bates (2000), “Mixed-Effects Models in S and S-Plus”, Springer. Kevin Crowston __ R-help@r-project.org 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] deleting certain observations in a data frame
Hi, I'm wondering what the fastest way is to delete certain data points (observations) in a data frame. I have a vector of the indices/row.names I would like to delete. I have tried replacing list by list, but it always complains about different lengths, replacing list of length a with length b and so on. Another way to think of it is that it's a generazation of na.rm I guess. Thanks, Karen _ [[alternative HTML version deleted]] __ R-help@r-project.org 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] deleting certain observations in a data frame
Karen For indices, use the minus sign: yourData[-indicesToBeDeleted,] For rownames, negate %in%: yourData[!rownames(yourData)%in%namesToBeDeleted,] HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chang Liu Sent: Friday, 15 February 2008 9:50 a.m. To: r-help@r-project.org Subject: [R] deleting certain observations in a data frame Hi, I'm wondering what the fastest way is to delete certain data points (observations) in a data frame. I have a vector of the indices/row.names I would like to delete. I have tried replacing list by list, but it always complains about different lengths, replacing list of length a with length b and so on. Another way to think of it is that it's a generazation of na.rm I guess. Thanks, Karen _ [[alternative HTML version deleted]] __ R-help@r-project.org 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 confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. __ R-help@r-project.org 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] Using Conditional AIC with lmer
Hi all, This was posted originally on r-sig-mixed-models, but I thought I would post here as well as it might be of more general interest. With a colleague, I have been trying to implement the Conditional AIC described by Vaida and Blanchard 2005 Biometrika, Conditional Akaike information for mixed-effects models. This quantity is derived in a way analogous to the AIC, but is appropriate for scenarios where one is interested in the particular coefficient estimates for individual random effects. The formula for the asymptotic CAIC is given as -2*log(likelihood of observed values, conditional on ML estimates of fixed effects and empirical Bayes estimates of random effects) + 2*K where K = rho + 1, and rho = effective degrees of freedom = trace of the hat matrix mapping predicted values onto observed values. After some thinking and some off-list advice, we have decided that appropriate code for CAIC is CAIC - function(model) { sigma - attr(VarCorr(model), 'sc') observed - attr(model, 'y') predicted - fitted(model) cond.loglik - sum(dnorm(observed, predicted, sigma, log=TRUE)) rho - hatTrace(model) p - length(fixef(model)) N - nrow(attr(model, 'X')) K.corr - N*(N-p-1)*(rho+1)/((N-p)*(N-p-2)) + N*(p+1)/((N-p)*(N-p-2)) CAIC - -2*cond.loglik + 2*K.corr return(CAIC) } where K.corr is the finite-sample correction for K, for ML model fits. I am posting this so that 1) This code can be of use to any other souls in the statistical wilderness trying to do model selection with mixed models, and 2) So that wiser minds can point out any errors in our approach. Thanks, Kyle __ R-help@r-project.org 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] Replacing columns in a data frame using a previous condition
It's, Jim. Thank you so much. Jorge On 2/14/08, jim holtman [EMAIL PROTECTED] wrote: Is this what you want to do? x - data.frame(a=1:10, b=1:10, c=1:10, d=1:10) z - cbind(c=11:20, d=11:20) z c d [1,] 11 11 [2,] 12 12 [3,] 13 13 [4,] 14 14 [5,] 15 15 [6,] 16 16 [7,] 17 17 [8,] 18 18 [9,] 19 19 [10,] 20 20 x[,colnames(z)] - z[, colnames(z)] x a b c d 1 1 1 11 11 2 2 2 12 12 3 3 3 13 13 4 4 4 14 14 5 5 5 15 15 6 6 6 16 16 7 7 7 17 17 8 8 8 18 18 9 9 9 19 19 10 10 10 20 20 On 2/14/08, Jorge Iván Vélez [EMAIL PROTECTED] wrote: Dear R-list, I'm working with a data frame which dimensions are dim(GERU) [1] 3468 318 and looks like GERU[1:10,1:10] ped ind par1 par2 sex sta rs7696470 rs7696470.1 rs1032896 rs1032896.1 1 USA5854 200 2 1 4 4 1 1 2 USA5854 312 1 1 4 4 1 1 3 USA5854 412 2 2 1 4 1 3 4 USA5854 512 1 2 4 2 2 1 5 USA5855 100 1 1 0 0 0 0 6 USA5855 200 2 2 1 0 0 0 7 USA5855 312 1 2 0 2 0 0 8 USA5855 412 1 1 2 0 2 1 9 USA5855 512 1 2 0 1 0 0 10 USA5856 100 1 13 3 3 3 What I would like to do is: 1. Identify which column (from 6 to 318) has more than 4 categories (I solved that). In GERU would be rs7696470 and rs7696470.1. 2. Using the columns in step 1, replace its entries equals to 2 for 3. For example, rs7696470 would be 4,4,1,4,0,1,0,3,0,3 and so on. 3. Once replaced the entries, I need to rewrite the columns in GERU. Here is what I've done: # Function to identify columns with 3 or more categories tx=function(x) ifelse(dim(table(x))4,1,0) # Identifying the columns M4=apply(GUPN[,-c(1:6)],2,tx) names(which(MR==1))# Step 1 [1] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901rs1565901.1 rs1565902 [8] rs1565902.1 rs11131334 rs11131334.1 rs1948616 rs1948616.1 rs4484334rs4484334.1 [15] rs1497921rs1497921.1 rs1391320rs1391320.1 rs1497913rs1497913.1 rs996208 [22] rs996208.1 # Step 2 REPLACE=GUPN[,names(which(AR==1))] RES=apply(REPLACE,2,function(x) ifelse(x==2,3,x)) RES[1:10,1:5] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901 1 1 33 3 3 2 1 13 3 3 3 3 31 3 3 4 1 33 3 3 5 0 00 0 0 6 0 00 0 0 7 0 00 0 0 8 0 00 0 0 9 0 00 0 0 101 33 3 1 Now, the problem I have is replacing the columns in GERU by the columns in RES (step 3). At the end the dimension of the new data set should be 3468x318. Any help would be greatly appreciated. Thanks you so much, Jorge [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Replacing columns in a data frame using a previous condition
Is this what you want to do? x - data.frame(a=1:10, b=1:10, c=1:10, d=1:10) z - cbind(c=11:20, d=11:20) z c d [1,] 11 11 [2,] 12 12 [3,] 13 13 [4,] 14 14 [5,] 15 15 [6,] 16 16 [7,] 17 17 [8,] 18 18 [9,] 19 19 [10,] 20 20 x[,colnames(z)] - z[, colnames(z)] x a b c d 1 1 1 11 11 2 2 2 12 12 3 3 3 13 13 4 4 4 14 14 5 5 5 15 15 6 6 6 16 16 7 7 7 17 17 8 8 8 18 18 9 9 9 19 19 10 10 10 20 20 On 2/14/08, Jorge Iván Vélez [EMAIL PROTECTED] wrote: Dear R-list, I'm working with a data frame which dimensions are dim(GERU) [1] 3468 318 and looks like GERU[1:10,1:10] ped ind par1 par2 sex sta rs7696470 rs7696470.1 rs1032896 rs1032896.1 1 USA5854 200 2 1 4 4 1 1 2 USA5854 312 1 1 4 4 1 1 3 USA5854 412 2 2 1 4 1 3 4 USA5854 512 1 2 4 2 2 1 5 USA5855 100 1 1 0 0 0 0 6 USA5855 200 2 2 1 0 0 0 7 USA5855 312 1 2 0 2 0 0 8 USA5855 412 1 1 2 0 2 1 9 USA5855 512 1 2 0 1 0 0 10 USA5856 100 1 13 3 3 3 What I would like to do is: 1. Identify which column (from 6 to 318) has more than 4 categories (I solved that). In GERU would be rs7696470 and rs7696470.1. 2. Using the columns in step 1, replace its entries equals to 2 for 3. For example, rs7696470 would be 4,4,1,4,0,1,0,3,0,3 and so on. 3. Once replaced the entries, I need to rewrite the columns in GERU. Here is what I've done: # Function to identify columns with 3 or more categories tx=function(x) ifelse(dim(table(x))4,1,0) # Identifying the columns M4=apply(GUPN[,-c(1:6)],2,tx) names(which(MR==1))# Step 1 [1] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901rs1565901.1 rs1565902 [8] rs1565902.1 rs11131334 rs11131334.1 rs1948616 rs1948616.1 rs4484334rs4484334.1 [15] rs1497921rs1497921.1 rs1391320rs1391320.1 rs1497913rs1497913.1 rs996208 [22] rs996208.1 # Step 2 REPLACE=GUPN[,names(which(AR==1))] RES=apply(REPLACE,2,function(x) ifelse(x==2,3,x)) RES[1:10,1:5] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901 1 1 33 3 3 2 1 13 3 3 3 3 31 3 3 4 1 33 3 3 5 0 00 0 0 6 0 00 0 0 7 0 00 0 0 8 0 00 0 0 9 0 00 0 0 101 33 3 1 Now, the problem I have is replacing the columns in GERU by the columns in RES (step 3). At the end the dimension of the new data set should be 3468x318. Any help would be greatly appreciated. Thanks you so much, Jorge [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org 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] Principal component analysis PCA
Thanks for the advice. I tried to find the cov of my matrix using R and it ran out of memory. I am not sure how to do double loop to create the covariace matrix? Also is doing prcomp( covariace matrix) the same as finding prcomp( original data ,matrix of snps)? Thanks for your help, Thomas Lumley wrote: On Wed, 13 Feb 2008, Wang, Zhaoming (NIH/NCI) [C] wrote: Try EIGENSTRAT http://www.nature.com/ng/journal/v38/n8/abs/ng1847.html The same approach as EIGENSTRAT is pretty straightforward in R. You need to create the covariance matrix of people (rather than of SNPs) for the 0/1/2 genotype at each SNP and take the principal components of that matrix. In this case the number of individuals is small enough that you should be able to create the covariance matrix directly by matrix operations. In larger data sets where the entire data matrix doesn't fit in memory, you need some sort of double loop. -thomas Zhaoming -Original Message- From: SNN [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 13, 2008 9:14 PM To: r-help@r-project.org Subject: [R] Principal component analysis PCA Hi, I am trying to run PCA on a set of data with dimension 115*300,000. The columns represnt the snps and the row represent the individuals. so this is what i did. #load the data code-read.table(code.txt, sep='\t', header=F, nrows=30) # do PCA # pr-prcomp(code, retx=T, center=T) I am getting the following error message Error: cannot allocate vector of size 275.6 Mb I tried to increase the memory size : memory.size(4000) but it did not work, is there a solution for this ? or is there another software that can handle large data sets. Thanks -- View this message in context: http://www.nabble.com/Principal-component-analysis-PCA-tp15472509p154725 09.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Principal-component-analysis-PCA-tp15472509p15488659.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Replacing columns in a data frame using a previous condition (SOLVED)
Dear R-list, Thanks a lot for your help. Thanks to Jim, Dimitris and Phil. It's exactly what I needed to do. Jorge On 2/14/08, Jorge Iván Vélez [EMAIL PROTECTED] wrote: Dear R-list, I'm working with a data frame which dimensions are dim(GERU) [1] 3468 318 and looks like GERU[1:10,1:10] ped ind par1 par2 sex sta rs7696470 rs7696470.1 rs1032896 rs1032896.1 1 USA5854 200 2 1 4 4 1 1 2 USA5854 312 1 1 4 4 1 1 3 USA5854 412 2 2 1 4 1 3 4 USA5854 512 1 2 4 2 2 1 5 USA5855 100 1 1 0 0 0 0 6 USA5855 200 2 2 1 0 0 0 7 USA5855 312 1 2 0 2 0 0 8 USA5855 412 1 1 2 0 2 1 9 USA5855 512 1 2 0 1 0 0 10 USA5856 100 1 13 3 3 3 What I would like to do is: 1. Identify which column (from 6 to 318) has more than 4 categories (I solved that). In GERU would be rs7696470 and rs7696470.1. 2. Using the columns in step 1, replace its entries equals to 2 for 3. For example, rs7696470 would be 4,4,1,4,0,1,0,3,0,3 and so on. 3. Once replaced the entries, I need to rewrite the columns in GERU. Here is what I've done: # Function to identify columns with 3 or more categories tx=function(x) ifelse(dim(table(x))4,1,0) # Identifying the columns M4=apply(GUPN[,-c(1:6)],2,tx) names(which(MR==1))# Step 1 [1] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901rs1565901.1 rs1565902 [8] rs1565902.1 rs11131334 rs11131334.1 rs1948616 rs1948616.1 rs4484334rs4484334.1 [15] rs1497921rs1497921.1 rs1391320rs1391320.1 rs1497913rs1497913.1 rs996208 [22] rs996208.1 # Step 2 REPLACE=GUPN[,names(which(AR==1))] RES=apply(REPLACE,2,function(x) ifelse(x==2,3,x)) RES[1:10,1:5] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901 1 1 33 3 3 2 1 13 3 3 3 3 31 3 3 4 1 33 3 3 5 0 00 0 0 6 0 00 0 0 7 0 00 0 0 8 0 00 0 0 9 0 00 0 0 101 33 3 1 Now, the problem I have is replacing the columns in GERU by the columns in RES (step 3). At the end the dimension of the new data set should be 3468x318. Any help would be greatly appreciated. Thanks you so much, Jorge [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org 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] Replacing columns in a data frame using a previous condition
try this: GERU[6:318] - lapply(GERU[6:318], function (x) { if (length(unique(x[!is.na(x)])) = 5) x[x == 2] - 3 x }) 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 Quoting Jorge Iván Vélez [EMAIL PROTECTED]: Dear R-list, I'm working with a data frame which dimensions are dim(GERU) [1] 3468 318 and looks like GERU[1:10,1:10] ped ind par1 par2 sex sta rs7696470 rs7696470.1 rs1032896 rs1032896.1 1 USA5854 200 2 1 4 4 1 1 2 USA5854 312 1 1 4 4 1 1 3 USA5854 412 2 2 1 4 1 3 4 USA5854 512 1 2 4 2 2 1 5 USA5855 100 1 1 0 0 0 0 6 USA5855 200 2 2 1 0 0 0 7 USA5855 312 1 2 0 2 0 0 8 USA5855 412 1 1 2 0 2 1 9 USA5855 512 1 2 0 1 0 0 10 USA5856 100 1 13 3 3 3 What I would like to do is: 1. Identify which column (from 6 to 318) has more than 4 categories (I solved that). In GERU would be rs7696470 and rs7696470.1. 2. Using the columns in step 1, replace its entries equals to 2 for 3. For example, rs7696470 would be 4,4,1,4,0,1,0,3,0,3 and so on. 3. Once replaced the entries, I need to rewrite the columns in GERU. Here is what I've done: # Function to identify columns with 3 or more categories tx=function(x) ifelse(dim(table(x))4,1,0) # Identifying the columns M4=apply(GUPN[,-c(1:6)],2,tx) names(which(MR==1))# Step 1 [1] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901rs1565901.1 rs1565902 [8] rs1565902.1 rs11131334 rs11131334.1 rs1948616 rs1948616.1 rs4484334rs4484334.1 [15] rs1497921rs1497921.1 rs1391320rs1391320.1 rs1497913rs1497913.1 rs996208 [22] rs996208.1 # Step 2 REPLACE=GUPN[,names(which(AR==1))] RES=apply(REPLACE,2,function(x) ifelse(x==2,3,x)) RES[1:10,1:5] rs335322 rs335322.1 rs186750 rs186750.1 rs1565901 1 1 33 3 3 2 1 13 3 3 3 3 31 3 3 4 1 33 3 3 5 0 00 0 0 6 0 00 0 0 7 0 00 0 0 8 0 00 0 0 9 0 00 0 0 101 33 3 1 Now, the problem I have is replacing the columns in GERU by the columns in RES (step 3). At the end the dimension of the new data set should be 3468x318. Any help would be greatly appreciated. Thanks you so much, Jorge [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] finding source for a function
RSiteSearch is your friend. E.g.: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/63365.html and then click on 'Next in thread a couple of times Gabor On Thu, Feb 14, 2008 at 03:23:30PM -0600, Edna Bell wrote: Dear R Gurus: How do you get source for functions which say UseMethod when you type in their names, please? I've tried getAnywhere and getMethods...I thought that might produce them. Thanks in advance. Sincerely, Edna __ R-help@r-project.org 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. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org 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] Principal component analysis PCA
On Thu, 14 Feb 2008, SNN wrote: Thanks for the advice. I tried to find the cov of my matrix using R and it ran out of memory. How did you do this? The covariance matrix is only 115x115, so it shouldn't run out of memory cov(t(code)) should work If that doesn't work then tcrossprod(code)/30 - tcrossprod(rowMeans(code)) might. I am not sure how to do double loop to create the covariace matrix? Also is doing prcomp( covariace matrix) the same as finding prcomp( original data ,matrix of snps)? That's the point of the paper behind the EIGENSTRAT software, which is worth reading. The eigenvalues are the same and the eigenvectors are related. One way around gives the left singular vectors of the data matrix, the other gives the right singular vectors. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org 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] finding source for a function
Dear R Gurus: How do you get source for functions which say UseMethod when you type in their names, please? I've tried getAnywhere and getMethods...I thought that might produce them. Thanks in advance. Sincerely, Edna __ R-help@r-project.org 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] write output in a custom format
Thanks for the input! It does work fine, however I'll have to do another loop to repeat this whole process quite a few times (10^3, 10^4 particles maybe), so I was hoping for a solution without loop. Maybe I could reshape all the values into a big array, dump it to a file and replace some values using system(awk...). I just don't really know how to format the data, having different number of values for some lines. Would that be a sensible thing to do? thanks, baptiste On 14 Feb 2008, at 16:49, jim holtman wrote: Here is a start. You basically have to interate through your data and use 'cat' to write it out: particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) output - file(/tempxx.txt, w) cat(particle$dose, \n, file=output, sep= ) for (i in 1:nrow(particle$pos)){ cat(particle$pos$x[i], particle$pos$y[i], \n, file=output, sep= ) } cat(#\n, file=output, sep= ) close(output) Here is what the file looks like: 1 100 0 0 0 1 1 0 0 1 1 # On 2/14/08, baptiste Auguié [EMAIL PROTECTED] wrote: Hi, I need to create a text file in the following format, 1 100.0 0 0 0 1 1 0 0 1 1 # 1 100.0 0 0 0 0 1 1 0 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) print(particle) I'd like to establish a connection to a file and append to it a particle block in the format above, or even write the whole file at once. Because different lines have a different number of elements, I couldn't get write.table to work in this case, and my attempts at sink (), dump(), writeLines(), writeChar() all turn into really dirty solutions. I have this feeling I'm overlooking a simple solution. Any help welcome, baptiste _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org 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] Cholmod error `matrix not positive definite'
Could you tell us which version of the lme4 package you are using? You can just send the output produced by sessionInfo() If you can make your data available so we can test it then please do so. If the data set is large you could send it to me in private email and I will make it available on a web site. I think that the development version of the lme4 package, available via install.packages(lme4, repos = http://r-forge.r-project.org;) should be resistant to that type of error but I am willing to be shown otherwise. On Thu, Feb 14, 2008 at 10:36 AM, Martijn Vandegehuchte [EMAIL PROTECTED] wrote: Dear R-users, I'm new to R, so my apologies if this question doesn't make sense. I've tried the following model in lmer, and it works perfectly: model-lmer(aphids~densroot+zone+(1|zone/site), family=quasipoisson) But if I try the exact same model with a different variable, totmas, the model looks as follows: model-lmer(aphids~totmas+zone+(1|zone/site), family=quasipoisson) Totmas is also a continuous variable just like densroot, but in this case I receive the following message: CHOLMOD warning: ߆e Error in objective(.par, ...) : Cholmod error `matrix not positive definite' at file:../Supernodal/t_cholmod_super_numeric.c, line 613 Moreover, if I test yet another continuous variable vitality, to my surprise R just crashes completely. This is a mystery to me, especially because the variables totmas or vitality don't give any problem when I build the exact same models in SAS with proc glimmix... Does someone have experience with this type of problem? Thank you in advance, Martijn. -- Martijn Vandegehuchte Ghent University Department Biology Terrestrial Ecology Unit K.L.Ledeganckstraat 35 B-9000 Ghent telephone: +32 (0)9/264 50 84 e-mail: [EMAIL PROTECTED] website TEREC: www.ecology.ugent.be/terec [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] setting color ranges
Hi, I need to plot a matrix using image() such that negative values are easily distinguishable from posittive values, while also maintaining a gradation in color with magnitude. How can I set ranges for colors in order to achieve this. Thanks. Sam -- View this message in context: http://www.nabble.com/setting-color-ranges-tp15489086p15489086.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] write output in a custom format
There is nothing wrong with a loop for handling this case. Most of your time is probably going to be spent writing out the files. If you don't want 'for' loops, you can use 'lapply', but I am not sure what type of performance improvement you will see. You are having to make decisions on each particle on how to write it. You can also use awk/perl as you indicated, but you would have to write the data out for those programs. You might take a test run and see. I would guess that by the time you format it for awk and then run awk, you could have done the whole thing in R. But it is your choice and there are plenty of tools to choose from. On 2/14/08, baptiste Auguié [EMAIL PROTECTED] wrote: Thanks for the input! It does work fine, however I'll have to do another loop to repeat this whole process quite a few times (10^3, 10^4 particles maybe), so I was hoping for a solution without loop. Maybe I could reshape all the values into a big array, dump it to a file and replace some values using system(awk...). I just don't really know how to format the data, having different number of values for some lines. Would that be a sensible thing to do? thanks, baptiste On 14 Feb 2008, at 16:49, jim holtman wrote: Here is a start. You basically have to interate through your data and use 'cat' to write it out: particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) output - file(/tempxx.txt, w) cat(particle$dose, \n, file=output, sep= ) for (i in 1:nrow(particle$pos)){ cat(particle$pos$x[i], particle$pos$y[i], \n, file=output, sep= ) } cat(#\n, file=output, sep= ) close(output) Here is what the file looks like: 1 100 0 0 0 1 1 0 0 1 1 # On 2/14/08, baptiste Auguié [EMAIL PROTECTED] wrote: Hi, I need to create a text file in the following format, 1 100.0 0 0 0 1 1 0 0 1 1 # 1 100.0 0 0 0 0 1 1 0 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, particle - list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c (0,1,0,1))) print(particle) I'd like to establish a connection to a file and append to it a particle block in the format above, or even write the whole file at once. Because different lines have a different number of elements, I couldn't get write.table to work in this case, and my attempts at sink (), dump(), writeLines(), writeChar() all turn into really dirty solutions. I have this feeling I'm overlooking a simple solution. Any help welcome, baptiste _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? _ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org 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] non-interactive connection to SQL Server
Yes, it does - thank you! The only thing I forgot (and it took me a while to find this out) was to separate the fields by semicolon, i.e. the correct command is: odbcDriverConnect(driver=SQL Server; database=dataBaseName; wsid=myComputer; server=dataBaseServer; uid=moshe; pwd=moshe) --- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 13 Feb 2008, Moshe Olshansky wrote: Hi everyone, I am afraid that I have already asked this question in the past (or at least I knew an answer to it) but I am unable to do it now. I have an SQL Server data base. I used the GUI interface of odbcDriverConnect to create a .dsn file for this data base and every time I want to connect I invoke odbcDriverConnect() which opens GUI from which I choose my .dsn file and the connection is established. Now I want to do this automatically (without GUI) and all my attempts fail. If I remember correctly the dsn must be a string containing all the connection details but it does not work for me. Clearly it does, as you did that via odbcDriverConnect. Look at the object it returns: it contains the string it used. You can use that directly. Could anybody help, please! Thank you! Moshe. __ R-help@r-project.org 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@r-project.org 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] setting color ranges
Hi Sam, You might find it easier to use ggplot2 to do this. See http://had.co.nz/ggplot2/geom_tile.html for some examples. Hadley On Thu, Feb 14, 2008 at 2:59 PM, samsr [EMAIL PROTECTED] wrote: Hi, I need to plot a matrix using image() such that negative values are easily distinguishable from posittive values, while also maintaining a gradation in color with magnitude. How can I set ranges for colors in order to achieve this. Thanks. Sam -- View this message in context: http://www.nabble.com/setting-color-ranges-tp15489086p15489086.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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. -- http://had.co.nz/ __ R-help@r-project.org 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] data frame question
Create the new data.frame and do the muliplying on it? df2 - df1 df2[,1] - df2[,1]*2 --- joseph [EMAIL PROTECTED] wrote: Hi I have a data frame df1 in which I would like to multiply col1 by 2. The way I did it does not allow me to keep the old data frame. How can I do this and be able to create a new data frame df2? df1= data.frame(col1= c(3, 5, NA, 1), col2= c(4, NA,6, 2)) df1 col1 col2 134 25 NA 3 NA6 412 df1$col1=df1$col1*2 df1 col1 col2 164 2 10 NA 3 NA6 422 Be a better friend, newshound, and [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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 each column of a matrix or dataframe versus x in a single plot
Perhaps matplot will do what you want? ?matplot aa - matrix(1:25, nrow=5) matplot(aa) --- tomaschwutz [EMAIL PROTECTED] wrote: How do a plot several columns of a matrix at once in a single plot versus a single x-variable? The default plot.matrix or plot.dataframe commands plot each column versus each other column in several sub-plots. I want to plot each column versus a single other vector (x) as several lines or points in one plot. I can do it by hand: get the range of all variables (i.e. columns of the matrix or dataframe), initiate an empty plot command, loop through all the columns and issue a lines or points command. I guess there is a predefined sophisticated function for that, however, I was not able to find it. Does someone know where I find such a function? Best regards tomaschwutz __ R-help@r-project.org 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. [[elided Yahoo spam]] __ R-help@r-project.org 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] passing username and password to source()
Phil Spector wrote: Ricardo - The authentication can't be done through environmental variables -- the only way is to send an Authorization header. I believe the environmental variables that Dieter is thinking of are the ones that are created on the server side based on the headers that the user agent sends. - Phil Hi Phil, If I've well understood what you and the other colleagues have said is that whatever the method to write the authorization header I use, it is the only way of accessing programmatically my server. I've installed Live HTTP headers, but I am still far from understanding all the messages in its window. Please, could you point me in the right direction to learn what must I look for in Live HTTP headers log? Any example? Thank you so much, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org 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] forestplot() with large number of confidence intervals
Hi I am using forestplot() in rmeta package on a dataset of 45 point estimates with corresponding confidence intervals. The resulting plot was just too large and plotted out of the graphic window that I can not see whole picture. Is there anyway to fix this problem? Thanks Looking for last minute shopping deals? __ R-help@r-project.org 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] setting color ranges
On Thu, 14 Feb 2008, samsr wrote: Hi, I need to plot a matrix using image() such that negative values are easily distinguishable from posittive values, while also maintaining a gradation in color with magnitude. How can I set ranges for colors in order to achieve this. Thanks. Look at the function diverge_hcl() in package vcd which provides diverging palettes. You can find several examples in example(diverge_hcl, package = vcd) vignette(hcl-colors, package = vcd) Further background information is available in this technical report by Kurt Hornik, Paul Murrell and me http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87 Best, Z Sam -- View this message in context: http://www.nabble.com/setting-color-ranges-tp15489086p15489086.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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] dimnames
?write.table and look at the row.names arguement which is what they are called in this instance. write.table(XX, file=XX.txt,quote=FALSE,sep=\t, row.names=FALSE) --- Roberto Olivares Hernandez [EMAIL PROTECTED] wrote: Hi, I used the write.table function to save data in txt file, and this is the output: V1 V2 V3 V4 1 YAL005C 21 14 11 2 YAL007C 2 1 4 3 YAL012W 8 16 3 4 YAL016W 24 23 23 5 YAL019W 3 3 2 6 YAL020C 2 4 2 7 YAL021C 7 5 5 8 YAL022C 3 1 2 but I need to remove the dimnames (first column) I tried to use dimnames function to remove it and then save it, but still, the output is the same These are the command lines, XX #matrix dimnames(XX)-NULL write.table(XX,XX.txt,quote=FALSE,sep=\t) Thanks in advance Roberto [[alternative HTML version deleted]] __ R-help@r-project.org 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. [[elided Yahoo spam]] __ R-help@r-project.org 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] data frame question
Thanks. I have another question: In the following data frame df, I want to replace all values in col1 that are higher than 3 with NA. df= data.frame(col1=c(1:5, NA),col2= c(2,NA,4:7)) - Original Message From: John Kane [EMAIL PROTECTED] To: joseph [EMAIL PROTECTED]; r-help@r-project.org Cc: r-help@r-project.org Sent: Thursday, February 14, 2008 3:09:40 PM Subject: Re: [R] data frame question Create the new data.frame and do the muliplying on it? df2 - df1 df2[,1] - df2[,1]*2 --- joseph [EMAIL PROTECTED] wrote: Hi I have a data frame df1 in which I would like to multiply col1 by 2. The way I did it does not allow me to keep the old data frame. How can I do this and be able to create a new data frame df2? df1= data.frame(col1= c(3, 5, NA, 1), col2= c(4, NA,6, 2)) df1 col1 col2 1 3 4 2 5 NA 3 NA 6 4 1 2 df1$col1=df1$col1*2 df1 col1 col2 1 6 4 2 10 NA 3 NA 6 4 2 2 Be a better friend, newshound, and [[alternative HTML version deleted]] __ R-help@r-project.org 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. Connect with friends from any web browser - no download required. Try the new Canada Messenger for the Web BETA at Looking for last minute shopping deals? [[alternative HTML version deleted]] __ R-help@r-project.org 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] Retrieving data frames from a for loop
Dear R-helpers, I need to retrieve the data frames generated in a for loop. What I have looks something like this: where tab is a pre-existing data frame. for (i in 1:20) { g-sample(rep(LETTERS[1:2],each=10)) combination-data.frame(tab,g) } I tried to name every single combination doing this: assign(paste('combination',i), combination) without success. I need to retrieve every combination per separate. Thank you once again for your help. Looking for last minute shopping deals? __ R-help@r-project.org 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] LMER
Hi, I run the following models: 1a. lmer(Y~X+(1|Subject),family=binomial(link=logit)) and 1b. lmer(Y~X+(1|Subject),family=binomial(link=logit),method=PQL) Why does 1b produce results different from 1a? The reason why I am asking is that the help states that PQL is the default of GLMMs and 2. gamm(Y~X,family=binomial(link=logit),random=list(Subject=~1)) The interesting thing about the example below is, that gamm is also supposed to fit by PQL. Interestingly, however, the GAMM fit yields about the coefficient estimates of 1b. But the significance values of 1a. Any insight would be greatly appreciated. library(lme4) library(mgcv) Y=c(0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1) X=c(1,2,3,4,3,1,0,0,2,3,3,2,4,3,2,1,1,3,4,2,3) Subject=as.factor(c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7)) cbind(Y,X,Subject) r1=lmer(Y~X+(1|Subject),family=binomial(link=logit)) summary(r1) r2=lmer(Y~X+(1|Subject),family=binomial(link=logit),method=PQL) summary(r2) r3=gamm(Y~X,family=binomial(link=logit),random=list(Subject=~1)) summary(r3$gam) - cuncta stricte discussurus __ R-help@r-project.org 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] Questions about EM algorithm
Dear all: Assume I have 3 distributions, x1, x2, and x3. x1 ~ normal(mu1, sd1) x2 ~ normal(mu2, sd2) x3 ~ normal(mu3, sd3) y1 = x1 + x2 y2 = x1 + x3 Now that the data I can observed is only y1 and y2. It is easy to estimate (mu1+m2), (mu1+mu3), (sd1^2+sd2^2) and (sd1^2+sd3^2) by EM algorithm since y1 ~ normal(mu1+mu2, sqrt(sd1^2+sd2^2)) and y2 ~ normal(mu1+mu3, sqrt(sd1^2+sd3^2)) However, I want to estimate mu1, mu2, mu3, sd1, sd2, and sd3. Is it possible to do so by EM algorithm (or any other estimation methods like gibbs sampling or MLE) ? Anyone can give me some sample code or suggestions? Thanks a lot in advance. __ R-help@r-project.org 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] Quantile Regression R squared
Dear R, I am currently trying to caculate the coefficient of determination for different quantile regression models. For example fit-rq(Hrubra~SessileInvertebrates,tau=0.8, data=Q1) fit1-rq(Hrubra~SessileInvertebrates,tau=0.8, data=Q2) etc Could someone please advise me how do you calculate the the sum of the weighted absolute deviations in the models for the formula R = 1-(Sum(f)/Sum(r)) I have looked all through the help files but the only example I can find is in Stata. Thanks in advance Beth Strain _ Your Future Starts Here. Dream it? Then be it! Find it at www.seek.com.au %2F%3Ftracking%3Dsk%3Ahet%3Ask%3Anine%3A0%3Ahot%3Atext_t=764565661_r=OCT07_endtext_Future_m=EXT [[alternative HTML version deleted]] __ R-help@r-project.org 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] Problems with Rcmdr unter JGR (Windows XP)
Willi Nagl willi.nagl at gmail.com writes: I try to start Rmcdr from JGR. The Rmcdr-Windows comes up correctly; but the Menu-Bar in the Rcmdr-Window goes away, if I try to go into the Rmcdr-Window. I hope, someone has a solution. Regards, willi My experience is that, under Windows, you cannot run Rcmdr with either JGR or (X)Emacs/ESS. From John Fox's own 'An Introduction to ESS + XEmacs for Windows Users of R': The Rcmdr package does not run reliably under XEmacs/ESS for Windows. I get the same instability (Rcmdr not responding and then R crashing) with Rcmdr and JGR. Under Linux, I have had Emacs/ESS and Rcmdr running together. I don't know about JGR, as I don't presently have it installed on a Linux box. If you want to use Rcmdr under Windows, the combination of R-Gui, Tinn-R and Rcmdr works well. Michael Bibo Research Officer Queensland Health __ R-help@r-project.org 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] Retrieving data frames from a for loop
Use a 'list' to capture the data within the loop: result - vector('list', 20) # preallocate tab - data.frame(x=1:20) for (i in 1:20) { + + g-sample(rep(LETTERS[1:2],each=10)) + result[[i]] -data.frame(tab,g) + + } # you can now access the combinations like this: result[[1]] x g 1 1 B 2 2 A 3 3 B 4 4 B 5 5 B 6 6 B 7 7 A 8 8 B 9 9 A 10 10 B 11 11 A 12 12 B 13 13 B 14 14 A 15 15 A 16 16 A 17 17 A 18 18 B 19 19 A 20 20 A result[[5]] x g 1 1 B 2 2 A 3 3 B 4 4 B 5 5 A 6 6 A 7 7 B 8 8 A 9 9 B 10 10 A 11 11 B 12 12 A 13 13 B 14 14 B 15 15 B 16 16 A 17 17 A 18 18 A 19 19 A 20 20 B On Thu, Feb 14, 2008 at 6:42 PM, Judith Flores [EMAIL PROTECTED] wrote: Dear R-helpers, I need to retrieve the data frames generated in a for loop. What I have looks something like this: where tab is a pre-existing data frame. for (i in 1:20) { g-sample(rep(LETTERS[1:2],each=10)) combination-data.frame(tab,g) } I tried to name every single combination doing this: assign(paste('combination',i), combination) without success. I need to retrieve every combination per separate. Thank you once again for your help. Looking for last minute shopping deals? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org 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 plot fitted values from lmer (lme4 package)?
I am modelling (at least trying to) the seasonal component of a variable using lmer. I think I am just about getting the hang of building the models but want to see what the fitted values look like. I need to plot 2 lines on the same graph - the original data ( copy of dataframe below) and the fitted values. I am doing this to a) start to understand how to use R and b) start to understand how to build and compare models. I have been using books (e.g. The R Book Michael Crawley) and pdf (e.g. time series analysis with R part 1 – Walter Zuccchini and Oleg Nenadic) for reference and if the answer is there (which it probably is) I can’t understand it (I have a very slow dial up connection so even searching nabble frequently crashes)! An example of the model is: Scale the annual cycle to be length 1.0:- with(a_dataframe,length(mean_ind)) [1] 15 index-1:15 15/4 [1] 3.75 time-index/3.75 Model (index used as explanatory variable for trend, also allows different intercepts for years as a random effect – I hope):- mtrend-lmer(byquarter$mean_ind~index+sin(time*2*pi)+cos(time*2*pi)+(1|factor(byquarter$YEAR)),method=ML) using “lm” I followed the following process to produce the graph I wanted. lmodel-with(a_dataframe,lm(mean_ind~sin(time*2*pi)+cos(time*2*pi))) plot(time,adataframe$mean_ind,pch=.) lines(time,predict(lmodel)) How can I do the same with lmer? I have tried a variety of things with “predict”, trying to put the results from lmer as a “groupedData” object etc. But I can’t seem to make it work. Any simple solutions? Many thanks for any help. Sample data a_dataframe below (I removed NULL rows so row references are not concsequtive):- YEAR_QUARTER YEAR a_mean 12004_2 2004 71.46154 22004_3 2004 56.3 32004_4 2004 37.9 19 2005_1 2005 37.0 20 2005_2 2005 88.4 21 2005_3 2005 87.28571 22 2005_4 2005 43.75000 38 2006_1 2006 50.85714 39 2006_2 2006 142.25000 40 2006_3 2006 137.57143 41 2006_4 2006 79.86667 57 2007_1 2007 73.1 58 2007_2 2007 146.28571 59 2007_3 2007 118.07692 60 2007_4 2007 73.5 -- View this message in context: http://www.nabble.com/How-to-plot-fitted-values-from-lmer-%28lme4-package%29--tp15492920p15492920.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Remove rows with NA across all columns
Hi I have a data frame df with 3 columns. Some rows are NA across all 3 columns. How can I remove rows with NA across all columns? df=data.frame(col1=c(1:3,NA,NA,4),col2=c(7:9,NA,NA,NA),col3=c(2:4,NA,NA,4)) Thanks Joseph Be a better friend, newshound, and [[alternative HTML version deleted]] __ R-help@r-project.org 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] Remove rows with NA across all columns
Learn to use the power and flexibility of R subscripting. ## Warning:untested apply(df,1,function(x)any(!is.na(x))) gives TRUE for all rows that aren't all NA's. So stick this expression into the 1st coordinate of a subscript for the df: df[apply(df,1,function(x)any(!is.na(x))),] Cheers, Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of joseph Sent: Thursday, February 14, 2008 8:53 PM To: r-help@r-project.org Cc: r-help@r-project.org Subject: [R] Remove rows with NA across all columns Hi I have a data frame df with 3 columns. Some rows are NA across all 3 columns. How can I remove rows with NA across all columns? df=data.frame(col1=c(1:3,NA,NA,4),col2=c(7:9,NA,NA,NA),col3=c(2:4,NA,NA,4)) Thanks Joseph Be a better friend, newshound, and [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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 trieving data frames from a for loop
Have you tried making a list of data frames instead? So data.list-list() for (i in 1:20) { g-sample(rep(LETTERS[1:2],each=10)) #make a name a.name-paste(combination,i,sep=) #add it to the list of data frames data.list[[a.name]]-data.frame(tab,g) } This should be easier to iterate over later. Judith Flores wrote: Dear R-helpers, I need to retrieve the data frames generated in a for loop. What I have looks something like this: where tab is a pre-existing data frame. for (i in 1:20) { g-sample(rep(LETTERS[1:2],each=10)) combination-data.frame(tab,g) } I tried to name every single combination doing this: assign(paste('combination',i), combination) without success. I need to retrieve every combination per separate. Thank you once again for your help. Looking for last minute shopping deals? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Retrieving-data-frames-from-a-for-loop-tp15492093p15495242.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] tests of lognormal distribution in R
Hi all, I have a data of lognormal distribution (sample size 1,000,000). What I want to do is 1) to test if my dataset is a lognormal distribution or not (Histogram shows a nice normal distribution in log scale but I want to check) 2) two subsets from this dataset have same mean or not (like t test of normal distribution) What I tried are 1) ad.test{truncgof} of R, which is a Supremum Class Anderson-Darling test but I got error message. What I had problems are 1) Memory error happen with error message of cannot allocate vector of size 1.0GB and I cannot increase the computer spec. 2) I don't know what is t test of lognormal. What I am thinking is 1) Is it OK to convert the data in log scale and do perform t test to say these dataset has same mean? How can I solve my problem? Thank you for any comments. Hyunchul [[alternative HTML version deleted]] __ R-help@r-project.org 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.