[R] Bugs through R in Mac
Hello, I recently changed from Win XP to Mac OS X (10.5.1). Is there a way to run Bugs (in any version) in R (R version 2.6.0 (2007-10-03)) on this platform? Fredrik __ 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.
Newsletter: Vielen dank f�r ihre Anmeldung!
Hallo, Ihre E-Mailadresse [EMAIL PROTECTED] wurde in den Newsletterverteiler hinzugefügt. URL: http://www.fueralles.de/cgi-bin/nsl_pro/newsletter.cgi?id=steinfeuerfred Mit freundlichen Grüssen Ihr Newsletter-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.
Re: [R] Bugs through R in Mac
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Fredrik Lundgren wrote: Hello, I recently changed from Win XP to Mac OS X (10.5.1). Is there a way to run Bugs (in any version) in R (R version 2.6.0 (2007-10-03)) on this platform? Which way to run Bugs in R did you use in Windows? On MacOS X, a solution that should work but is completely inelegant is using the package R2WinBUGS, and running WinBUGS within DarWINE. There are some rumors that OpenBUGS development will be forced within the next couple of months, but I am not that confident that we will have a natively working BRugs version on Mac OS X or Linux this year ... There has been a discussion between Rodney Sparapani and Gregor Gorjanc some time ago on the sourceforge mailing list bugs-r-devel (project bugs-r) you might want to check out. Uwe Ligges Fredrik __ 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] Looping over subsets
Can you provide an example of what you would like to do. Show what a full set (on a small scale would be) and then how you would select the subsets and then what type of processing you would like to do (PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.) On 20 Jan 2008 06:53:45 +, Z. Fang [EMAIL PROTECTED] wrote: Hi, Possibly a dumb question, but I wonder if anyone can help me with this. What I want to do, essentially, is to loop over all ordered subsets of a given size of a certain set. Ultimately, the idea is to find the subset that maximises a certain value. The set in question is likely large (the subset size is likely small, though), so things like combn don't seem to be a good solution. The biggest concern is keeping memory usage sane, but processing time is also fairly important. Any ideas? Zhou Fang __ 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] spacing problems
Dear all, I try to do a matrix with this data but the warning massage had occur: In matrix(x5, ncol = 6, byrow = T) : data length [116] is not a sub-multiple or multiple of the number of rows [20] I think the spacing problem cause this where double spacing and tabs are everywhere!! Secondly, I have a raw data (which i downloaded from the AutoGraph server) where it has 2 data in one text file. How am i going to split it to two?? I also need to make a command function so that i can do it for the other 38 similar types of data. Below show my command function and attach with is my data. Kindly help me to solve these problems and thanks in advance. fun-function(filename) { x-scan(file=filename,sep=\n,skip=12,what=character(0)) x1-gsub([][)(:\\,|\\-],,x) x2-gsub(Telomere,NA,x1) x3-gsub(Decreasing order|Increasing order,,x2) x4-strsplit(x3,\t) x5-unlist(x4) y-matrix(x5,ncol=6,byrow=T) tc-textConnection(apply(y,1,paste,collapse= )) w-read.table(tc) t-as.data.frame(w) attr(t,names)=c(CS(O),id,no.anchor,ref,loc.start,loc.end,CS(O).size,CS(O)ref.density,tested,loc.start,loc.end,breakp.start,breakp.end,den of anchor) return(t) } Cheers, Anisah - AutoGRAPH analysis in a flat-file format ( CS(O) locations, size, breakpoints...): -- Reference Chromosome vs Dataset 3 - CS(O) id (number of marker/anchor) Location(s) on reference CS(O) size CS(O) density on reference chromosome Location(s) on tested Breakpoints CS(O) locations (denstiy of marker/anchor) CS 1 (27): cfa1: [ 3251712 - 12398289 ] 91465773 mmu18: [ 24330828 - 90644456 ] ] 12398289, 13347136 [(2 ) CS 2 (19): cfa1: [ 13347136 - 18193820 ]48466844 mmu1: [ 113688560 - 106596368 ]] 18193820, 19140840 [(3 ) CSO 3.1 (18):cfa1: [ 19140840 - 22178912 ] 3038072 6 mmu18: [ 66984412 - 63788168 ]- Decreasing order -] 22178912, 23188292 [ (2 ) CSO 3.2 (4): cfa1: [ 23188292 - 24126920 ] 938628 4 mmu18: [ 69469888 - 70578512 ]- Increasing order -] 24126920, 24190392 [(8 ) CS 4 (2):cfa1: [ 24190392 - 24265894 ]75502 26 mmu18: [ 70634048 - 70693560 ] ] 24265894, 24823786 [(7 ) CSO 5.1 (6): cfa1: [ 24823786 - 27113036 ] 2289250 3 mmu18: [ 71384360 - 73984760 ]- Increasing order -] 27113036, 27418228 [ (13 ) CSO 5.2 (4): cfa1: [ 27418228 - 27578150 ] 159922 25 mmu18: [ 68532272 - 68058624 ]- Decreasing order -] 27578150, 28055666 [(9 ) CS 6 (77): cfa1: [ 28055666 - 47327576 ]19271910 4 mmu10: [ 24284924 - 3134304 ] ] 47327576, 47940412 [(5 ) CSO 7.1 (15):cfa1: [ 47940412 - 51570228 ] 3629816 4 mmu17: [ 3283055 - 7577392 ]- Increasing order - ] 51570228, 51988448 [ (11 ) CSO 7.2 (16):cfa1: [ 51988448 - 57900888 ] 5912440 3 mmu17: [ 12850771 - 8003706 ]- Decreasing order - ] 57900888, 58482632 [ (11 ) CSO 7.3 (5): cfa1: [ 58482632 - 59714992 ] 1232360 4 mmu17: [ 13497139 - 14565909 ]- Increasing order -] 59714992, 59864308 [(15 ) CSO 8.1 (8): cfa1: [ 59864308 - 60129744 ] 265436 30 mmu10: [ 33840808 - 33608556 ]- Decreasing order -] 60129744, 60211840 [ (17 ) CSO 8.2 (21):cfa1: [ 60211840 - 65147456 ] 4935616 4 mmu10: [ 51273836 - 57483016 ]- Increasing order -] 65147456, 65273344 [ (7 ) CSO 8.3 (21):cfa1: [ 65273344 - 72417520 ] 7144176 3 mmu10: [ 33201750 - 24858506 ]- Decreasing order -] 72417520, 73256040 [(7 ) CS 9 (24): cfa1: [ 73256040 - 78879792 ]56237524 mmu13: [ 64301608 - 58167304 ] ] 78879792, 79088752 [(10 ) CS 10 (3): cfa1: [ 79088752 - 80616144 ]15273922 mmu4: [ 73484664 - 71603504 ] ] 80616144, 82195232 [(2 ) CS 11 (58): cfa1: [ 82195232 - 96913624 ]14718392 4 mmu19: [ 14515091 - 29676192 ] ] 96913624, 97163832 [(8 ) CS 12 (10): cfa1: [ 97163832 - 99948816 ]27849844 mmu13: [ 53424904 - 51664268 ] ] 99948816, 100087840 [(9 ) CSO 13.1 (4):cfa1: [ 100087840 - 100423328 ] 335488 12 mmu13: [ 51443540 - 51113392 ]- Decreasing order -] 100423328, 101013264 [ (11 ) CSO 13.2 (17): cfa1: [ 101013264 - 102120080 ] 1106816 15 mmu13: [ 48589808 - 49694080 ]- Increasing order -] 102271920, 102458192 [(25 ) CSO 14.1 (10): cfa1: [ 102458192 - 104863664 ] 2405472 4 mmu7: [ 11943329 - 5734576 ]- Decreasing order - ] 104863664, 105135376 [ (35 ) CSO 14.2 (37): cfa1: [ 105135376 - 106177648 ]
[R] Newsletter: Ihre E-Mailadresse wurde ausgetragen.
Hallo, Ihre E-Mailadresse [EMAIL PROTECTED] wurde aus dem Verteiler entfernt. URL: http://www.fueralles.de/cgi-bin/nsl_pro/newsletter.cgi?id=steinfeuerfred Mit freundlichen Grüssen Ihr Newsletter-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.
Re: [R] problems with .svg
Yes, try another mirror. Austria should work. Or go to http://cran.at.r-project.org/src/contrib/PACKAGES.html and download the package directly and install it via R CMD INSTALL package_file You might need to give the '-l' options for where to install to. G. On Sun, Jan 20, 2008 at 03:49:22PM +0100, Mag. Ferri Leberl wrote: Thank you so far. install.packages(RSvgDevice, dependencies = TRUE) returns Warnung in install.packages(RSvgDevice, dependencies = TRUE) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' Warnung in install.packages(RSvgDevice, dependencies = TRUE) : 'lib = /usr/local/lib/R/site-library' is not writable Would you like to create a personal library '~/R/i486-pc-linux-gnu-library/2.5' to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE) When asked I chose for the Bamberg-mirror. Can you recognize a mistake? Should I chose for a different mirror? Thank you in advance. Yours, Mag. Ferri Leberl Am Montag, den 14.01.2008, 19:21 +0100 schrieb Gabor Csardi: Are you sure this is an R problem? I guess it is not, but rather a pstoedit problem. You can use the RSVGDevice package, or the Cairo package to export your graphics directly into SVG from R. Gabor On Mon, Jan 14, 2008 at 07:10:13PM +0100, Mag. Ferri Leberl wrote: Dear everybody! I am making a graph in R and employ pstoedit to expot the .pdf-output to .svg. When I open the .svg with firefox I get the .svg-code shown wit the following header: Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt. Which information should how be included? Thank you in advance. Yours, Mag. Ferri Leberl __ 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.
[R] model selection method - step() or bic.glm()
Dear R-helpers, I'm considering two methods of selecting a poisson regression model within R: 1. Using the step() function (stats package) to find the best model by a stepwise algorithm and AIC 2. Using the bic.glm() function (BMA package) to find the best model by Bayesian Model Averaging and BIC Are these both reasonable methods for model selection or is one clearly more appropriate than the other? I understand this is more of a stats question than an R software question, but I hope someone can help. Thanks in advance. Best wishes, Des [[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] sorting
Hi, I want to sort my matrix according to (any) selected column. For example given matrix: x [,1] [,2] [,3] [1,]347 [2,]258 [3,]169 I want to sort the first column in ascending order and make the other columns follow the 'new order' like: x1 [,1] [,2] [,3] [1,]169 [2,]258 [3,]347 thank in advance for help. best -- View this message in context: http://www.nabble.com/sorting-tp14983068p14983068.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] (sem assunto)
Dear Edison, There are several approaches you could take. One would be to use a component+residual plot (see the cr.plots function in the car package, which has a method for glm objects, including logistic regression), although that doesn't provide a test. Another approach would be to fit a nonparametric regression model, such as a generalized additive model (see the mgcv and gam packages), with smooth terms in place of linear terms, which can be used to test linearity. I hope this helps, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Edison Iglesias de Oliveira Vidal Sent: January-19-08 5:31 PM To: r-help@r-project.org Subject: [R] (sem assunto) I have been searching without success to find out how to test for the assumption of linear relationship between the indenpendent variables and the logit of the dependent variable in multiple logistic regression models using R. I shall be glad for any advice. best regards, Edison Iglesias de Oliveira Vidal, MD Home Care Department, Hospital Israelita Albert Einstein Sco Paulo, Brazil _ Cansado de espago para ss 50 fotos? Conhega o Spaces, o site de relac[[elided trailing spam]] [[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] sorting
On 20/01/2008 10:50 AM, threshold wrote: Hi, I want to sort my matrix according to (any) selected column. For example given matrix: x [,1] [,2] [,3] [1,]347 [2,]258 [3,]169 I want to sort the first column in ascending order and make the other columns follow the 'new order' like: x1 [,1] [,2] [,3] [1,]169 [2,]258 [3,]347 thank in advance for help. See ?order. o - order(x[,1]) x1 - x[o,] Duncan Murdoch __ 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 .svg
The program does not open the interface again to select am mirror. Neither works install.packages(RSvgDevice, dependencies = TRUE, repos=http://cran.r-project.org,contriburl=http://cran.r-project.org;) the feedback here is Warnung in install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, : argument 'lib' is missing: using '/home/nemo/R/i486-pc-linux-gnu-library/2.5' Warnung: unable to access index for repository http://cran.r-project.org Warning message: package âRSvgDeviceâ is not available in: install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, What is going wrong? Yours, Leberl Am Sonntag, den 20.01.2008, 16:34 +0100 schrieb Gabor Csardi: Yes, try another mirror. Austria should work. Or go to http://cran.at.r-project.org/src/contrib/PACKAGES.html and download the package directly and install it via R CMD INSTALL package_file You might need to give the '-l' options for where to install to. G. On Sun, Jan 20, 2008 at 03:49:22PM +0100, Mag. Ferri Leberl wrote: Thank you so far. install.packages(RSvgDevice, dependencies = TRUE) returns Warnung in install.packages(RSvgDevice, dependencies = TRUE) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' Warnung in install.packages(RSvgDevice, dependencies = TRUE) : 'lib = /usr/local/lib/R/site-library' is not writable Would you like to create a personal library '~/R/i486-pc-linux-gnu-library/2.5' to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: package âRSvgDeviceâ is not available in: install.packages(RSvgDevice, dependencies = TRUE) When asked I chose for the Bamberg-mirror. Can you recognize a mistake? Should I chose for a different mirror? Thank you in advance. Yours, Mag. Ferri Leberl Am Montag, den 14.01.2008, 19:21 +0100 schrieb Gabor Csardi: Are you sure this is an R problem? I guess it is not, but rather a pstoedit problem. You can use the RSVGDevice package, or the Cairo package to export your graphics directly into SVG from R. Gabor On Mon, Jan 14, 2008 at 07:10:13PM +0100, Mag. Ferri Leberl wrote: Dear everybody! I am making a graph in R and employ pstoedit to expot the .pdf-output to .svg. When I open the .svg with firefox I get the .svg-code shown wit the following header: Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt. Which information should how be included? Thank you in advance. Yours, Mag. Ferri Leberl __ 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] problems with .svg
On Sun, 20 Jan 2008, Mag. Ferri Leberl wrote: The program does not open the interface again to select am mirror. Neither works install.packages(RSvgDevice, dependencies = TRUE, repos=http://cran.r-project.org,contriburl=http://cran.r-project.org;) the feedback here is Warnung in install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, : argument 'lib' is missing: using '/home/nemo/R/i486-pc-linux-gnu-library/2.5' Warnung: unable to access index for repository http://cran.r-project.org Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, What is going wrong? You incorrectly specified contriburl: you only need repos, and giving contriburl incorrectly is the reason for the message you got. I suspect chooseCRAN mirror() failed because the CRAN master was inaccessible: it has been from here on and off all day. In which case you will need to select a different mirror. Yours, Leberl Am Sonntag, den 20.01.2008, 16:34 +0100 schrieb Gabor Csardi: Yes, try another mirror. Austria should work. Or go to http://cran.at.r-project.org/src/contrib/PACKAGES.html and download the package directly and install it via R CMD INSTALL package_file You might need to give the '-l' options for where to install to. G. On Sun, Jan 20, 2008 at 03:49:22PM +0100, Mag. Ferri Leberl wrote: Thank you so far. install.packages(RSvgDevice, dependencies = TRUE) returns Warnung in install.packages(RSvgDevice, dependencies = TRUE) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' Warnung in install.packages(RSvgDevice, dependencies = TRUE) : 'lib = /usr/local/lib/R/site-library' is not writable Would you like to create a personal library '~/R/i486-pc-linux-gnu-library/2.5' to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE) When asked I chose for the Bamberg-mirror. Can you recognize a mistake? Should I chose for a different mirror? Thank you in advance. Yours, Mag. Ferri Leberl Am Montag, den 14.01.2008, 19:21 +0100 schrieb Gabor Csardi: Are you sure this is an R problem? I guess it is not, but rather a pstoedit problem. You can use the RSVGDevice package, or the Cairo package to export your graphics directly into SVG from R. Gabor On Mon, Jan 14, 2008 at 07:10:13PM +0100, Mag. Ferri Leberl wrote: Dear everybody! I am making a graph in R and employ pstoedit to expot the .pdf-output to .svg. When I open the .svg with firefox I get the .svg-code shown wit the following header: Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt. Which information should how be included? Thank you in advance. Yours, Mag. Ferri Leberl __ 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]] -- 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] Bugs through R in Mac
You could try JAGS. According to the website it is 'an engine for the BUGS language that runs on Unix'. It runs on Mac OS X and has an interface with R (rjags). http://www-fis.iarc.fr/~martyn/software/jags/ Vincent On Jan 20, 5:58 am, Uwe Ligges [EMAIL PROTECTED] wrote: hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Fredrik Lundgren wrote: Hello, I recently changed from Win XP to Mac OS X (10.5.1). Is there a way to run Bugs (in any version) in R (R version 2.6.0 (2007-10-03)) on this platform? Which way to run Bugs in R did you use in Windows? On MacOS X, a solution that should work but is completely inelegant is using the package R2WinBUGS, and running WinBUGS within DarWINE. There are some rumors that OpenBUGS development will be forced within the next couple of months, but I am not that confident that we will have a natively working BRugs version on Mac OS X or Linux this year ... There has been a discussion between Rodney Sparapani and Gregor Gorjanc some time ago on the sourceforge mailing list bugs-r-devel (project bugs-r) you might want to check out. Uwe Ligges Fredrik __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [EMAIL PROTECTED] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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] access data inside package
have you tried data() instead? b On Jan 20, 2008, at 3:21 PM, Dan Kelley wrote: The technique d - get(d, pos=globalenv()) doesn't work for me. It just says that it cannot get d, even though I have a data/d.rda file. Do I have to do something special with namespaces, to find it? PS. a possibly-related link is as follows. http://www.nabble.com/how-to-make-read-only-data-frames--tp14756183p14756183.html -- View this message in context: http://www.nabble.com/access-data-inside-package-tp14565386p14986337.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] access data inside package
The technique d - get(d, pos=globalenv()) doesn't work for me. It just says that it cannot get d, even though I have a data/d.rda file. Do I have to do something special with namespaces, to find it? PS. a possibly-related link is as follows. http://www.nabble.com/how-to-make-read-only-data-frames--tp14756183p14756183.html -- View this message in context: http://www.nabble.com/access-data-inside-package-tp14565386p14986337.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] access data inside package
Yes, data() works, but then I have this warning from R CMD check on my package, so I think I should not be doing it that way. Benilton Carvalho wrote: have you tried data() instead? b -- View this message in context: http://www.nabble.com/access-data-inside-package-tp14565386p14986576.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] access data inside package
then combine system.file() with load(). b On Jan 20, 2008, at 3:40 PM, Dan Kelley wrote: Yes, data() works, but then I have this warning from R CMD check on my package, so I think I should not be doing it that way. Benilton Carvalho wrote: have you tried data() instead? b -- View this message in context: http://www.nabble.com/access-data-inside-package-tp14565386p14986576.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.
[R] Res: distance matrix
Like this? my.points-data.frame(cbind(x=c(1,10,50,100,1,20,10,100),y=c(1,5,20,50,100,1,1,10))) rownames(my.points)-paste(pt,1:8,sep=) plot(my.points) text((my.points+2),rownames(my.points),col=red) require(vegan) my.points.dist-vegdist(my.points,method=euclidean) my.points.dist kind regards, miltinho - Mensagem original De: WCD [EMAIL PROTECTED] Para: r-help@r-project.org Enviadas: Domingo, 20 de Janeiro de 2008 17:41:45 Assunto: [R] distance matrix Hello, I want do get the point to point distance matrix. Suppose, I have a data frame where the first column is X and second column is Y coordinate of points. I define a function dst(x1,y1,x2,y2) to claculate distance between two points. But I don't know how to tell R to calculate dst for every two points and create a matrix of these distances. Can you give me a little guidance, please? I am quite new to R and programming. Thanks for every advice. Filip Kral. -- View this message in context: http://www.nabble.com/distance-matrix-tp14986595p14986595.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. para armazenamento! [[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] access data inside package
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO First call data(d) then everything is fine already - except that codetools are moaning around. Those codetools can be calmed down by the line we had already: d - get(d, pos=globalenv()) Uwe Ligges Dan Kelley wrote: Yes, data() works, but then I have this warning from R CMD check on my package, so I think I should not be doing it that way. Benilton Carvalho wrote: have you tried data() instead? b __ 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] distance matrix
Suppose you have: x - runif(25) y - rnorm(25) x.df - data.frame(x,y) dist(x.df) The default is euclidean distance. Hope this helps! Sincerely, Erin On Jan 20, 2008 2:41 PM, WCD [EMAIL PROTECTED] wrote: Hello, I want do get the point to point distance matrix. Suppose, I have a data frame where the first column is X and second column is Y coordinate of points. I define a function dst(x1,y1,x2,y2) to claculate distance between two points. But I don't know how to tell R to calculate dst for every two points and create a matrix of these distances. Can you give me a little guidance, please? I am quite new to R and programming. Thanks for every advice. Filip Kral. -- View this message in context: http://www.nabble.com/distance-matrix-tp14986595p14986595.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. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ 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] access data inside package
My R CMD check gives me fit.tide: no visible binding for global variable ‘tideconst’ when I do load(paste(system.file(package=oce),data/tidesetup.rda,sep=/)) ... try to use tideconst ... where tidesetup.rda holds, among other things, a variable named tideconst. I guess I can see why -- there is nothing in the file name that tells which variables are contained therein. I'm sorry to be a bother on this. -- View this message in context: http://www.nabble.com/access-data-inside-package-tp14565386p14986948.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] access data inside package
Thanks, Uwe, this works perfectly. Uwe Ligges-3 wrote: hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO First call data(d) then everything is fine already - except that codetools are moaning around. Those codetools can be calmed down by the line we had already: d - get(d, pos=globalenv()) Uwe Ligges Dan Kelley wrote: Yes, data() works, but then I have this warning from R CMD check on my package, so I think I should not be doing it that way. Benilton Carvalho wrote: have you tried data() instead? b __ 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/access-data-inside-package-tp14565386p14987387.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] changing color scheme in R in UNIX
Hi, I've been using R in Windows but am now starting to use it more often in the UNIX environment. In Windows, I'm used to the text provided by the user appearing in red, and the output from R appearing in blue. Is there a way to achieve this in UNIX? Thanks, Andrew [[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] access data inside package
On 20/01/2008 3:21 PM, Dan Kelley wrote: The technique d - get(d, pos=globalenv()) doesn't work for me. It just says that it cannot get d, even though I have a data/d.rda file. Do I have to do something special with namespaces, to find it? PS. a possibly-related link is as follows. http://www.nabble.com/how-to-make-read-only-data-frames--tp14756183p14756183.html If you put it in data/d.rda, then it doesn't get loaded until you request it via a call to data(). That's why the get() doesn't work. I think you have two choices: In some file in your R directory, create the object d. You might do this by putting the file into inst/something and loading it from there, or you might just include R source that creates it. Alternatively, put it in the special sysdata.rda file in the R directory. See Writing R Extensions Package Subdirectories for instructions. You probably want to specify LazyLoad: yes for your package, so that objects don't take up memory until actually referenced. In either of these cases, the object d will be visible to users as soon as your package is loaded. If you don't want that, you should use a namespace for your package. Duncan Murdoch __ 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] image/area plot
Perhaps: kk=data.frame(fact=letters[1:10], freq=c(5,1,10,2,10,7,5,10,30,20)) res - rep(kk[[1]], kk[[2]]) resmat - matrix(c(res), 10) image(1:10, 1:10, resmat, col=rainbow(20)) grid(ncol(resmat), nrow(resmat)) ##1 text(expand.grid(seq_len(ncol(resmat)), seq_len(nrow(resmat))), as.character(res)) ##2 pos - lapply(apply(apply(resmat, 2, duplicated), 2, function(x)which(!x)), append, 11) for(j in 1:length(pos)){ rect(pos[[j]]-.5, j-.5, pos[[j]]-.5, j+.5, lwd=2) } abline(h=c(seq(1.5, 5.5, by=1), 8.5), lwd=2) ##3 plot(0, xlim=c(0,10), ylim=c(1, max(table(resmat))), type=n, xaxt=n) tb - table(resmat) dis - 0 for(i in 1:10){ rect(dis, seq(par(usr)[1], tb[i], by=1), dis+.8, seq(par(usr)[1], tb[i], by=1)+1) dis - dis + 1 } axis(1, at=0.5:9.5, labels=LETTERS[1:10]) ##4 I think that symbols function should be useful On 18/01/2008, Marta Rufino [EMAIL PROTECTED] wrote: Yes, that is it, a square pie chart :-) I did not knew the name... sorry... Does anyone knows about it? Thank you very much, Best wishes, Marta hadley wickham wrote: Do you have an example graphic that shows what you're trying to create? I can't figure out if you want something like a square pie chart (aka waffle chart), a stacked barchart, a levelplot, or something else. Hadley On Jan 18, 2008 6:06 AM, Marta Rufino [EMAIL PROTECTED] wrote: Dear R users, I am trying to produce an image plot, that represents the proportions of a factor (z variable), so that the number of squares of each colour represents each factor level, with the respective label inside (sorry for the crap English). # Something like this: kk=data.frame(fact=letters[1:10], freq=c(5,1,10,2,10,7,5,10,30,20)) # factor and respective frequecies res=a # transform into a matrix (is there an easier way to do this?... for the image plot for(ii in 1:dim(kk)[1]){ res=c(res, rep(as.character(kk[ii,1]), l=kk[ii, 2])) } res=res[-1] res res=matrix(c(factor(res)), nc=10) image(x=1:10,y=1:10, res[,order(colSums(res))], col=rainbow(20)) abline(h=seq(0.5,10.5,1), col=8, lty=3); abline(v=seq(0.5,10.5,1), col=8, lty=3)#add some gridlines #Problems: #1. How to add the labels in each area text(1,1,paste(Factor level,kk[1,1]), pos=4) #2. How to separate the areas of each factor level (for BW printing), with lines (instead of colours as it is) segments(.5,1.5,5.5,1.5, lwd=2);segments(5.5,.5,5.5,1.5, lwd=2) # something like this, but automatically :-( #3. How to keep the areas together (contiguous) and not allow split over to lines? #4. Could I replace the col. by a symbol, for example? I think I would need to use plot instead of image. Any help will be much apretiated, Thank you very much in advance, Best wishes, Marta PS: This type of graphs are used in community ecology analysis, for example-... -- ... Marta M. Rufino (PhD) __ 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. -- ... Marta M. Rufino (PhD) . Instituto Nacional de Investigação Agrária e das Pescas (INIAP/IPIMAR), Centro Regional de Investigação Pesqueira do Sul (CRIPSul) Avenida 5 de Outubro s/n P-8700-305 Olhão, Portugal +351 289 700 541 . Institut de Ciències del Mar - CMIMA (CSIC) Passeig Marítim de la Barceloneta, 37-49 08003 BARCELONA - Catalunya Spain [[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. -- 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] R and samr under Linux
hi, This is my first day with R, pls pardon my newbie gaffs. Im running under Linux, samr V1.25 and R (V2.4.1 and 2.6.1), 32 and 64 bit. Either way, when I run using samr library I get the error: samr is not a valid package - installed 2.0.0? I see in R source code a conditional leading to this message: pfile -system.file (Meta, package.rds, package=package, libloc = which.lib.loc); The samr does not have a Meta directory, or underlying package.rds, as the other packages have. So, it seems to fail this check. 1. It seems to me that the offered Linux samr package V1.25 is not compatible with these versions (2.4 / 2.6) of R. Is this a correct conclusion? 2. R seems to be an interpreted language, and its 'libraries' seem to be just text files. Thus, it seems I could find a Windows implementation of samr and copy it to my Linux. Any ideas about this theory? 3. Does R language have a way for me to define which processor in a cluster I would like to execute a section of code upon, like in MPI? Please let me know some of these things, if you can help. Thanks for helping me, -m.aoki __ 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] Efficient way for multiplying vectors with a only certain number of rows in a matrix
Dear R-users, I am working on a problem that I am currently not able to solve efficiently. It is about multiplying one column of a matrix with only a certain number of rows of another matrix. Let me illustrate my problem with an example: n.obs = 800 n.rowsperobs = 300 n.param = 23 Designmat = matrix(rnorm(n.obs*n.rowsperobs*n.param),ncol=n.param) Betamat = matrix(rnorm(n.obs*n.param),nrow=n.param) In this example, Designmat consists of 800*300 rows, meaning that 300 rows belong to one of the 800 observations. Each observation has also one parameter vector, which is one column in the Betamat-matrix (i.e. Betamat contains the n.obs parameter vectors). My goal is to multiply the parameter vector of each observation (i.e. the respective column in Betamat) with ONLY THOSE ROWS IN DESIGNMAT that belong to this observation. Applied to the example above: The first column in Betamat has to be multiplied with the first 300 rows in Designmat, the second column in Betamat has to be multiplied with rows 301 to 600 in Betamat and so on. Hence, the result of this operation should be a vector of length 24. I can think of solutions implying several loops and/or lapplys, but I guess that there might be a much easyer and above all faster solution. Thank you very much for your help in advance. -- View this message in context: http://www.nabble.com/Efficient-way-for-multiplying-vectors-with-a-only-certain-number-of-rows-in-a-matrix-tp14988427p14988427.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] Newbie question on subsets
This is very standard problem for neophytes. Subsetting a factor does not automatically subset the levels, so the all appear in the boxplot. I think the simplest way round this is to replace ~ country in the formula by ~ factor(country). The call to factor() will re-set the levels to only those which appear. So try boxplot(log(marketvalue) ~ factor(country), ## changed line data = subset(Forbes2000, country %in% c(United Kingdom,Germany,India,Turkey)), ylab = log(marketvalue), varwidth = TRUE) Bill Venables. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joe Trubisz Sent: Sunday, 20 January 2008 1:12 PM To: R-help@r-project.org Subject: [R] Newbie question on subsets Hi... I'm working through the book, A Handbook of Statistical Analyses using R by Everitt, and I'm trying to do the following (p. 19 of his book): boxplot(log(marketvalue) ~ country, data = subset(Forbes2000, country %in% c(United Kingdom,Germany,India,Turkey)), ylab = log(marketvalue), varwidth = TRUE) This *almost* works, but I'm getting ALL the countries on the x-axis, not just the 4-specified. I tried tinkering with variations in the subset command to no avail. Can someone tell me what's wrong/missing with the above command? Thanks, Joe __ 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] how to extract data by specific months from a monthly ts object
tom soyer wrote: Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts(xa,start=c(1990,1),frequency=12) ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13 14 25 26 37 38 49 50 ta[cycle(ta)==c(1,2,8)] # this method doesn't work, unfortunately [1] 1 2 13 14 25 26 37 38 49 50 Warning message: In `==.default`(cycle(ta), c(1, 2, 8)) : longer object length is not a multiple of shorter object length somehow ta[cycle(ta)==c(1,2)] works. But what I really need is for ta[cycle(ta)==c(1,2,8)] to work, and it doesn't. Does anyone know how could to do this kinds of data extraction? Thanks! Tom, You need to use %in% when you want to test whether one or more values are in a second set of values. In this case: ta[cycle(ta) %in% c(1, 2, 8)] [1] 1 2 8 13 14 20 25 26 32 37 38 44 49 50 BTW, the use of: ta[cycle(ta) == c(1, 2)] [1] 1 2 13 14 25 26 37 38 49 50 results in a correct response, but largely by chance in this case because of the way in which the data is stored. You should be using: ta[cycle(ta) %in% c(1, 2)] [1] 1 2 13 14 25 26 37 38 49 50 Note however, that if we use: ta[cycle(ta) == c(1, 3)] [1] 1 13 25 37 49 we do not get the correct answer, which should be: ta[cycle(ta) %in% c(1, 3)] [1] 1 3 13 15 25 27 37 39 49 See ?%in% for more information. HTH, Marc Schwartz __ 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 extract data by specific months from a monthly ts object
Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts(xa,start=c(1990,1),frequency=12) ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13 14 25 26 37 38 49 50 ta[cycle(ta)==c(1,2,8)] # this method doesn't work, unfortunately [1] 1 2 13 14 25 26 37 38 49 50 Warning message: In `==.default`(cycle(ta), c(1, 2, 8)) : longer object length is not a multiple of shorter object length somehow ta[cycle(ta)==c(1,2)] works. But what I really need is for ta[cycle(ta)==c(1,2,8)] to work, and it doesn't. Does anyone know how could to do this kinds of data extraction? Thanks! -- Tom [[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] how to extract data by specific months from a monthly ts object
Try %in% ta[ cycle(ta) %in% c(1, 2, 8) ] cycle(ta) == c(1, 2) works only in this case since c(1, 2) is recycled to cycle(ta) == rep(c(1, 2), length = length(ta)) It would not have worked had your data had started on an even numbered month. This also works: cyc - cycle(ta) ta[ cyc == 1 | cyc == 2 | cyc == 8 ] On Jan 20, 2008 8:09 PM, tom soyer [EMAIL PROTECTED] wrote: Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts(xa,start=c(1990,1),frequency=12) ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13 14 25 26 37 38 49 50 ta[cycle(ta)==c(1,2,8)] # this method doesn't work, unfortunately [1] 1 2 13 14 25 26 37 38 49 50 Warning message: In `==.default`(cycle(ta), c(1, 2, 8)) : longer object length is not a multiple of shorter object length somehow ta[cycle(ta)==c(1,2)] works. But what I really need is for ta[cycle(ta)==c(1,2,8)] to work, and it doesn't. Does anyone know how could to do this kinds of data extraction? Thanks! -- Tom [[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] how to extract data by specific months from a monthly ts object
Thanks Marc and Gabor, I got it! On 1/20/08, Marc Schwartz [EMAIL PROTECTED] wrote: tom soyer wrote: Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts(xa,start=c(1990,1),frequency=12) ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13 14 25 26 37 38 49 50 ta[cycle(ta)==c(1,2,8)] # this method doesn't work, unfortunately [1] 1 2 13 14 25 26 37 38 49 50 Warning message: In `==.default`(cycle(ta), c(1, 2, 8)) : longer object length is not a multiple of shorter object length somehow ta[cycle(ta)==c(1,2)] works. But what I really need is for ta[cycle(ta)==c(1,2,8)] to work, and it doesn't. Does anyone know how could to do this kinds of data extraction? Thanks! Tom, You need to use %in% when you want to test whether one or more values are in a second set of values. In this case: ta[cycle(ta) %in% c(1, 2, 8)] [1] 1 2 8 13 14 20 25 26 32 37 38 44 49 50 BTW, the use of: ta[cycle(ta) == c(1, 2)] [1] 1 2 13 14 25 26 37 38 49 50 results in a correct response, but largely by chance in this case because of the way in which the data is stored. You should be using: ta[cycle(ta) %in% c(1, 2)] [1] 1 2 13 14 25 26 37 38 49 50 Note however, that if we use: ta[cycle(ta) == c(1, 3)] [1] 1 13 25 37 49 we do not get the correct answer, which should be: ta[cycle(ta) %in% c(1, 3)] [1] 1 3 13 15 25 27 37 39 49 See ?%in% for more information. HTH, Marc Schwartz -- Tom [[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] Vendez Votre voiture en 1 clic
-- Pour vous d�sabonner � cette liste, visitez http://jbala.ws/lists/lt.php?id=MkxRBwUHBVJIB08AVV1XAQ%3D%3D Pour mettre vos pr�f�rences � jour, visitez http://jbala.ws/lists/lt.php?id=MkxRBwUHBVVIB08AVV1XAQ%3D%3D Faire suivre un message a quelqun http://jbala.ws/lists/lt.php?id=MkxRBwUHBVRIB08AVV1XAQ%3D%3D -- Powered by PHPlist, www.phplist.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] Efficient way for multiplying vectors with a only certain number of rows in a matrix
Perhaps: n.obs = 800 n.rowsperobs = 300 n.param = 23 Designmat = matrix(rnorm(n.obs*n.rowsperobs*n.param),ncol=n.param) Betamat = matrix(rnorm(n.obs*n.param),nrow=n.param) Design.spl - split(as.data.frame(Designmat), rep(1:n.obs, each=n.rowsperobs)) res - sapply(1:ncol(Betamat), function(x)as.matrix(Design.spl[[x]])%*%Betamat[,x]) On 20/01/2008, Ralph79 [EMAIL PROTECTED] wrote: Dear R-users, I am working on a problem that I am currently not able to solve efficiently. It is about multiplying one column of a matrix with only a certain number of rows of another matrix. Let me illustrate my problem with an example: n.obs = 800 n.rowsperobs = 300 n.param = 23 Designmat = matrix(rnorm(n.obs*n.rowsperobs*n.param),ncol=n.param) Betamat = matrix(rnorm(n.obs*n.param),nrow=n.param) In this example, Designmat consists of 800*300 rows, meaning that 300 rows belong to one of the 800 observations. Each observation has also one parameter vector, which is one column in the Betamat-matrix (i.e. Betamat contains the n.obs parameter vectors). My goal is to multiply the parameter vector of each observation (i.e. the respective column in Betamat) with ONLY THOSE ROWS IN DESIGNMAT that belong to this observation. Applied to the example above: The first column in Betamat has to be multiplied with the first 300 rows in Designmat, the second column in Betamat has to be multiplied with rows 301 to 600 in Betamat and so on. Hence, the result of this operation should be a vector of length 24. I can think of solutions implying several loops and/or lapplys, but I guess that there might be a much easyer and above all faster solution. Thank you very much for your help in advance. -- View this message in context: http://www.nabble.com/Efficient-way-for-multiplying-vectors-with-a-only-certain-number-of-rows-in-a-matrix-tp14988427p14988427.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. -- 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] R and samr under Linux
hi, I have determined some of my own answers, so will share here. There are binary associations within the R libraries specific to the environment that created them, be it Windows or Linux, 32 or 64 bit. I found these associations in the Meta directory of the libraries. So, R libraries cannot be shared across different platforms as I had hoped as R libraries have a binary component. As for samr, and some of the other Linux packages available, these packages must first be compiled by R, which in so doing produces the 'missing' Meta directory, among other critical output. The procedure I used for Linux was to download a package, for example samr. I then extracted its contents, which produced a 'samr' directory. I changed to that directory and, from a command line, issued the following: #R CMD INSTALL -l samr samr This compiles the directory (last argument) into the library samr (first argument), the best that I can determine anyway. The result was yet another samr directory containing all of the expected contents, including the Meta directory, under this one. I copied this samr directory to: /usr/lib64/R/library ...and repeated these steps for the 'impute' library, apparently needed by samr, and then tried again to run the developer's software (I didn't write it) and it worked. So, Im up and running on 64-bit Linux and R / samr. Maybe these steps are not the best, but they worked for me. Hope this helps any other newbies out there : )! -mark aoki - Original Message - From: markaoki [EMAIL PROTECTED] To: r-help@r-project.org Sent: Sunday, January 20, 2008 2:39 PM Subject: [R] R and samr under Linux hi, This is my first day with R, pls pardon my newbie gaffs. Im running under Linux, samr V1.25 and R (V2.4.1 and 2.6.1), 32 and 64 bit. Either way, when I run using samr library I get the error: samr is not a valid package - installed 2.0.0? I see in R source code a conditional leading to this message: pfile -system.file (Meta, package.rds, package=package, libloc = which.lib.loc); The samr does not have a Meta directory, or underlying package.rds, as the other packages have. So, it seems to fail this check. 1. It seems to me that the offered Linux samr package V1.25 is not compatible with these versions (2.4 / 2.6) of R. Is this a correct conclusion? 2. R seems to be an interpreted language, and its 'libraries' seem to be just text files. Thus, it seems I could find a Windows implementation of samr and copy it to my Linux. Any ideas about this theory? 3. Does R language have a way for me to define which processor in a cluster I would like to execute a section of code upon, like in MPI? Please let me know some of these things, if you can help. Thanks for helping me, -m.aoki __ 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] OT: single measure of (group) correlation with more than two vectors?
Hello, I have a survey in which a number of people rated a set of items on a 1..5 scale. I believe it would be desirable to argue that the people's responses are correlated, and thus that the rating task makes sense to people. Is there a standard approach to this? With only 2 people, the correlation coefficient between their responses would be an interpretable number, (though probably there is some stronger way to assess whether the results are _significantly_ correlated). With N2 people, there is the correlation matrix, but it does not give a nice single number. Thinking, the determinant of the matrix of response vectors might be a possibility, since it will be low if the rows are correlated. Though, it should be normalized somehow to be interpretable. Is there a standard approach to this problem? Thanks for any advice 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] 'matrix' returns integer instead of decimal
Brant Inman wrote: R-helpers: I am experiencing some odd behavior with the 'matrix' function that I have not experienced before and was wondering if there is something that I was missing in my code. - sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines grid stats graphics grDevices utils datasets methods [9] base other attached packages: [1] meta_0.8-2 car_1.2-7 arm_1.1-1 R2WinBUGS_2.1-6 [5] coda_0.13-1lme4_0.99875-9 Matrix_0.999375-3 nlme_3.1-86 [9] latticeExtra_0.3-1 RColorBrewer_1.0-2 survival_2.34 MASS_7.2-39 [13] foreign_0.8-23 RGraphics_1.0-6lattice_0.17-4 loaded via a namespace (and not attached): [1] rcompgen_0.1-17 tools_2.6.1 rm(list=ls()) matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, # Make a data matrix + 1,28,1,19,22,49,25,162,31,200,9,39,22,193, + 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, + 25.5,3,65,25,54,24,41,37,95,11,17,26,49,13, + 84,38,170,29,60,9,20,44,47,30,160,40,185,10, + 41,40,185,4.5,46.5,60,140,12,75,42,225,26,57, + 17,92,23.5,23.5,6,68), ncol=2, byrow=T) [,1] [,2] [1,] 7.0 47 [2,] 4.0 38 [3,] 20.0 96 [4,] 1.0 14 [5,] 10.0 48 [6,] 2.0 101 [7,] 12.0 161 [8,] 1.0 28 [9,] 1.0 19 [10,] 22.0 49 [11,] 25.0 162 [12,] 31.0 200 [13,] 9.0 39 [14,] 22.0 193 [15,] 0.5 46 [16,] 31.0 131 [17,] 4.0 75 [18,] 31.0 220 [19,] 7.0 55 [20,] 3.0 91 [21,] 14.5 26 [22,] 3.0 65 [23,] 25.0 54 [24,] 24.0 41 [25,] 37.0 95 [26,] 11.0 17 [27,] 26.0 49 [28,] 13.0 84 [29,] 38.0 170 [30,] 29.0 60 [31,] 9.0 20 [32,] 44.0 47 [33,] 30.0 160 [34,] 40.0 185 [35,] 10.0 41 [36,] 40.0 185 [37,] 4.5 46 [38,] 60.0 140 [39,] 12.0 75 [40,] 42.0 225 [41,] 26.0 57 [42,] 17.0 92 [43,] 23.5 24 [44,] 6.0 68 Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would very much appreciate any comments. Thanks, Brant Inman Mayo Clinic Hi Brant, I don't get this with 2.6.1 patched on Fedora 8: mat - matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, 1,28,1,19,22,49,25,162,31,200,9,39,22,193, 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, 25.5,3,65,25,54,24,41,37,95,11,17,26,49,13, 84,38,170,29,60,9,20,44,47,30,160,40,185,10, 41,40,185,4.5,46.5,60,140,12,75,42,225,26,57, 17,92,23.5,23.5,6,68), ncol=2, byrow=T) mat [,1] [,2] [1,] 7.0 47.0 [2,] 4.0 38.0 [3,] 20.0 96.0 [4,] 1.0 14.0 [5,] 10.0 48.0 [6,] 2.0 101.0 [7,] 12.0 161.0 [8,] 1.0 28.0 [9,] 1.0 19.0 [10,] 22.0 49.0 [11,] 25.0 162.0 [12,] 31.0 200.0 [13,] 9.0 39.0 [14,] 22.0 193.0 [15,] 0.5 45.5 [16,] 31.0 131.0 [17,] 4.0 75.0 [18,] 31.0 220.0 [19,] 7.0 55.0 [20,] 3.0 91.0 [21,] 14.5 25.5 [22,] 3.0 65.0 [23,] 25.0 54.0 [24,] 24.0 41.0 [25,] 37.0 95.0 [26,] 11.0 17.0 [27,] 26.0 49.0 [28,] 13.0 84.0 [29,] 38.0 170.0 [30,] 29.0 60.0 [31,] 9.0 20.0 [32,] 44.0 47.0 [33,] 30.0 160.0 [34,] 40.0 185.0 [35,] 10.0 41.0 [36,] 40.0 185.0 [37,] 4.5 46.5 [38,] 60.0 140.0 [39,] 12.0 75.0 [40,] 42.0 225.0 [41,] 26.0 57.0 [42,] 17.0 92.0 [43,] 23.5 23.5 [44,] 6.0 68.0 Given some of the packages you have listed above, I would try to go into R using: R --vanilla from a command line and then try your example again. It seems possible that one of the packages has modified the behavior of print() on a matrix or is causing some type of conflict. For example, if options(digits) has been modified from it's default of '7': options(digits) $digits [1] 7 to either 1 or 2, I can replicate the behavior you see above: options(digits = 2) mat [,1] [,2] [1,] 7.0 47 [2,] 4.0 38 [3,] 20.0 96 [4,] 1.0 14 [5,] 10.0 48 [6,] 2.0 101 [7,] 12.0 161 [8,] 1.0 28 [9,] 1.0 19 [10,] 22.0 49 [11,] 25.0 162 [12,] 31.0 200 [13,] 9.0 39 [14,] 22.0 193 [15,] 0.5 46 [16,] 31.0 131 [17,] 4.0 75 [18,] 31.0 220 [19,] 7.0 55 [20,] 3.0 91 [21,] 14.5 26 [22,] 3.0 65 [23,] 25.0 54 [24,] 24.0 41 [25,] 37.0 95 [26,] 11.0 17 [27,] 26.0 49 [28,] 13.0 84 [29,] 38.0 170 [30,] 29.0 60 [31,] 9.0 20 [32,] 44.0 47 [33,] 30.0 160 [34,] 40.0 185 [35,] 10.0 41 [36,] 40.0 185 [37,] 4.5 46 [38,] 60.0 140 [39,] 12.0 75 [40,] 42.0 225 [41,] 26.0 57 [42,] 17.0 92 [43,] 23.5 24 [44,] 6.0 68 HTH, Marc Schwartz
Re: [R] 'matrix' returns integer instead of decimal
On Sun, 20 Jan 2008, Brant Inman wrote: Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would very much appreciate any comments. I don't see this (though I'm not on Windows). My first guess is that the rounding happens in print() rather than in matrix() -- if you print just the [15,2] entry of the matrix is it 45.5 or 46? Is it == to 45.5 or 46? -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] 'matrix' returns integer instead of decimal
R-helpers: I am experiencing some odd behavior with the 'matrix' function that I have not experienced before and was wondering if there is something that I was missing in my code. - sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines grid stats graphics grDevices utils datasets methods [9] base other attached packages: [1] meta_0.8-2 car_1.2-7 arm_1.1-1 R2WinBUGS_2.1-6 [5] coda_0.13-1lme4_0.99875-9 Matrix_0.999375-3 nlme_3.1-86 [9] latticeExtra_0.3-1 RColorBrewer_1.0-2 survival_2.34 MASS_7.2-39 [13] foreign_0.8-23 RGraphics_1.0-6lattice_0.17-4 loaded via a namespace (and not attached): [1] rcompgen_0.1-17 tools_2.6.1 rm(list=ls()) matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, # Make a data matrix + 1,28,1,19,22,49,25,162,31,200,9,39,22,193, + 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, + 25.5,3,65,25,54,24,41,37,95,11,17,26,49,13, + 84,38,170,29,60,9,20,44,47,30,160,40,185,10, + 41,40,185,4.5,46.5,60,140,12,75,42,225,26,57, + 17,92,23.5,23.5,6,68), ncol=2, byrow=T) [,1] [,2] [1,] 7.0 47 [2,] 4.0 38 [3,] 20.0 96 [4,] 1.0 14 [5,] 10.0 48 [6,] 2.0 101 [7,] 12.0 161 [8,] 1.0 28 [9,] 1.0 19 [10,] 22.0 49 [11,] 25.0 162 [12,] 31.0 200 [13,] 9.0 39 [14,] 22.0 193 [15,] 0.5 46 [16,] 31.0 131 [17,] 4.0 75 [18,] 31.0 220 [19,] 7.0 55 [20,] 3.0 91 [21,] 14.5 26 [22,] 3.0 65 [23,] 25.0 54 [24,] 24.0 41 [25,] 37.0 95 [26,] 11.0 17 [27,] 26.0 49 [28,] 13.0 84 [29,] 38.0 170 [30,] 29.0 60 [31,] 9.0 20 [32,] 44.0 47 [33,] 30.0 160 [34,] 40.0 185 [35,] 10.0 41 [36,] 40.0 185 [37,] 4.5 46 [38,] 60.0 140 [39,] 12.0 75 [40,] 42.0 225 [41,] 26.0 57 [42,] 17.0 92 [43,] 23.5 24 [44,] 6.0 68 Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would very much appreciate any comments. Thanks, Brant Inman Mayo Clinic [[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] 'matrix' returns integer instead of decimal
Check your getOption(digits). Default is typically 7. Either you or a package/function sets it to a small value. You get that **output** with options(digits=n) where n=1,2,3. /Henrik On Jan 20, 2008 7:13 PM, Thomas Lumley [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008, Brant Inman wrote: Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would very much appreciate any comments. I don't see this (though I'm not on Windows). My first guess is that the rounding happens in print() rather than in matrix() -- if you print just the [15,2] entry of the matrix is it 45.5 or 46? Is it == to 45.5 or 46? -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-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] 'matrix' returns integer instead of decimal
*As usual, the R-helpers were bang on. Some package must have modified my digits option without me noticing.* ** *--* ** * test - matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, + 1,28,1,19,22,49,25,162,31,200,9,39,22,193, + 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, + 25.5,3,65,25,54,24,41,37,95,11,17,26,49,13, + 84,38,170,29,60,9,20,44,47,30,160,40,185,10, + 41,40,185,4.5,46.5,60,140,12,75,42,225,26,57, + 17,92,23.5,23.5,6,68), ncol=2, byrow=T) test[15,2] [1] 46* * getOption('digits') [1] 2 options(digits=7) test[15,2] [1] 45.5 Thanks to the 3 guys who responded within minutes of my email. Brant * ** [[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] 'matrix' returns integer instead of decimal
Brant Inman brant.inman at gmail.com writes: *As usual, the R-helpers were bang on. Some package must have modified my digits option without me noticing.* I'm pretty certain that the arm package is the problem. options(digits) $digits [1] 7 library(arm) Loading required package: MASS Loading required package: Matrix Loading required package: lattice Loading required package: lme4 Loading required package: R2WinBUGS Loading required package: coda arm (Version 1.0-38, built: 2007-12-31) Working directory is /home/ben options( digits = 2 ) Loading required package: car Loading required package: foreign options(digits) $digits [1] 2 I've complained about this to the maintainer but not yet loudly or persistently enough :-) cheers Ben Bolker __ 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.