Re: [R] Error with Source()
Normally is a missing comma in a function command list. Ciao! mario On 10-Nov-11 19:02, jim holtman wrote: You have a syntax error in your script. Take a look around line 884 On Thu, Nov 10, 2011 at 9:27 AM, ftoninif_ton...@hotmail.com wrote: Hi everybody, I started to receive a weird message in R that I have never seen before...also I haven't found anything on google or on this forum about it. Whenever I use the command source(...) to point to one of my scripts, I get the following message: Error in source(myfunctions.R) : myfunctions.R:884:9: unexpected symbol 883: 884: cond ^ I am using the same commands as I did in the past and it was working...I started to receive this error (not sure if it has to do with it or not) after trying to create a batch file to run one of my .R scripts with double-click. That batch file worked...but as soon as I use the source() command it does not work any more. Any help is appreciated! Thanks Francesco -- View this message in context: http://r.789695.n4.nabble.com/Error-with-Source-tp4023794p4023794.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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Win upgrade pb (virus)
Thanks to all that responded privately! If you have AVG and needs the colorspace (or ggplot2) package do the following from a suitably privileged account: 1) Open AVG gui and select Components-Anti virus from the menu 2) Click Advanced settings... and then go to Temporary disable AVG protection Here you need half a million clicks to disable protection for 10 min 3) Install colorspace package from R (I installed ggplot2 that installs colorspace) 4) Go to the user library and note the path to the colorspace.dll . In my case it is: C:\Users\mvalle\R\win-library\2.14\colorspace\libs\i386\colorspace.dll (SHIFT-click and then Copy as path is handy) 5) In the open AVG window click Manage Exceptions then Add File and add the path above 6) On the main AVG gui there is a big button that reenables protection. Voilà, no more problems. Thanks again! mario On 11-Nov-11 11:34, Mario Valle wrote: I just upgraded my Win7 32bits installation to 2.14.0 after deinstalling 2.12.x First thing I moved the win-library from 2.12 to 2.14 and executed a update.packages(ask='graphics',checkBuilt=TRUE) (Swiss mirror). This aborts with the console message: Error in if (any(diff)) { : missing value where TRUE/FALSE needed And the antivirus (AVG) pops up complaining that colorspace.dll contains the virus Win32/Heur I cannot ignore the thread because update.packages has already crashed when I can reach the antivirus dialogbox to push the ignore button. To continue I had to remove the colorspace and ggplot2 packages. Is it a known problem? What else can I do (except removing the above packages or changing antivirus)? Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Win upgrade pb (virus)
I just upgraded my Win7 32bits installation to 2.14.0 after deinstalling 2.12.x First thing I moved the win-library from 2.12 to 2.14 and executed a update.packages(ask='graphics',checkBuilt=TRUE) (Swiss mirror). This aborts with the console message: Error in if (any(diff)) { : missing value where TRUE/FALSE needed And the antivirus (AVG) pops up complaining that colorspace.dll contains the virus Win32/Heur I cannot ignore the thread because update.packages has already crashed when I can reach the antivirus dialogbox to push the ignore button. To continue I had to remove the colorspace and ggplot2 packages. Is it a known problem? What else can I do (except removing the above packages or changing antivirus)? Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 add a double quote to a string
On 11-Oct-11 09:23, arunkumar wrote: Hi I want to add a double quote to a string eg Expected output = DROP TABLE IF EXISTS abc My code tab=c(abc) query = paste(DROP TABLE IF EXISTS ,tab,sep=) query = paste(DROP TABLE IF EXISTS \,tab,\, sep=) or query = paste('DROP TABLE IF EXISTS ',tab,'', sep=) and tab=abc. no need for c() Ciao! mario Please help me to solve this problem -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-double-quote-to-a-string-tp3893061p3893061.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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] For loop for subset - repeating same over and over?
Not reproducible. Could you please attach the dataset QInflAvgbyPlot Otherwise I don't see anything obviously wrong here. Ciao! mario On 30-Sep-11 01:37, kelseyann wrote: SiteSpp- c(ADHALP,ADLCON,ADLARC,BDALAT,BDPARC,BDLCON,BDLARC,AWCAQU,AWERUS,AWEANG,AWDPSI,BWCSTA,BWHPAU,BWETRI,BWERUS,BWDFIS,BWPARC,BWLCON,BWLARC,BWJBIG) n.SiteSpp- length(SiteSpp) for (i in (1:n.SiteSpp)) { QInfl.aov- aov(AvgOfnumResponse ~ strTrea*strYear, data=QInflAvgbyPlot, subset=(SiteSpp == SiteSpp[i])) print(summary(QInfl.aov)) } -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] trouble with library(FEAR) and libgfortran.so.1
1) you can try to make a symbolic link to libgfortran.so.3 and call it libgfortran.so.1 Sometimes it works. 2) you can try to downgrade your version of gfortran 3) you can ask to the package maintainer to recompile FEAR with a more modern gfortran. Hope it helps mario On 25-Sep-11 08:21, John P. Burkett wrote: Running R version 2.13.1 under Ubuntu 10.10 (kernel version 2.6.35-30-generic) on a x86-64 laptop with gfortran 4.4, I'm trying to install and use the FEAR package from http://www.clemson.edu/economics/faculty/wilson/Software/FEAR/fear.html. I downloaded the the FEAR 1.15 package for 64-bit Linux (compatible with R-2.12.0 compiled with GCC, GNU Fortran 4.1.2, Linux kernel 2.6.16.60 SMP) to the /home/john/Downloads directory. The command install.packages(FEAR-linux-64bit-2.6.16.60-0.21-smp.tar.gz, repos=NULL, destdir=/home/john/Downloads) appears to have worked, eliciting the following responses: Installing package(s) into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) * installing *binary* package ‘FEAR’ ... * DONE (FEAR) The command library(FEAR) produced the following response: Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/usr/local/lib/R/site-library/FEAR/libs/FEAR.so': libgfortran.so.1: cannot open shared object file: No such file or directory Error: package/namespace load failed for 'FEAR' Doing ls -l in the /usr/local/lib/R/site-library/FEAR/libs directory produces the following: total 288 -rwxr-xr-x 1 root staff 292757 2011-09-25 00:24 FEAR.so The command locate libgfortran.so produces this response: /home/john/Sage/sage-4.7-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/libgfortran.so.3 /home/john/Sage/sage-4.7-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/libgfortran.so.3.0.0 /usr/lib/libgfortran.so.3 /usr/lib/libgfortran.so.3.0.0 /usr/lib/gcc/x86_64-linux-gnu/4.4/libgfortran.so It appears to me that R looks for libgfortran.so.1 whereas I have libgfortran.so.3. I would be very grateful for suggestions about how to get R to load the FEAR package. -John __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Unexpected behavior from which.max (or possibly max)
If I enclose x$i+x$window in parentheses it works: check.max- function(x){obs.max- which.max(x$elev[x$i:(x$i+x$window)]); obs.max} x$elev[x$i:x$i+x$window] means: x$elev[(x$i:x$i)+x$window] Simple. mario check.max(test) [1] 11 What am I missing? Here is sessionInfo (I know I need to upgrade; I am behind the state's McAfee firewall thingy which makes it very difficult for me): sessionInfo() R version 2.11.1 (2010-05-31) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.11.1 Thanks, Jason [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] writeLines + foreach/doMC
Read something about parallel processing and how I/O should be done by a single process. Suggestion: write a different file from each thread then combine the results with cat or similar. Hope it helps mario On 04-Jul-11 11:58, Ramzi TEMANNI wrote: Hi I'm processing sequencing data trying to collapsing the locations of each unique sequence and write the results to a file (as storing that in a table will require 10GB mem at least) so I wrote a function that, given a sequence id, provide the needed line to be stored library(doMC) # load library registerDoMC(12) # assign the Number of CPU fileConn-file(paste(fq_file,_SeqID.txt,sep=),open = at) # open connection writeLines(paste(ReadID,Freq,Seq,LOC_UG,Nb_UG_Seq,sep=\t), fileConn) # write header foreach(i=1:length(uniq.Seq)) %dopar% # for eqch unique sequence { writeLines(paste(gettable1(uniq.Seq[i]),collapse= ), fileConn) #write the the results line } close(fileConn) the code excute well, but the problem is that some lines are wired: The header and lot of lines are ok : ReadIDFreqSeqLOC_UGNb_UG_Seq HWI-EA332_0036:5:16:9530:21025#ATGC/1 2 X_10130:489:+,X_10130:489:+ 2 HWI-EA332_0036:5:117:6674:4940#ATGC/1 1 X:432:-,X:432:- 2 HWI-EA332_0036:5:62:15592:7375#ATGC/1 2 X_22660:253:+,X_22660:253:+ 2 HWI-EA332_0036:5:110:14349:8422#ATGC/1 4 X_13806:399:+,X_13806:399:+,X_27263:481:+,X_27263:481:+ 4 other looks wired HWI-EA332_0036:5:17:1400ReadIDFreqSeqLOC_UGNb_UG_Seq HWI-EA332_0036:5:61:7734:4201ReadIDFreqSeqLOC_UGNb_UG_Seq HWI-EA332_0036:5:117:5361:10666#ATGReadIDFreqSeqLOC_UG Nb_UG_Seq HWI-EA332_0036:5:115:7421:20664#ATGC/1 GATCReadIDFreqSeq LOC_UGNb_UG_Seq HWI-EA332_0036:5:175:95:- 2 HWI-EA332_0036:5JCVI_35536:444:+ 2 X 1 X_22484:571:-,X_22484:571:- 2 Is this due to the fact that one process start to write prior the other has finished ? Is there a way to solve this problem ? Any suggestions would be greatly appreciated. Thanks and have a nice day. Best, Ramzi TEMANNI http://www.linkedin.com/in/ramzitemanni [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Can I disable Cairo?
On Linux 2.13 by default links cairo, so png() uses it for rendering. One of my users has performance problem, so ask if it possible to temporary disable cairo during png() rendering so it reverts to grGraphics. My workaround for now is to configure R without cairo, but this affects all users that are forced to load and use CairoDevice if they wants better quality. I want to avoid this, is it possible? Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] EM vs Bayesian
Maybe it is better to ask this question on: http://stats.stackexchange.com/ The question is not R specific. mario On 24-Apr-11 16:16, Jim Silverton wrote: Hello, Is there any literature there that says that the EM is better/worse than a Baysian model when it comes to differentiating univariate mixture of normal distributions? -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Location of libraries in Windows
I'm preparing to install 2.13, so I need a clarification about package location on disk. On window the packages I have installed are under C:\Users\mvalle\R\win-library\2.12 and the ones that come with R are under C:\Program Files\R\library If I execute update.packages() from the R gui, it fails because it finds e.g. Matrix as a package that should be updated but the process cannot write under R\library. I failed to change permissions for this directory (I tried hard...) so I'm forced to run Rterm.exe as administrator just to update packages. I would ask if moving all directories (except maybe base) from R\library to R\win-library\2.12 could be a good thing to do. Or should I simply not update packages that come with R? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Location of libraries in Windows
The best method to solve a problem is to send a mail to the list. One second later you find the problem has just been solved for someone else... The solution is here: http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/ Anyway, my question about folder location remains. Thanks! mario On 18-Apr-11 09:22, Mario Valle wrote: I'm preparing to install 2.13, so I need a clarification about package location on disk. On window the packages I have installed are under C:\Users\mvalle\R\win-library\2.12 and the ones that come with R are under C:\Program Files\R\library If I execute update.packages() from the R gui, it fails because it finds e.g. Matrix as a package that should be updated but the process cannot write under R\library. I failed to change permissions for this directory (I tried hard...) so I'm forced to run Rterm.exe as administrator just to update packages. I would ask if moving all directories (except maybe base) from R\library to R\win-library\2.12 could be a good thing to do. Or should I simply not update packages that come with R? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Krylov subspace computations of matrix exponentials
Look at ExpoKit (http://www.maths.uq.edu.au/expokit/) It implement Krylov methods and is really fast. Unfortunately no R wrapper that I know yet. If you plan to implement it, I can provide my testing code. Ciao! mario On 14-Apr-11 10:16, Niels Richard Hansen wrote: I use the very nice expm functions available from the expm and Matrix packages. My understanding is that for large sparse matrices the currently best methods available are Krylov subspace methods, but they are as far as I can tell not implemented in either of the packages mentioned, nor in any other R package I have found. Does anybody know if Krylov subspace methods are available from any R package? If not, is there anybody working on this or planning to do so? If not, I might be interested in making such an implementation, because I find myself in the need of fast methods for very large sparse matrices. A third question. There exists a Fortran implementation called Expokit with an ad hoc license stating that Permission to use, copy, modify, and distribute EXPOKIT and its supporting documentation for non-commercial purposes, is hereby granted without fee, provided that this permission message and copyright notice appear in all copies. If I choose to use Expokit and just write an interface to R, would there be any problems with having such a copyright notice in the package? Thanks, Niels -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Optimzing a nested function
P.S.: It is bad taste to call a variable 'sum' because it is a R function. Ciao! mario On 12-Apr-11 08:33, vioravis wrote: I am trying to optimize a nested function using nlminb. This throws out an error that y is missing. Can someone help me with the correct syntax?? Thank you. test1- function(x,y) { sum- x + y return(sum) } test2- function(x,y) { sum- test1(x,y) sumSq- sum*sum return(sumSq) } nlminb(start = c(1,1), test2,lower = c(0,0), upper = c(5,5)) -- View this message in context: http://r.789695.n4.nabble.com/Optimzing-a-nested-function-tp3443825p3443825.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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 linear Regression: singular gradient matrix at initial parameter estimates
Use a more realistic starting point instead of the default one: fit - nls(yeps ~ p1 / (1 + exp(p2 - x)) * exp(p4 * x), start=list(p1=410,p2=18,p4=-.03)) This works for me: fit Nonlinear regression model model: yeps ~ p1/(1 + exp(p2 - x)) * exp(p4 * x) data: parent.frame() p1p2p4 199.48276 16.28664 -0.01987 residual sum-of-squares: 560.6 Number of iterations to convergence: 5 Achieved convergence tolerance: 5.637e-07 Ciao! mario On 12-Apr-11 18:01, Felix Nensa wrote: fit = nls(yeps ~ p1 / (1 + exp(p2 - x)) * exp(p4 * x)) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Very simple question
paste(teste, collapse=+) ciao! mario On 08-Apr-11 12:44, Ronaldo Reis Junior wrote: teste - c(A,B,C) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] hc2Newick is different than th hclust dendrogram
Well, I could not call them entirely different. See attached (tree-tv from TreeView, tree-r from R). Yes, I had to rotate and mirror the tree in TreeView but that's all. And yes, I have to ignore the tree length values from the file. Maybe it is better to post your inquiry to the Bioconductor list (from where hc2newick apparently arrives in package 'ctc'). Some humble suggestions: - don't call a text file .Rdata! Rdata is a specific binary format read using load() and saved using save(). - add to the description of your problem how to read the data, i.e.: z - scan('data.Rdata') C - matrix(z, 112, 112, byrow=TRUE) - add to your problem description all the packages you loaded to make the example work, i.e.: library('ctc') Hope it helps mario On 04-Apr-11 21:47, Jose Hleap Lozano wrote: It was... I have it in my sent box is called data.Rdata... I am attaching it again! Thanks -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 attachment: tree-tv.pngattachment: tree-r.png__ 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] Plotting MDS (multidimensional scaling)
Also try the asp parameter in plot. plot(fit2$points, xlab=Coordinate 1, ylab=Coordinate 2,main=Metric MDS,type='n',asp=1) text(fit2$points, labels = c('A','B','C','D'), cex=1) Hope it helps mario On 02-Apr-11 22:07, Daniel Malter wrote: Hi, I just encountered what I thought was strange behavior in MDS. However, it turned out that the mistake was mine. The lesson learned from my mistake is that one should plot on a square pane when plotting results of an MDS. Not doing so can be very misleading. Follow the example of an equilateral triangle below to see what I mean. I hope this helps others to avoid this kind of headache. Let's say I have an equilateral triangle. Then, the three Euclidean distances between points A, B, and C are all equal. That is, dist(AB)=dist(AC)=dist(BC). Let the points A, B, and C have (x,y)-coordinates (0,0), (2,0), and (1,sqrt(3)). Then, MDS should reproduce an equilateral triangle, which it does if there are only three points. require(MASS) x=c(0,2,1,0,0,sqrt(3)) dim(x)=c(3,2) d1=dist(x) fit1-isoMDS(d1) plot(fit1$points, xlab=Coordinate 1, ylab=Coordinate 2, main=Metric MDS,type=n) text(fit1$points, labels = c('A','B','C'), cex=1) So far so good, until I add more points. Now assume, I add a fourth point D at {0,2*sqrt(3)}. This produces the rectangular triangle ABD with hypothenuse BD that encompasses the smaller triangle ABC such that C lies in the middle between B and D. Then, MDS should reproduce the rectangular triangle ABD and the equilateral triangle ABC within it. However, even though distance matrix d2 below still indicates that ABC is an equilateral triangle, the plot of the MDS does not confirm this. x=c(0,2,1,0,0,0,sqrt(3),2*sqrt(3)) dim(x)=c(4,2) d2=dist(x) fit2-isoMDS(d2) plot(fit2$points, xlab=Coordinate 1, ylab=Coordinate 2, main=Metric MDS,type=n) text(fit2$points, labels = c('A','B','C','D'), cex=1) The reason for this is that the dimension of the plot is automatically scaled to fit the points. This distorts the visual impression of the distances, angular relationships, and relative locations. If you plot on a square pane, however, peace and order are restored in the galaxy. plot(fit2$points, xlab=Coordinate 1, ylab=Coordinate 2, main=Metric MDS,type=n,xlim=c(-3,3),ylim=c(-3,3)) text(fit2$points, labels = c('A','B','C','D'), cex=1) Best, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Plotting-MDS-multidimensional-scaling-tp3422670p3422670.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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 put line linking two plots
Hello! Suppose I have three charts like below. The top chart is a general overview and the bottom charts are related so some point of this chart. To make clear this relationship I want to draw a line between (4,0.9) in the top chart and (10,1) in the bottom-left one. Currently I add it manually using Inkscape on the resulting pdf file. Is it possible to add it inside R? Should I switch to other charting packages? Thanks for the advice! mario set.seed(123) pdf(test.pdf, width=14, height=7) layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE)) plot(runif(10), type='b') plot(runif(20), type='l') plot(runif(20), type='l') dev.off() R 2.12.2 on Windows 7 (32bits) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 Bad Data
s - read.table('d.dat', na.strings='-') On 16-Mar-11 06:45, Rahul Kaura wrote: 06/30/2007 0.0028 0.0183 0.0122 0.0042 0.0095- 07/31/2007 -0.0111 0.0255 0.0096 -0.0069 -0.0024 0.0043 08/31/2007 -0.0108 -0.0237 -0.0062 -0.0138 -0.0173 -0.0065 09/30/2007 0.0197 0.0477 0.0410 0.0331 0.0114 0.0322 -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 Bad Data
To recover also the date: x- read.table('d.dat', na.strings='-') x$V1- as.Date(x$V1, %m/%d/%Y) Hope it helps mario On 16-Mar-11 06:45, Rahul Kaura wrote: I created a couple of timeSeries objects - when I was merging them , I got an error. Looking at the data , I see that one of the time series has 06/30/2007 0.0028 0.0183 0.0122 0.0042 0.0095- 07/31/2007 -0.0111 0.0255 0.0096 -0.0069 -0.0024 0.0043 08/31/2007 -0.0108 -0.0237 -0.0062 -0.0138 -0.0173 -0.0065 09/30/2007 0.0197 0.0477 0.0410 0.0331 0.0114 0.0322 The - (first row, last column) is getting picked up from excel and is not a number How do I check for this and replace with zero [[alternative HTML version deleted]] -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] sprintf does not print
Use cat(sprintf('I did the the %d,%d \n',k,l)) The functions do not print in non interactive mode Hope it helps mario On 16-Feb-11 11:15, Alaios wrote: Dear all I have an sprintf inside a loop to track changes in variable's value. This sprintf statement works if I copy and paste it inside R sprintf('I did the the %d,%d \n',k,l) but when this is inside a loop I get no message. listcounter-1 for (k in c(1:mmax)){ # for (l in c(1:nmax)){ lst[[listcounter]]-fun(estimatedsr) listcounter-listcounter+1 sprintf('I did the the %d,%d \n',k,l) } } When I paste the code above I never get any message printed. I know that the loop works. When I kill the execution of the loop the listcounter variable has value different from the initial one. What might be the solution to that strange problem? Best Regards Alex __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] txtProgressBar examples?
Nice reference! I'm on Win 7 32 bits 2.12.0 and the first example fills the R console with ideograms and strange characters just by doing: pb - txtProgressBar(min = 0, max = 20, style = 3) Bug or feature? BTW the rest of the example works, as the whole example works on Linux. Ciao! mario On 15-Feb-11 13:41, Laurent Gatto wrote: 'R: Monitoring the function progress with a progress bar' [1] might b helpful. Laurent [1] http://ryouready.wordpress.com/2009/03/16/r-monitor-function-progress-with-a-progress-bar/ On 14 February 2011 18:32, Scott Chamberlainmyrmecocys...@gmail.com wrote: Dear R users, I am curious if someone could direct me towards websites/tutorials for uses of progress bars (especially) in R. I can't seem to figure them out. Thanks very much, Scott [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Grid drawing over the filled.contour's legend
Add the following lines before grid: # insert 3 lines of code, stolen from filled.contour(): mar.orig - par(mar) w - (3 + mar.orig[2]) * par(csi) * 2.54 layout(matrix(c(2, 1), nc = 2), widths = c(1, lcm(w))) Taken from thil list somewhere. Ciao! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Fwd: Re: [R-sig-hpc] Working doSNOW foreach openMPI example
Whas missing the R in the command line: mpirun -n --hostfile /home/hostfile R --no-save -f rtest.R Hope this helps mario On 13-Jan-11 22:08, Justin Moriarty wrote: Hi, Just wanted to share a working example of doSNOW and foreach for an openMPI cluster. The function eddcmp() is just an example and returns some inocuous warnings. The example first has each node return its nodename, then runs an example comparing dopar, do and a for loop. In the directory containing rtest.R it is run from the command line with: mpirun -n --hostfile /home/hostfile --no-save -f rtest.R Here is the code for rtest.R: # library(doSNOW) library(panel) cl-makeMPIcluster(3) registerDoSNOW(cl) clusterEvalQ(cl,library(panel)) res-clusterCall(cl, function(){Sys.info()[nodename]}) print(do.call(rbind,res)) sme- matrix(rnorm(100),10,10) clusterExport(cl,sme) myfun-function() { for(i in 1:1000) { x-eddcmp(sme) } } ged-0 system.time({ ged-foreach(i=1:10) %dopar% { myfun() } }) system.time({ ged-foreach(i=1:10) %do% { myfun() } }) system.time({ for(i in 1:10) { ged-myfun() } }) stopCluster(cl) mpi.quit() # Cheers, Justin [[alternative HTML version deleted]] ___ R-sig-hpc mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-hpc -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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-sig-hpc] Error in makeMPIcluster(spec, ...): how to get a minimal example for parallel computing with doSNOW to run?
Shouldn't -n be 4 in the bsub command? One master+3 slaves. This was required for snowfall, but I think doSNOW is similar. Hope it helps mario On 16-Dec-10 23:09, Marius Hofert wrote: Dear expeRts, I try to get a minimal example for parallel computing via foreach + doSNOW to run on a computer cluster (Brutus from ETH Zurich). The minimal example is given below. It runs perfectly fine on my MacBook but when I submit it as a batch job via ... bsub -n 3 -R select[model==Opteron8380] mpirun R --no-save -q -f doSNOW_minimal.R ... it does not work. The output is also given below. The error is Error in makeMPIcluster(spec, ...) : a cluster already exists 1. The only similar thing I found on the web is http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg35501.html but unfortunately, it was not answered. I also contacted the maintainers of the cluster, however, they couldn't really help me since they were no expeRts. Cheers, Marius Ps: As you an expeRt probably sees right away, I am a newby when it comes to parallel computing, so please check all the details (does the mpirun command makes sense? and the bsubs command [the batch system is LSF]?) and let me know if you need further. ## minimal example library(doSNOW) # loads foreach library(Rmpi) # for default in makeCluster() cl- makeCluster(3) # create cluster object with the given number of slaves registerDoSNOW(cl) # register the cluster object with foreach x- foreach(i = 1:3) %dopar% { # simple test sqrt(i) } x stopCluster(cl) # properly shut down the cluster ## minimal example ## output Sender: LSF Systemlsfad...@a6218 Subject: Job 921476:mpirun R --no-save -q -f doSNOW_minimal.R Done Jobmpirun R --no-save -q -f doSNOW_minimal.R was submitted from hostbrutus2 by userhofertj in clusterbrutus. Job was executed on host(s)3*a6218, in queuepub.1h, as userhofertj in clusterbrutus. /cluster/home/math/hofertj was used as the home directory. /cluster/home/math/hofertj was used as the working directory. Started at Thu Dec 16 22:16:31 2010 Results reported at Thu Dec 16 22:16:43 2010 Your job looked like: # LSBATCH: User input mpirun R --no-save -q -f doSNOW_minimal.R Successfully completed. Resource usage summary: CPU time : 6.96 sec. Max Memory : 3 MB Max Swap :29 MB Max Processes : 1 Max Threads: 1 The output (if any) follows: master (rank 0, comm 1) of size 3 is running on: a6218 slave1 (rank 1, comm 1) of size 3 is running on: a6218 slave2 (rank 2, comm 1) of size 3 is running on: a6218 library(doSNOW) # loads foreach Loading required package: foreach Loading required package: iterators Loading required package: codetools Loading required package: snow library(Rmpi) # for default in makeCluster() cl- makeCluster(3) # create cluster object with the given number of slaves Error in makeMPIcluster(spec, ...) : a cluster already exists 1 Calls: makeCluster - makeMPIcluster registerDoSNOW(cl) # register the cluster object with foreach Error in assign(data, data, pos = .foreachGlobals, inherits = FALSE) : object 'cl' not found Calls: registerDoSNOW - setDoPar - assign x- foreach(i = 1:3) %dopar% { # simple test +sqrt(i) + } Error in checkCluster(cl) : not a valid cluster Calls: %dopar% - Anonymous - clusterCall - checkCluster x Error: object 'x' not found stopCluster(cl) # properly shut down the cluster Error in stopCluster(cl) : object 'cl' not found [1] Please use mpi.close.Rslaves() to close slaves [1] Please use mpi.quit() to quit R ## output ___ R-sig-hpc mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-hpc -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Is there a way to have 'comment' keep a list?
Look at the help page, the example does exactly this by putting a two element vector of strings as comment. Hope it helps mario On 09-Nov-10 11:36, Tal Galili wrote: Hello all, I recently discovered the comment command. I see it can only hold a vector of characters. Is there a way (or an alternative), to make it possible to have it keep a list? (for example, to keep different pieces of information like date of creation, information of each variable and so on) The closest solution I can think of is using 'names' on the vector, like this: x- 1 comment(x)- letters names(comment(x))- LETTERS x comment(x) Any other suggestions? (or general best practices for the comment command ?) Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] FYI: The First Cloud Portal to “R”
I have found this on HPC in the Cloud. Maybe could be of interest to someone. SC10 Disruptive Technology Preview: The First Cloud Portal to “R” and Beyond http://www.hpcinthecloud.com/features/SC10-Disruptive-Technology-Preview--The-First-Cloud-Portal-to-R-and-Beyond-105776458.html Enjoy! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Artifacts in filled.contour+pdf
Thanks David! Indeed the printout is perfect. But this image (produced with higher resolution) should appear in a publication. I will ask to the author to check her copy of the manuscript, if it is acceptable. Anyway, thanks for the pointer to pdf doc. mario On 26-Oct-10 02:30, David Winsemius wrote: On Oct 25, 2010, at 6:50 AM, Mario Valle wrote: Dear all, I'm using R 2.12.0 on Windows 7 (32bits) I created a filled contour from the attached data using the following code: load('bug.RData') pdf('bug.pdf', width=14, height=7) filled.contour(o4$x, o4$y, o4$z, color=rainbow, xlim=c(4,18), ylim=c(0,35), zlim=c(14,36)) dev.off() If you look (I used acrobat reader 9.4) at the attached bug.pdf, you see an incomplete grid of gray lines. From the pdf help page: Note If you see problems with PDF output, do remember that the problem is much more likely to be in your viewer than in R. Try another viewer if possible. Symptoms for which the viewer has been at fault are apparent grids on image plots (turn off graphics anti-aliasing in your viewer if you) and missing or incorrect glyphs in text (viewers silently doing font substitution). Unfortunately the default viewers on most Linux and Mac OS X systems have these problems, and no obvious way to turn off graphics anti- aliasing. Are they there when printed? On a Mac I can make the lines in that pdf graphic appear and disappear in different places on my screen by changing the Page Display settings for Resolution in Acrobat Reader, and viewing in other applications like GraphicConverter I see even more lines tha I do in Acrobat Reader. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Artifacts in filled.contour+pdf
Thanks Baptiste! the problem with lattice (or more likely with my ignorance) is that it does not accept NA values. Ciao! mario On 26-Oct-10 07:38, baptiste auguie wrote: Hi, As an alternative, maybe you could use lattice::panel.levelplot.raster which I think doesn't have this problem in pdf viewers. HTH, baptiste On 26 October 2010 02:30, David Winsemiusdwinsem...@comcast.net wrote: On Oct 25, 2010, at 6:50 AM, Mario Valle wrote: Dear all, I'm using R 2.12.0 on Windows 7 (32bits) I created a filled contour from the attached data using the following code: load('bug.RData') pdf('bug.pdf', width=14, height=7) filled.contour(o4$x, o4$y, o4$z, color=rainbow, xlim=c(4,18), ylim=c(0,35), zlim=c(14,36)) dev.off() If you look (I used acrobat reader 9.4) at the attached bug.pdf, you see an incomplete grid of gray lines. From the pdf help page: Note If you see problems with PDF output, do remember that the problem is much more likely to be in your viewer than in R. Try another viewer if possible. Symptoms for which the viewer has been at fault are apparent grids on image plots (turn off graphics anti-aliasing in your viewer if you) and missing or incorrect glyphs in text (viewers silently doing font substitution). Unfortunately the default viewers on most Linux and Mac OS X systems have these problems, and no obvious way to turn off graphics anti-aliasing. Are they there when printed? On a Mac I can make the lines in that pdf graphic appear and disappear in different places on my screen by changing the Page Display settings for Resolution in Acrobat Reader, and viewing in other applications like GraphicConverter I see even more lines tha I do in Acrobat Reader. -- David. This artifact is not present if the output is PNG (attached, obtained in the above code using png('bug.png', width=800, height=400) instead of pdf()). Seems like a off-by-one bug. Is it a known bug? Is there any workaround? I tried lattice::contourplot but it does not support NA. Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 bug.pdfbug.png__ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] the function doesn´t work
The message is clear. Just resove this problem before posting a terribly general and so not useful it does not work. Best mario f=outer(p,m,Vectorize(power)) Error in outer(p, m, Vectorize(power)) : object 'p' not found persp(p,m,power,theta=-50,phi=30,d=4,border=black) Error in persp(p, m, power, theta = -50, phi = 30, d = 4, border = black) : object 'p' not found On 26-Sep-10 08:39, jethi wrote: hey, my function doesn´t work. can somebody help me? the graphic doesn´t work and also the function. thnx a lot. N=10 n=100 p_0=c(1/5,1-1/5) power = function(p,m) { set.seed(1000) H=matrix(0,nrow=N,ncol=1) for(i in 1:N) { x- matrix(rnorm(n, 0, 0.5), ncol = m) y- matrix(rnorm(n, 0, 0.8), ncol = m) l- diag(cor(x, y)) q_1 = qnorm(0.05, 0, 0.05) q_2 = qnorm(1 - 0.05, 0, 0.05) p- (l^2)/sum(l^2) H[i]- sum(p_0*log(p_0)) - sum(p * log(p)) } 1- mean(q_1= H H= q_2) } m=seq(10,50,len=10) f=outer(p,m,Vectorize(power)) persp(p,m,power,theta=-50,phi=30,d=4,border=black) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] the function doesn´t work
It is not a problem of not knowing R. It is a problem of reasoning. if you use m1 and not assign to it a value beforehand it is difficult your function works. And this will happen in any language, not only R. Maybe explaining what you are trying to do helps. To do this try to add comments (starting with #) to your code. Reading error messages is always useful too. Best mario On 26-Sep-10 09:28, jethi wrote: hi, sorry but i can´t remove the problem.but i change the programm a little bit. i didn´t work with r programm before, so its really hard for me to find my problems. :) N=5 n=100 p_0=c(1/5,1-1/5) power = function(k1) { set.seed(1000) H=matrix(0,nrow=N,ncol=1) for(i in 1:N) { x- matrix(rnorm(n, 0, 0.5), ncol =m1) y- matrix(rnorm(n, 0, 0.8), ncol = m1) l- diag(cor(x, y)) q_1 = qnorm(0.05, 0, 0.05) q_2 = qnorm(1 - 0.05, 0, 0.05) p- (l^2)/sum(l^2) H[i]- sum(p_0*log(p_0)) - sum(p * log(p)) } 1- mean(q_1= H H= q_2) } m1=seq(0,n/2,len=10) k1=1/m1 output- power(k1) f=outer(k1,Vectorize(power)) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] help me understand how things work.
print(k) and you see a lower triangular distance matrix. k[1] selects distances between 1 and 2 k[2] selects distances between 1 and 3 and so on. you have a distance matrix, not a single distance value, so you have to select which distance you need. Ciao! mario On 16-Sep-10 14:38, Alaios wrote: I fixed by adding this: k - sqrt(dist(temp)) k returns sort of a list. So I need to select the first item which is the result. a - k[1] Can someone explain me why k[1] is needed for that? Best Regards Alex *From:* Mario Valle mva...@cscs.ch *To:* Alaios ala...@yahoo.com *Sent:* Thu, September 16, 2010 1:28:31 PM *Subject:* Re: [R] help me understand how things work. ?dist BTW, to me this does not happens. x - matrix(rnorm(100), nrow=5) d - dist(x) 1/sqrt(d) 1/sqrt(dist(x)) Hope it helps mario On 16-Sep-10 12:02, Alaios wrote: Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp- rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 101 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailto: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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle http://www.cscs.ch/%7Emvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 problem with R
When j==1 for loops from i down to zero. 5:0 is valid and means c(5,4,3,2,1,0) Hope it helps mario Nam Lethanh wrote: Dear Guys, I do converting codes from Fortran into R and got stuck in solving LOOPING procedure with R. In FORTRAN, it is (DO and END DO) for looping in the net. In R, it is (FOR with { }). I believe there is something wrong with my coding in R, do hope that you can help me solving following problems. It seems easy, but results are not the same. *** WITH R theta-c(0.08,0.06,0.09,0) for (i in 1:4){ for (j in 1:4){ a-1.0 for (k in i:(j-1)){ a-a*theta[k] } print(a) } -- HERE GOES the results - numeric(0) [1] 0.08 [1] 0.0048 [1] 0.000432 numeric(0) [1] 0.0048 [1] 0.06 [1] 0.0054 numeric(0) [1] 0.000432 [1] 0.0054 [1] 0.09 numeric(0) [1] 0 [1] 0 [1] 0 * IN FORTRAN, the results is totally different. program calculating_a implicit none integer i, j, k double precision a, theta(4) theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0 do i=1, 4 do j=1, 4 a=1 do k=i,j-1 a=a*theta(k) end do print*, a end do end do end Here goes the results with FOTRAN - 1 0.06 4.79E-003 4.31E-004 1 1 0.08 7.2E-0.03 1 1 1 0.09 1 1 1 1 - Thank you! Nam [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] FYI: matrix surprise
Some time ago someone asked for things that make R difficult to master. Here I want to record one R behavior that took me off-guard yesterday. Moral of the story: vectorialize, but don't exaggerate. Hope it helps mario ### A very simple data frame tc - textConnection( prefix idx val A 1 11 A 2 22 B 1 33 B 2 44) s - read.table(tc, stringsAsFactors=FALSE, header=TRUE) close(tc) print(s) ### Matrix I want to fill with the data frame values y - matrix(NA, 2, 2) colnames(y) - c(A, B) ### This does not work. Same values in both columns y[s$idx, s$prefix] - s$val print(y) ### This works as expected for(i in 1:4) y[s$idx[i], s$prefix[i]] - s$val[i] print(y) ### And also this y[s$idx[c(1,2)], A] - s$val[c(1,2)] y[s$idx[c(3,4)], B] - s$val[c(3,4)] print(y) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Parallel computing on Windows (foreach)
On 15-Jun-10 17:07, Sergey Goriatchev wrote: Hello, I am reading Using The foreach Package document and I have tried the following: - sessionInfo() R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252 LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C LC_TIME=German_Switzerland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] foreach_1.3.0 codetools_0.2-2 iterators_1.0.3 x- numeric(1) system.time(for(i in 1:1) x[i]- sqrt(i)) user system elapsed 0.030.000.03 system.time(system.time(x- foreach(i=1:1, .combine=c) %do% sqrt(i))) user system elapsed 7.140.007.14 system.time(system.time(x- foreach(i=1:1, .combine=c) %dopar% sqrt(i))) user system elapsed 7.190.007.19 Warning message: executing %dopar% sequentially: no parallel backend registered Not only is the sequential foreach much slower than the simple for-loop (as least in this particular instance), but I am not quite sure how to make foreach run parallel. Where would I get this parallel backend? Use doMPI and run R through mpirun (for example run on 8 cores): mpirun -np 8 R --slave -f your-script.r Hope it helps mario I looked at doMC and doRedis, but these do not run on Windows, as far as I understand. And doSNOW is something to use when you have a cluster, while I have a simple dual-core PC. It is not really clear for how to make parallel computing work. Please, help. Regards, Sergey __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] drawing curve
x-c(1:6) y-c(.01,.09,.08,.03,.001,.02) plot(x,y, type='l') Please try ?plot before asking to the list. Ciao! mario On 10-Jun-10 12:11, suman dhara wrote: Sir, I have a problem regarding drawing curve.I pose the problem as follows: suppose I have two vectors: x-c(1:6) y-c(.01,.09,.08,.03,.001,.02) plot(x,y) It gives me the plotted points.But I want to draw a smooth curve passing througt these points. How can I do this? Thanks Regards, Suman Dhara [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Merge usage to update data.frame
Good morning! I have two datasets with the same structure, one containing all my values and the second one that update same of these values (see example below). I want to create a data.frame with all the values of the first dataset except when an entry is present in the second dataset, in which case the second dataset value is taken. Is there a better method than my last line kludge? Thanks for your help! mario t1 - textConnection(AAA 1 BBB 2 CCC 3) a - read.table(t1, stringsAsFactors=FALSE) close(t1) t2 - textConnection(BBB 22) u - read.table(t2, stringsAsFactors=FALSE) close(t2) m - merge(a, u, by=V1, all.x=TRUE) out - data.frame(V1=m$V1, V2=ifelse(is.na(m$V2.y), m$V2.x, m$V2.y)) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Merge usage to update data.frame
That is! Match, not merge is the solution. Ahhh, memory, memory... Thanks a lot! mario On 07-Jun-10 0:09, jim holtman wrote: try this: a V1 V2 1 AAA 1 2 BBB 2 3 CCC 3 u V1 V2 1 BBB 22 a$V2[match(u$V1, a$V1)]- u$V2 a V1 V2 1 AAA 1 2 BBB 22 3 CCC 3 On Sun, Jun 6, 2010 at 12:41 PM, Mario Vallemva...@cscs.ch wrote: Good morning! I have two datasets with the same structure, one containing all my values and the second one that update same of these values (see example below). I want to create a data.frame with all the values of the first dataset except when an entry is present in the second dataset, in which case the second dataset value is taken. Is there a better method than my last line kludge? Thanks for your help! mario t1- textConnection(AAA 1 BBB 2 CCC 3) a- read.table(t1, stringsAsFactors=FALSE) close(t1) t2- textConnection(BBB 22) u- read.table(t2, stringsAsFactors=FALSE) close(t2) m- merge(a, u, by=V1, all.x=TRUE) out- data.frame(V1=m$V1, V2=ifelse(is.na(m$V2.y), m$V2.x, m$V2.y)) -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] AM/PM strptime %p failing 2.11.0 WinXP
I know it is not very useful to you, but on Vista with 2.11.patched it works: strptime(5/20/2010 6:45:32 PM, %m/%d/%Y %I:%M:%S %p) [1] 2010-05-20 18:45:32 strptime(5/20/2010 6:45:32, %m/%d/%Y %I:%M:%S) [1] 2010-05-20 06:45:32 sessionInfo() R version 2.11.0 Patched (2010-04-26 r51822) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base Maybe you can try to set the LANGUAGE to English. Good luck! mario On 24-May-10 2:59, Samuel Dennis wrote: I am attempting to import dates in the following format to R: 5/20/2010 6:45:32 PM Unfortunately I am unable to get the AM/PM function (%p) to work correctly under either 2.11.0 or 2.8.1. strptime(5/20/2010 6:45:32 PM, %m/%d/%Y %I:%M:%S %p) [1] NA but strptime(5/20/2010 6:45:32, %m/%d/%Y %I:%M:%S) [1] 2010-05-20 06:45:32 showing that the problem is with %p. I could only find one previous mention of this issue in the archives ( http://tolstoy.newcastle.edu.au/R/e2/help/06/11/6272.html) , which provided no solution beyond upgrading R (which I have done), and just suggested it was a problem with that particular installation of R and Windows. What could I do to get this function working on my Windows XP machine? Thankyou, Samuel Dennis sjdenn...@gmail.com [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] apparent problems with the textConnection command
Is not a problem of textConnection. It it how strings work. In them \ is the escape character, so you have to enter \\ Hope it helps mario ravi wrote: Dear list, In my experiments in reading in text data, I have obtained some peculiar results. I would appreciate any help in understanding these results. Consider the following code : ## Reading in text data from a text file ### the first line of file f1.txt contains the text : c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin; f1-file(C:\\Ex\\f1.txt) c1-readLines(f1,1) c2-gsub(;,;\n,c1) cat(c2) close(f1) ### the above code gives exactly the results that I want # next, attempt to read the same text in via textConnection f2-textConnection(c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;) d1-readLines(f2) The results that I obtained (with an echo of the commands) were : f1-file(C:\\Ex\\f1.txt) c1-readLines(f1,1) c1 [1] c:\\Rtools\\bin;c:\\Rtools\\perl\\bin;c:\\Rtools\\MinGW\\bin; c2-gsub(;,;\n,c1) cat(c2) c:\Rtools\bin; c:\Rtools\perl\bin; c:\Rtools\MinGW\bin; close(f1) f2-textConnection(c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;) Error: '\R' is an unrecognized escape in character string starting c:\R What I would like to know : 1. The textConnection command is, from what I understand, usually used to test typical data in a text file. However, in my example, initial testing with this command fails while the longer step of reading from a text file succeeds. Is there any reason for this? Is there any workaround for the problem with the textConnection command ? 2. There appear to be similiar problem with the read.table command. Using the allowEscapes =TRUE did not seem to help. Is there some other option here? Like, for example, temporarily setting another character like as the escape character? I would like to explain here that these questions are not directly related to any real world problem solving. They are just my attempts to understand the R language better. Thanking you, Ravi __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Fitting a function
Have you tried Eureqa? http://ccsl.mae.cornell.edu/eureqa It tries to discover the model from your data. Try it, it is impressive (at least on my data). Ciao! mario On 14-May-10 15:07, Thomas Levine wrote: Actually, ignore my comment about that link. I don't think that link is what you want to look at either. y~x^2 fits quite well, but you could also write a loop to run lm() on a bunch of different transformations. foo=list(log,sqrt) for (bar in foo) { plot(bar(x),y) } There may be a function that does this already, but I couldn't find it either. Sorry for sending so many emails 2010/5/14 Thomas Levinethomas.lev...@gmail.com: I spoke too soon; that is not linear. I've never used the model-fitting functions, but you may check them out. http://developer.r-project.org/model-fitting-functions.txt Tom 2010/5/14 Thomas Levinethomas.lev...@gmail.com: x-c(0.5,4,6,8,12) y-c(0.021,0.021,0.020,0.018,0.012) lm(y~x) 2010/5/14 Dani Valverdedaniel.valve...@uab.cat: Hello, It is a very naive question, but here it is. I have this values: x: 0.5 4 6 8 12 y: 0.021 0.021 0.020 0.018 0.012 I need to fit a function to them. How can I do it with R? Thank you so much! Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Tlf. +34 93 581 1910 Fax: +34 93 581 1573 __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] sprintf funny behavior
Not always the result of a function is printed on screen. Use: for(i in 1:4) print(sprintf(%d,4)) ciao! mario Matt Young wrote: sprintf(%d,4) [1] 4 for(i in 1:4) sprintf(%d,4) for(i in 1:4) print(4) [1] 4 [1] 4 [1] 4 [1] 4 Why doesn't sprintf like the for loop here __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 make legend with line+ character
Dear all, I have a multiline plot with each line labeled with a different letter. But I'm not able to make the legend display the same kind of pattern '-a-', instead the letter is overwritten by the line. A simpler legend with only the letter is not very visible and the pt.bg does nothing with letters. Any idea? plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') legend(left, legend=c(ds1,ds2), bty='n', col=1:2, lty=2,lwd=4,pch=letters) Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 make legend with line+ character
Thanks Uwe and Henrique! Both solution works and both have the same niceness/work.required ratio :-) Thanks again! mario On 26-Apr-10 14:02, Uwe Ligges wrote: On 26.04.2010 13:32, Mario Valle wrote: Dear all, I have a multiline plot with each line labeled with a different letter. But I'm not able to make the legend display the same kind of pattern '-a-', instead the letter is overwritten by the line. A simpler legend with only the letter is not very visible and the pt.bg does nothing with letters. Any idea? plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') legend(left, legend=c(ds1,ds2), bty='n', col=1:2, lty=2,lwd=4,pch=letters) I'd fake it rather quickly using lty=14 Uwe Ligges Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 make legend with line+ character
Thanks John and thanks to all! Seems this requires a lot of effort anyway. So maybe it is better to take a different approach: take the legend out of the chart and put it on a plot.new() on the right of the chart, use only colored letters but make them larger to be visible. Thanks! mario On 27-Apr-10 0:54, John Kane wrote: I suspect that you may have to construct the legend by hand (well, by explicit text commands anyway) Something like this seems to work and it should not be that difficult to write a function to handle the text commands. plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') text(1.4,6, label=-a- , col=red) text(2.5,6, label=dg1) --- On Mon, 4/26/10, Mario Vallemva...@cscs.ch wrote: From: Mario Vallemva...@cscs.ch Subject: [R] How to make legend with line+ character To: r-help@r-project.orgr-help@r-project.org Received: Monday, April 26, 2010, 7:32 AM Dear all, I have a multiline plot with each line labeled with a different letter. But I'm not able to make the legend display the same kind of pattern '-a-', instead the letter is overwritten by the line. A simpler legend with only the letter is not very visible and the pt.bg does nothing with letters. Any idea? plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') legend(left, legend=c(ds1,ds2), bty='n', col=1:2, lty=2,lwd=4,pch=letters) Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] macro variable in R?
Why don't use a list? m - list() for(i in 1:10) { m[[i]] - matrix(NA, i, i) } then access them as m[[7]][1,6] Ciao! mario On 22-Apr-10 18:08, karena wrote: I need to create 10 matrices. say matrix 1-10. matrix_1 is 1 by 1 matrix_2 is 2 by 2 matrix_3 is 3 by 3 . . . matrix_10 is 10 by 10 I am just wondering if there are some functions in R that are similar to the macro variables in SAS. so I can create these 10 matrices by doing: for (i in 1: 10) { matrix_$i- matrix(nrow=i, ncol=i) } rather thank creating these matrices one by one manually. Anyone have any suggestions? thanks, karena -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Unexpected warning from matplot
n - 63 a - 1:n x - a-1 y - outer(x,a) matplot(x,y,type='l') Warning message: In matplot(x, y, type = l) : default 'pch' is smaller than number of columns and hence recycled Why is it complaining if I specifically ask for type=l, so no pch involved? Annoyance or feature? The fix (if needed) is simple. In the matplot code change: if (is.null(pch)) { to: if (is.null(pch) (type[1] %in% c('p','b','o'))) { Best regards mario P.S.: R 2.9 on Win and Linux -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Confusing concept of vector and matrix in R
Reframe the problem. Rethink why you need to keep dimensions. I never ever had to use drop. My .02 something mario Barry Rowlingson wrote: On Tue, Mar 30, 2010 at 2:42 AM, Rolf Turner r.tur...@auckland.ac.nz wrote: Well then, why don't you go away and design and build your own statistics and data analysis language/package to replace R? You can then make whatever design decisions you like, and you won't have to live with the design decisions made by such silly and inept people as John Chambers and Rick Becker and their ilk. Aah, argument by (ironic) reference to learned authority! Even Einstein was wrong (God does not play dice). He was also right, thought he was wrong, and then we've discovered he may have been right all along (The Cosmological Constant, Dark Energy etc). How many of us have _never_ interfaced our foreheads with the keyboard when something breaks because we didn't put ,drop=FALSE in a matrix subscript? There is no doubt that R plays fast and loose with many concepts of type and structure that Computer Scientists would turn their nose up at. I would love to go away and redesign it, but I'd just end up with python. Truth is that R's statistical power is what makes it great because of the vast wealth of CRAN, not the R language per se with its features that so fluster my comp-sci friends. And many a beginner. We work round them by bashing our heads on the keyboards, typing ,drop=FALSE, and vowing never to do it again. And writing more unit tests. Barry __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] printing text within if functions inside a for loop
Use: cat(sprintf(Long on %s at a price of %f\n,dates[j],data[j])) Hope it helps mario Tian Pan wrote: Hi I am having a problem with outputting text inside an if function. I have the following code: for (j in 20:length(bb.up)) { if (up[j]==1 up[j-1]==0) { sprintf(Long on %s at a price of %f,dates[j],data[j]) } if (down[j]==1 down[j-1]==0) { sprintf(Short on %s at a price of %f,dates[j],data[j]) } } The loop runs fine and the sprintf function runs fine on its own, but the problem I am having is that there is no output if I run the loop with the sprintf inside it. Does anyone know what could be wrong? Is there a way for the code to output data within this loop? I can't seem to find anything on the internet for this problem. Thanks in advance. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Creating images without X11
Is it possible the problem is another? I cannot generate png images when R runs on a machine without *installed* X11 Here is the error message when I submit a simple png() plot on a computing node of my cluster. Error in X11(paste(png::, filename, sep = ), width, height, pointsize, : unable to start device PNG Calls: png In addition: Warning message: In png(Test.png) : unable to open connection to X11 display '' Execution halted The solution for my problem is to generate pdf files (that are then included in a LaTeX paper, so the solution does not help you). Ciao! mario On 14-Mar-10 6:14, Sharpie wrote: Jillian E Kozyra wrote: Dear Colleagues, We are attempting to create trees using R with our Ruby on Rails application. However, we are running into a problem involving the creation of the graphic. We would like them to be in either jpg or png format so that users can save, but due to a lack of control over our sever we are unable to start X11 server. Is there a way to create these images without using X11 server? Thanks, JIllian I had this exact same problem last summer when attempting to set up an automated process involving image generation on a remote server. Since I didn't have admin rights to the server, I ended up switching to the Cairo package for image generation as it uses the Cairo library rather than X11 as the back end. The other solution involved setting some sort of obscure, arcane X11 permission that I can't recall right now. All I can recall is that finding it was a frustrating half-day of Google searching and digging through man pages. I would suggest Cairo. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] looking for a package to solve current-voltage equation I=f(I)
?optim RSiteSearch(nonlinear equation solver) CRAN task view (optimization) Do a little work for your own before asking other to work for you. mario On 12-Mar-10 13:25, PtitBleu wrote: Hello, I'm looking for a R-package to solve such an equation : http://n4.nabble.com/file/n1590462/iv.png which is one current-voltage equation of a solar cell. Thanks in advance, Ptit Bleu. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] IMPORTANT - To remove the null elements from a vector
x - x[x != 0] If for null elements you intend the value of zero. Ciao! mario On 09-Mar-10 13:48, barbara.r...@uniroma1.it wrote: I have a vector that have null elements. How to remove these elements? For example: x=[10 0 30 40 0 0] I want the vector y=[10 30 40] Thanks [[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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 create a SVG plot
library(cairoDevice) Cairo_svg() On 04-Mar-10 8:13, Lesong Tsai wrote: Hi! I want to know how to create a SVG plot with R. savePlot() can't make it . waiting for your answer. thank you . -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Output to sequentially numbered files... also, ideas for running R on Xgrid
write.csv(x, file=sprintf(prefix%05d.csv, n)) On 02-Mar-10 23:26, JWC wrote: Hello, I have some code to run on an XGrid cluster. Currently the code is written as a single, large job... this is no good for trying to run in parallel. To break it up I have basically taken out the highest level for-loop and am planning on batch-running many jobs, each one representing an instance of the removed loop. However, when it comes to output I am stuck. Previously the output was an array of [x, y, i] dimensions. The removed for-loop ran through i, each iteration filling a x-y slice of the output array. Now the function returns a single xy matrix for a supplied, single value of i. Is there a way to output to sequentially numbered csv files such that they can be reconstituted into the [x, y, i] array? I have tried: write(x, file=get(n)) Where n is the value of i the function is running for. But I get the error: 'file' must be a character string or connection Is there a way of writing out to a csv file numbered with the value of a variable? Also, is this a very complicated way of parallelising this function? Many thanks, Joe -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] two questions for R beginners
My difficulties: 1) Statistics :-) well, I'm learning. 2) Understand what is available *per subject area*. Something like the task view for packages, should be compiled for basic commands/functions. Like: all things related to string manipulation, all things related to number formatting, all *apply things, and so on. Something similar is available for C runtime library functions (like in http://msdn.microsoft.com/en-us/library/2aza74he(VS.71).aspx ) and is really useful, also to expand the number of functions known. 3) The Diktakt-like: avoid for loops! without clear examples of alternatives. I have found them later in the maillist, but at the beginning it is not simple, especially coming from C/C++. 4) for statement behavior different from C/C++: for(i in 1:0) counts backward instead of stopping. 5) missing small things like ++var On the positive side: - it is not too difficult to setup something simple to create a decent chart. - it is possible to use for loops without feeling guilty. :-) - documentation is very well done. Maybe some page are still clear only to who already know the argument. - there are zillions of courses/papers/tutorials to read - after studying R by myself, now I'm becoming the local R expert, that from a workplace point of view is not bad... Hope it helps. Ciao! mario Ivan Calandra wrote: Since you want input from beginners, here are some thoughts I had and still have two big problems with R: - this vectorization thing. I've read many manuals (including R inferno), but I'm still not completely clear about it. In simple examples, it's fine. But when it gets a bit more complex, then... Related to it, the *apply functions are still a bit difficult to understand. When I have to use them, I just try one and see what happens. I don't understand them well enough to know which one I need. - the second problem is where to find the functions/packages I need. There are many options, and that's actually the problem. R Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with R, you discover that the capabilities of R are almost unlimited and you don't really know where to start, where to find what you need. As noted in earlier posts, the mailing list is really great, but some people are really hard with beginners. It was noted in a discussion a few days ago, but it looks like some don't realize how difficult it is at the beginning to formulate a good question, clear, with self-contained example and so on. Moreover, not everybody speaks English natively. I don't mean that you must help, even when the question is really vague and not clear and whatever. I'm just saying that if you don't want to help (whatever the reason), you don't have to say it badly. But in any cases, the mailing list is still really helpful. As someone noted (sorry I erased the email so I don't remember who), it might be a good idea to split it. Hope that's what you wanted Ivan Le 2/26/2010 08:39, Dieter Menne a écrit : Patrick Burns wrote: * What were your biggest misconceptions or stumbling blocks to getting up and running with R? (This derives partly from teaching) The fact that this xapply-stuff was not idempotent (worse: not always) and that you need a monster like do.call() to straighten this out. Nowadays, plyr comes close. The concept of environment. With S it was worse, though. That you cannot change values passed by reference. I noted that the latter is no problem for students who have not worked with c(++/#) before. That there is only one return-result in functions. [ and the likes as an operator. 10 years ago, when I started, the message was: S4 is the future, S3 is legacy. So I learned S4. Only to never use is in self-written code later. Might be different for BioConductor people. That sometimes you can use vectors not in data= (lattice), and sometimes not (ggplot2). Still a VERY confusing inconsistency. The why-does-this-not-print FAQ. Why does par(oma..) not work with lattice? 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] multicore in R
Why don't use the mclapply() function? It takes care of everything. mario On 25-Feb-10 8:56, dikshie wrote: Hi, i have a function: zz- (constrOptim(c(.5,0), fr, grr, ui=rbind(c(-1,0),c(1,-1)), ci=c(-0.9,0.1))) i can get the result by using command (for example): zz$par now if i can use multicore: zz-parallel(constrOptim(c(.5,0), fr, grr, ui=rbind(c(-1,0),c(1,-1)), ci=c(-0.9,0.1))) result collect(zz) i cant get my the result: result$par because multicore add process id. for example: $`2493`$par [1] 0.8891335 0.7891335 i try to get the result by: result$`processID(zz)`$par but it return NULL. so any idea how to get the result? with best regards, -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Where can I find general help on statistics?
Could you suggest where I could post general statistical/data analysis questions? For now I have found: http://talkstats.com/ and http://www.statisticsforums.com/ Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] strange behaviour of median
Linux 2.9.0 gives: median(df1) [1] 34 Ever stranger... mario Petr PIKAL wrote: During some experimentation in preparing R lessons I encountered this behaviour which I can not explain fully mat - matrix(1:16, 4,4) df1 - data.frame(mat) mean(df1) X1 X2 X3 X4 2.5 6.5 10.5 14.5 Expected, documented median(df1) [1] 6.5 10.5 Rather weird, AFAIK there shall not be an issue with data frame at least I did not find any in help page. I tracked it down probably to an As.Is operation with object and subsequent sorting in median.default. I know other (*apply) ways how to compute median for data frames so I just would like to hear an opinion about this behaviour from more experienced people. Thank you Best regards Petr __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 fitdistr
Try to pass a start value to help optim (see ?fitdistr) Ciao! mario vikrant wrote: Hi, I want to estimate parameters of weibull distribution. For this, I am using fitdistr() function in MASS package.But when I give fitdistr(c,weibull) I get a Error as follows:- Error in optim(x = c(4L, 41L, 20L, 6L, 12L, 6L, 7L, 13L, 2L, 8L, 22L, : non-finite value supplied by optim Any help or suggestions are most welcomed -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Mutliple sets of data in one dataset....Need a loop?
Great example Glen! I want to add simply a small thing that could be useful to someone. Suppose in your last step you want to change the line color for each chart. Using a for loop it is simple to use the integer index to access the df.lst elements and set the color: for(i in 1:length(df.lst)) plot(df.lst[i]$x, df.lst[i]$y, color=colors[i]) To do it 'lapply-style' use mapply: mapply(function(d, i) plot(d$x, d$y, color=colors[i]), dl, 1:length(dl)) Ciao! mario Glen Sargeant wrote: One way to plot subsets of data identified by a grouping variable is to use lapply() on a list of subsets. The approach is worth mentioning because similar tactics are useful for many problems. #List of unique values for grouping variable #that is not necessarily a factor names - as.list(unique(df$Experiment)) #List of dataframes; 1 for each unique value of grouping variable df.lst - lapply(names,function(name)subset(df,Experiment==name)) #Name components of the list #Not necessary in this case... but permits indexing by level #of the grouping variable names(df.lst) - names #Now you can use lapply() to carry out the same operation on #each component of your list. For example, to send plots to #a pdf with 1 page for each component: pdf(plot.pdf) lapply(df.lst,function(df)plot(df[,2],df[,3])) dev.off() - Glen Sargeant Research Wildlife Biologist -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 on plot in R with mac
You have redefined the plot function somewhere. Check your saved environment. mario On 20-Jan-10 15:36, khaz...@ceremade.dauphine.fr wrote: Hello all My computer is MacBook and I want to draw a plot in R, for example for x- c(1,3,6,9,12) y- c(1.5,2,7,8,15) I use this command plot(x,y) to do but I see this massage: Erreur dans plot(Di, g) : argument(s) inutilisé(s) (c(1, 2, 3), c(12, 23, 34)) Could you please help me? Thank you khazaei __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] density() vs. KernSmooth::bkde
Any advice when to use denstity() and when the KernSmooth package bkde() to smooth a histogram? No specific problem to use either one, but I'm curious why there are two so similar implementations. Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] density() vs. KernSmooth::bkde
Thanks Prof. Ripley! Indeed the correct comparison is between density() and the more modern GenKern::KernSec() and in this case the difference is negligible, so I will use density() for my work. Thanks! mario On 18-Jan-10 13:57, Prof Brian Ripley wrote: On Mon, 18 Jan 2010, Mario Valle wrote: Any advice when to use denstity() and when the KernSmooth package bkde() to smooth a histogram? No specific problem to use either one, but I'm curious why there are two so similar implementations. They are fundamentally different. density() uses FFT: bkde() does not and is more flexible as a result Both use binning. There are only a limited number of ways to implement something as simple as KDE, and most of them have appeared in R/S-PLUS. Remember that KernSmooth was written for S-PLUS and predates R (at least in anything like its current form). Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] optim: abnormal termination in lnsrch
I'm using optim() to minimize a certain function. Often the minimization ends with the message: ERROR: ABNORMAL_TERMINATION_IN_LNSRCH What is optim() trying to say? What have I to change in my function to make the minimization succeed? Do you think using BBoptim() instead of optim() changes anything? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] optim: abnormal termination in lnsrch (resend)
[sorry, forgot some details...] I'm using optim(param, fun, method='L-BFGS-B', lower=lo, upper=up) to minimize a certain function. Often the minimization ends with the message: ERROR: ABNORMAL_TERMINATION_IN_LNSRCH What is optim() trying to say? What have I to change in my function to make the minimization succeed? Do you think using BBoptim() instead of optim() changes anything? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] optim: abnormal termination in lnsrch (resend)
Attached a script that reproduces the problem. My function is fold.val() and at the end seems the curve contained in lnsrch.dat is fitted quite well, but optim generates the error. Thanks again! mario - I'm using optim(param, fun, method='L-BFGS-B', lower=lo, upper=up) to minimize a certain function. Often the minimization ends with the message: ERROR: ABNORMAL_TERMINATION_IN_LNSRCH What is optim() trying to say? What have I to change in my function to make the minimization succeed? Do you think using BBoptim() instead of optim() changes anything? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 x1 - seq(0, 1, 0.1) fold.val - function(x, mu, vr, thresh, smooth) { a - pnorm(x1, mean=thresh, sd=smooth) d - dnorm(x1, mean=mu, sd=sqrt(vr)) y - d*(1-a) yr - rev(d*a) xr - rev(2*thresh-x1) yr1 - approx(xr, yr, x1)$y yr1[is.na(yr1)] - 0 return(approx(x1, y+yr1, x)$y) } fold.err - function(p, xx, yy) { r - fold.val(xx, mu=p[1], vr=p[2], thresh=p[3], smooth=p[4]) return(sum((r-yy)^2)) } h - read.table(lnsrch.dat, col.names=c('x', 'y')) param - c(.413, 0.00687, .5228, .01255) up- c(.45, 0.0072, .53, .014) lo- c(.4, 0.0060, .52, .011) m - optim(param, fold.err, xx=h$x, yy=h$y, method='L-BFGS-B', lower=lo, upper=up) cat(m$message, \n) plot(h$x, h$y, type='l', xlab='Distance', ylab='Density') lines(h$x, fold.val(h$x, mu=m$par[1], vr=m$par[2], thresh=m$par[3], smooth=m$par[4]), lty=3, lwd=2, col='orange') 0 0.000176362361606926 0.000586510263929619 0.000231378280914905 0.00117302052785924 0.000295589496143618 0.00175953079178886 0.000368478469738331 0.00234604105571848 0.000449107043434096 0.00293255131964809 0.00053621721990612 0.00351906158357771 0.000628406534146135 0.00410557184750733 0.000724352089678939 0.00469208211143695 0.000823019379524589 0.00527859237536657 0.000923769963807285 0.00586510263929619 0.0010263098797736 0.0064516129032258 0.00113046157071014 0.00703812316715543 0.00123574038696884 0.00762463343108504 0.00134128566231542 0.00821114369501466 0.00144585907333914 0.00879765395894428 0.00154814766557669 0.0093841642228739 0.00164720012094507 0.00997067448680352 0.00174279078421419 0.0105571847507331 0.00183552090932921 0.0111436950146628 0.00192657682698567 0.0117302052785924 0.00201721475915703 0.012316715542522 0.0021081579678769 0.0129032258064516 0.00219912372548760 0.0134897360703812 0.00228864332012703 0.0140762463343109 0.00237423713314793 0.0146627565982405 0.00245290831576602 0.0152492668621701 0.00252185164895379 0.0158357771260997 0.00257923683549348 0.0164222873900293 0.00262490019714924 0.0170087976539589 0.00266075875058930 0.0175953079178886 0.00269076521650816 0.0181818181818182 0.00272028739787151 0.0187683284457478 0.00275494219114877 0.0193548387096774 0.00279911977041479 0.0199413489736070 0.00285462086919127 0.0205278592375367 0.00291989826644678 0.0211143695014663 0.00299027032424890 0.0217008797653959 0.00305916799687892 0.0222873900293255 0.0031200913977286 0.0228739002932551 0.00316865054306491 0.0234604105571848 0.00320399165284089 0.0240469208211144 0.00322911512411607 0.024633431085044 0.00325009141115046 0.0252199413489736 0.00327448251393837 0.0258064516129032 0.00330863483141881 0.0263929618768328 0.00335664878021895 0.0269794721407625 0.00341998836253680 0.0275659824046921 0.00349792087037627 0.0281524926686217 0.00358846480856140 0.0287390029325513 0.00368937637895126 0.0293255131964809 0.00379878944173669 0.0299120234604106 0.00391534984847043 0.0304985337243402 0.00403793448762949 0.0310850439882698 0.00416520590831426 0.0316715542521994 0.00429527045546386 0.032258064516129 0.00442560376781198 0.0328445747800587 0.00455325817307603 0.0334310850439883 0.00467525233059903 0.0340175953079179 0.00478900552079331 0.0346041055718475 0.00489270623934628 0.0351906158357771 0.0049809321012 0.0357771260997067 0.00506785770230776 0.0363636363636364 0.00514095495458048 0.036950146627566 0.00520698251869515 0.0375366568914956 0.00526847101068982 0.0381231671554252 0.00532783817372676 0.0387096774193548 0.00538686868362264 0.0392961876832845 0.00544630067045661 0.0398826979472141 0.00550562536463334 0.0404692082111437 0.00556316103457661 0.0410557184750733 0.00561640167932586 0.0416422287390029 0.00566258222546389 0.0422287390029326 0.00569935446480522 0.0428152492668622 0.00572527363548914 0.0434017595307918 0.00574066288496805 0.0439882697947214 0.00574780398040942 0.044574780058651 0.00575013267506571 0.0451612903225806 0.00575179443458933 0.0457478005865103 0.00575684258138564 0.0463343108504399 0.00576851671527049 0.0469208211143695
Re: [R] Distance between sets of points in transformed environmental space
silhouette coefficients? It measure for each point how similar is to its cluster other points and how dissimilar from the points of other clusters. P.N. Tam, M. Steinbach, V. Kumar, Introduction to data mining, Addison-Wesley, 2006 page 541 Hope it helps. mario Charlotte Maia wrote: Well, here's another naive post from me (hopefully better than the last one). Firstly I'm not sure computing euclidean distance is that simple. I would assume temperatures and precipitation would need to be standardised in some way. I think the notion of how far away something is, and how distinct location wise something is, are quite different, so maybe two measures? For distance per se, I think your first idea is the best. Plus simple is always good... For distinctness, given one one of two sets, for each point, you could just compute the closest point to it. If the closest point is a member of the same set, we will call that a + point, if the closest point is a member of the other set, we will call it a - point. In principle the measure of distinctness would be the sum of the +'s, however there might need to be some scaling to take into account the number of points in each set. There are also a lot of fancy things out there, so someone will probably come up with a much fancier (and possibly better) idea than this. Well, that's just my rant, before I go to bed. kind regards -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Learning R - View datasets
guohao.hu...@gmail.com wrote: Please check the following pdf file. http://tw.nextmedia.com/applenews/article/art_id/32119622/IssueID/20091127 Besides a beautiful blond girl, I do not recognize any pdf here... Could you provide a direct link? Thanks! mario 1. First install.packages(Flury) 2. library(Flury) 3. data(wines) 'wines’ is a data frame with 26 observations, one factor denoting the country of origin and 15 quantitative variables denoting 15 free monoterpenes and C[13]-norisoprenoids. It is thought these influence the wine’s aroma. Country a factor with levels South Africa Germany Italy Y1 a numeric vector Y2 a numeric vector Y3 a numeric vector Y4 a numeric vector Y5 a numeric vector Y6 a numeric vector Y7 a numeric vector Y8 a numeric vector Y9 a numeric vector Y10 a numeric vector Y11 a numeric vector Y12 a numeric vector Y13 a numeric vector Y14 a numeric vector Y15 a numeric vector If you do not know how to get these value, you can read ``R introduction''. I hope this can help you. Guo-Hao Huang -- From: Brock Tibert btibe...@yahoo.com Sent: Friday, November 27, 2009 12:46 PM To: r-help@r-project.org Subject: [R] Learning R - View datasets Hi All, I am making a serious effort to try to learn R, but one hurdle I am facing is that I need to see the data as I walk through the examples in the packages. For instance, many examples on the web start by a command like data(wines). How can I actually view what the dataset looks like prior to transformations and analysis? I have tried to use edit() , print, and head. In short, I know that data() lists all of the available datasets, data(wines) will load the dataset wines, but how can I look at the raw data? I figure this is probably an easy question, but any help you can provide will be greatly appreciated. Thanks, Brock __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] snowfall: missing MPI node
Hello, I don't know if the question pertains to Rmpi, snow or snowfall. I run my job by: mpirun -np N -hostfile $PBS_NODEFILE RMPISNOW -f my-script.r --slave In the snowfall sfInit call I have to specify one less CPU respect to the mpirun call sfInit(parallel=TRUE, cpus=N-1, type=MPI) otherwise I receive an error similar to: cluster size N-1 already running (sorry I don't remember the exact message) Is this normal? In this case, if I want to call my script with - --cpus option I have to resort to inelegant shell scripting to obtain N-1 from the -mp argument. In any case, is it possible to know in the script the number of processes (-np #) requested to mpirun? Thanks for your time! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] snowfall: sfExport apparently harmless error
I'm running my script using mpirun -mp 4 and using snowfall+Rmpi on Linux 64bits. I receive the following error, but apparently without consequences on the results. Any idea? I'm able to reproduce it with a minimal script (below). Seems the critical issue is the for loop. Without it no error. Thanks for your help! TERM: Undefined variable. TERM: Undefined variable. TERM: Undefined variable. TERM: Undefined variable. Loading required package: utils Loading required package: utils Loading required package: utils Loading required package: utils Library Rmpi loaded. snowfall 1.70 initialized: parallel execution on 3 CPUs. Error in unserialize(obj) : unknown input format Calls: sfExport ... mpi.recv.Robj - .mpi.unserialize - unserialize - .Call Execution halted MPI Application rank 0 exited before MPI_Finalize() with status 1 /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 15028 Terminated R --no-save $* /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 23906 Terminated R --no-save $* /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 22094 Terminated R --no-save $* --- script library('Rmpi', verbose=FALSE) library('snowfall', verbose=FALSE) # Initialize cluster sfInit(parallel=TRUE, cpus=3, type=MPI) for(i in 1:2) { # Prepare fake data n - 46000 x - runif(n, 0.02, 0.54) logx - log(x) sfExport(logx) # Compute fake function computeTakens - function(r0idx) { if(r0idx == 1) return(NA) return(1/(logx[r0idx] - sum(logx[1:(r0idx-1)])/(r0idx-1))) } res - sfClusterApplyLB(n:1, computeTakens) } sfStop() -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] (correction) snowfall+Rmpi: sfExport error
Sorry for wasting your time with an incorrect diagnosis in my previous mail! I'm running my script using mpirun -mp 4 and using snowfall+Rmpi on Linux 64bits. I receive the following error, that terminates the run. Any idea? I'm able to reproduce the problem with a minimal script (below). If n 16371 it completes 9 iterations without problems. Already at 16371 it dies at iteration 7 (with the error below). This value of n is suspiciously close to 2^14 (16kb). So maybe it is a configuration problem of my MPI installation. Or it is an undocumented limitation of snowfall/snow/Rmpi. My real variable size is around 10, so I prefer not to implement workarounds to sfExport variables whose size is 16k. If you can point me in the right direction will be really helpful. Thanks! mario TERM: Undefined variable. TERM: Undefined variable. TERM: Undefined variable. TERM: Undefined variable. Loading required package: utils Loading required package: utils Loading required package: utils Loading required package: utils Library Rmpi loaded. snowfall 1.70 initialized: parallel execution on 3 CPUs. Error in unserialize(obj) : unknown input format Calls: sfExport ... mpi.recv.Robj - .mpi.unserialize - unserialize - .Call Execution halted MPI Application rank 0 exited before MPI_Finalize() with status 1 /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 15028 Terminated R --no-save $* /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 23906 Terminated R --no-save $* /users/mvalle/snow/snow/inst/RMPISNOW: line 40: 22094 Terminated R --no-save $* --- script library('Rmpi') library('snowfall') sfInit(parallel=TRUE, cpus=3, type=MPI) for(i in 1:9) { n - 2 logx - runif(n, 0.02, 0.54) sfExport(logx) } sfStop() -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Running two R instances at the same time
Why instead you don't explore packages 'multicore' or 'snow+showfall (using sockets)'? Ciao! mario Peter Juhasz wrote: Dear R experts, please excuse me for writing to the mailing list without subscribing. I have a somewhat urgent problem that relates to R. I have to process large amounts of data with R - I'm in an international collaboration and the data processing protocol is fixed, that is a specific set of R commands has to be used. I wrote a perl program that manages creation of data subsets from my database and feeds these subsets to an R process via pipes. This worked all right, however, I wanted to speed things up by exploiting the fact that I have a dual-core machine. So I rewrote my perl driver program to use two threads, each starting its own R instance, getting data off a queue and feeding it to its R process. This also worked, except that I noticed something very peculiar: the processing time was almost exactly the same for both cases. I did some tests to look at this, and it seems that R needs twice the time to do the exact same thing if there are two instances of it running. I don't understand how is this possible. Maybe there is an issue of thread-safety with the R backend, meaning that the two R *interpreter* instances are talking to the same backend that's capable of processing only one thing at a time? Technical details: OS was Ubuntu 9.04 running on a Core2Dou E7300, and the R version used was the default one from the Ubuntu repository. Please see http://www.perlmonks.org/?node_id=792460 for an extended discussion of the problem, and especially http://www.perlmonks.org/?node_id=793506 for excerpts of output and actual code. Thanks for your answers in advance: Péter Juhász __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Submit a R job to a server
Bernd Bischl wrote: Noah Silverman wrote: Deb, I generally run my larger R tasks on a server. Here is my workflow. 1) Write an R script using a text editor. (There are many popular ones.) 2) FTP the R script to your server. 3) SSH into the server 4) Run R 5) Run the script that you uploaded from the R process you just started. Dear Debrata, if this is what you mean by submitting a job, so just login in remotely and starting the job manually, you can do what Noah suggested in a more convenient way: - many Scp / Ftp applications allow editing on the server, meaning you don't have to transfer the file after every change manually. I use a combination of winscp and Notepad++ normally for this. Notepad++ has an integrated ftp client very useful for this kind of things (and for editing a web site too). Ciao! mario - read the man pages of the unix command screen (by typing man screen on the server) to see how to get a permanent session that stays there for you, after you detach from it. Be sure to test your scripts on your local system before with easy (and faster examples). For packages: The same requirements apply to the R on server as for your local system, you simply need the same packages there. Bernd __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Subsample points for mclust
Nothing is better than asking help to find the answer by myself... Page 47 of the technical report (tr504.pdf) deals exactly with the problem of big datasets. Also I found that mclust is too much for my problem, the optimum number of Gaussian suggested is way too high. For example for one dataset (downsampled to 1/10) it suggests 9 Gaussian, but the central 7 sum with good approximation to a single Gaussian, so the dataset is better decomposed into only 3 Gaussian. I admit I'm not rigorous at all... Bye! mario Mario Valle wrote: Hi all! I have an ordered vector of values. The distribution of these values can be modeled by a sum of Gaussians. So I'm using the package 'mclust' to get the Gaussians's parameters for this 1D distribution. It works very well, but, for input sizes above 100.000 values it starts taking really forever. Unfortunately my dataset has around 4.6M values... My question: is it correct to subsample my dataset taking a value every N to make mclust happy? Or have I no alternative except using the complete dataset? Excuse my profound ignorance and thank for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Subsample points for mclust
Hi all! I have an ordered vector of values. The distribution of these values can be modeled by a sum of Gaussians. So I'm using the package 'mclust' to get the Gaussians's parameters for this 1D distribution. It works very well, but, for input sizes above 100.000 values it starts taking really forever. Unfortunately my dataset has around 4.6M values... My question: is it correct to subsample my dataset taking a value every N to make mclust happy? Or have I no alternative except using the complete dataset? Excuse my profound ignorance and thank for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Wiki down?
From yesterday I cannot connect anymore to wiki.r-project.org Is the problem known? Thanks! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] FBI Homicide data?
Dear all, do you know if it's available and where the FBI Homicide dataset? It has at least the following columns: victim age, homicide age. A scatterplot of this data is visible here: http://www.uml.edu/gallery/main.php?g2_itemId=6016 Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] Issues getting R to write image files
Has tried to close the image file at the end? Do: dev.off() Hope it helps mario Kenny Larsen wrote: Hi All, Have spent the last couple of days learning R and shell scripting to do batch plotting jobs. I have had success getting R to complete a filled contour plot and output to a file (.jpg or .tiff etc). However, when I try to do the same thing with the simple plot command the script seems to execute correctly yet there is no output. Below is my R code: file - Sys.getenv(input_file) tiff(paste( file, tiff, sep=.)) z - read.table(file) plot(z, type=l, xlim=range(0.6,2), col = red, plot.title = title(main = file, xlab = Wavelength (um), ylab = Intensity (arb.)) q() The data file is simply 2 columns of real numbers. The system it is running on is a linux box from the command line, but does have the Xlibrarys and can clearly write tiff's as it managed it with the filled contours. Bear in mind I only started with both linux and R a couple of days ago, so be gentle if it is something silly! Cheers, Kenny -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 read a binary file bit by bit?
In my humble opinion, forget R and use more appropriate tools, like a very small C program that reads 10 bytes at a time and outputs 8 integers. Then use R to read the resulting file. Ciao! mario Inigo Pagola Barrio wrote: Hello everybody, I am trying to a read a binary file with different formats. I use the readBin function so I can read bytes, short and double numbers depending on the bytes per element in the byte stream. But now I need to read bit by bit, and join them in groups of ten because every ten bits will form a number. How can I do this? Regards, _ Iñigo Pagola Solar Thermal Energy Deparment CENTRO NACIONAL DE ENERGÍAS RENOVABLES __ 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. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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 could I terminate a script (without leaving R)?
Good morning! Which is the preferred method to leave a sourced script and returning back to the '' prompt? For example I search for certain files to be processed, but nothing should be done if they are not present. Normally I do in my script: f-dir(pattern=qq) if(length(f) 0) { ...process file list... } # script end But I don't like those {} encompassing the whole script so I'm searching for something to put in place of the '???' here: f-dir(pattern=qq) if(length(f) == 0) '???' ...process file list... # script end Using stop(No file found, call.=F) works, but the Error message is ugly in this case. Any suggestion? Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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.