Re: [R] debug R device plot
cameron.bracken wrote: You need to look for a file (it may not be in your project directory) that contains ___LOCK in its file name and delete it. Specifically, the rogue lockfile should be in the same directory as options('tikzMetricsDictionary'). Or, if you haven't set a permanent location for the metrics dictionary, it will be in a temporary directory. The tikzDevice prints out a status message with the location of the temporary dictionary whenever it has to create one. - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/debug-R-device-plot-tp3403638p3545664.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect positioning of raster images on Windows
Paul Murrell-2 wrote: Hi This is a rounding (truncation) problem. Working on a fix. Paul Sharpie wrote: Michael Sumner-2 wrote: I think there's something about the discrete cell versus centre value interpretation here, and you are pushing the pixels through R's graphics engine as well as whatever the png device has to do. I can't enlighten you about the details of that, but by creating an image file more directly with pixels as data you can get the result exactly: test - matrix(c(0, 255), 3, 5) library(rgdal) ## transpose to get orientation right x - image2Grid(list(x = 1:ncol(test), y = 1:nrow(test), z = t(test))) writeGDAL(x, raster.png, driver = PNG, type = Byte) On Mon, Oct 18, 2010 at 3:17 PM, Sharpie ch...@sharpsteen.net wrote: I am working on dumping raster data from R into PNG files using rasterImage(). I am working with a test matrix from the rasterImage() example and using it to produce a PNG image with the following code: # From the example for rasterImage(). A 3 pixel by 5 pixel b/w checkerboard. testImage - as.raster(0:1, nrow=3, ncol=5) testImage [,1] [,2] [,3] [,4] [,5] [1,] #00 #FF #00 #FF #00 [2,] #FF #00 #FF #00 #FF [3,] #00 #FF #00 #FF #00 png('test.png', width=5, height=3, units='px') # Just want the image, no margins, boarders or other fancy stuff. par(mar = c(0,0,0,0) ) plot.new() plotArea = par('fig') rasterImage(testImage, plotArea[1], plotArea[3], plotArea[2], plotArea[4], interpolate = FALSE ) dev.off() However, using R 2.12.0, 64 bit on Windows 7 I have a strange issue where the image is shifted up by one row and to the left by one row. In other words, the bottom row of pixels is missing along with the right column. The code works as I expect it to on OS X and Debian. Am I misusing the plotting commands in some way or should I submit an off-by-one bugreport to Bugzilla? Any suggestions or comments are most welcome. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-positioning-of-raster-images-on-Windows-tp2999649p2999649.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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.com Hi Micheal, I appreciate the suggestion. However, rgdal is very heavyweight and installing the GDAL library is not a trivial operation automagically handled `install.packages()` on every platform R supports. As I am not doing spatial analysis, I am very reluctant to add rgdal to the dependency list of my package. I would very much prefer to find the root cause of the difference in `png()` behavior on Windows when compared to OS X and Linux. If anyone on this list has some insight to share, I would be very grateful to hear it. I waffled a bit on whether to send this to R-help or R-devel, in the light of day (as opposed to the foggy darkness that surrounds 2am) think it may be more of an R-devel question. Forwarding it there now. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/le code. Thank you so much Paul! I poked around a bit in the Windows C code, but I know nothing about how devga works, so it wasn't a very fruitful investigation. Now that I know what is happening I can put an appropriate warning message in my package. Thanks again for all the excellent work you have put into the R graphics system! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-positioning-of-raster-images-on-Windows-tp2999649p3002321.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect positioning of raster images on Windows
Michael Sumner-2 wrote: I think there's something about the discrete cell versus centre value interpretation here, and you are pushing the pixels through R's graphics engine as well as whatever the png device has to do. I can't enlighten you about the details of that, but by creating an image file more directly with pixels as data you can get the result exactly: test - matrix(c(0, 255), 3, 5) library(rgdal) ## transpose to get orientation right x - image2Grid(list(x = 1:ncol(test), y = 1:nrow(test), z = t(test))) writeGDAL(x, raster.png, driver = PNG, type = Byte) On Mon, Oct 18, 2010 at 3:17 PM, Sharpie ch...@sharpsteen.net wrote: I am working on dumping raster data from R into PNG files using rasterImage(). I am working with a test matrix from the rasterImage() example and using it to produce a PNG image with the following code: # From the example for rasterImage(). A 3 pixel by 5 pixel b/w checkerboard. testImage - as.raster(0:1, nrow=3, ncol=5) testImage [,1] [,2] [,3] [,4] [,5] [1,] #00 #FF #00 #FF #00 [2,] #FF #00 #FF #00 #FF [3,] #00 #FF #00 #FF #00 png('test.png', width=5, height=3, units='px') # Just want the image, no margins, boarders or other fancy stuff. par(mar = c(0,0,0,0) ) plot.new() plotArea = par('fig') rasterImage(testImage, plotArea[1], plotArea[3], plotArea[2], plotArea[4], interpolate = FALSE ) dev.off() However, using R 2.12.0, 64 bit on Windows 7 I have a strange issue where the image is shifted up by one row and to the left by one row. In other words, the bottom row of pixels is missing along with the right column. The code works as I expect it to on OS X and Debian. Am I misusing the plotting commands in some way or should I submit an off-by-one bugreport to Bugzilla? Any suggestions or comments are most welcome. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-positioning-of-raster-images-on-Windows-tp2999649p2999649.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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.com Hi Micheal, I appreciate the suggestion. However, rgdal is very heavyweight and installing the GDAL library is not a trivial operation automagically handled `install.packages()` on every platform R supports. As I am not doing spatial analysis, I am very reluctant to add rgdal to the dependency list of my package. I would very much prefer to find the root cause of the difference in `png()` behavior on Windows when compared to OS X and Linux. If anyone on this list has some insight to share, I would be very grateful to hear it. I waffled a bit on whether to send this to R-help or R-devel, in the light of day (as opposed to the foggy darkness that surrounds 2am) think it may be more of an R-devel question. Forwarding it there now. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-positioning-of-raster-images-on-Windows-tp2999649p3001166.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Incorrect positioning of raster images on Windows
I am working on dumping raster data from R into PNG files using rasterImage(). I am working with a test matrix from the rasterImage() example and using it to produce a PNG image with the following code: # From the example for rasterImage(). A 3 pixel by 5 pixel b/w checkerboard. testImage - as.raster(0:1, nrow=3, ncol=5) testImage [,1] [,2] [,3] [,4] [,5] [1,] #00 #FF #00 #FF #00 [2,] #FF #00 #FF #00 #FF [3,] #00 #FF #00 #FF #00 png('test.png', width=5, height=3, units='px') # Just want the image, no margins, boarders or other fancy stuff. par(mar = c(0,0,0,0) ) plot.new() plotArea = par('fig') rasterImage(testImage, plotArea[1], plotArea[3], plotArea[2], plotArea[4], interpolate = FALSE ) dev.off() However, using R 2.12.0, 64 bit on Windows 7 I have a strange issue where the image is shifted up by one row and to the left by one row. In other words, the bottom row of pixels is missing along with the right column. The code works as I expect it to on OS X and Debian. Am I misusing the plotting commands in some way or should I submit an off-by-one bugreport to Bugzilla? Any suggestions or comments are most welcome. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-positioning-of-raster-images-on-Windows-tp2999649p2999649.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] F# vs. R
Sergey Goriatchev wrote: Hello, Marc No, I do not want to validate Cox PH. :-) I do use R daily, though right now I do not use the statistical part that much. I just generally wonder if any R-user tried F# and his/her opinions. Regards, Sergey In my work as a programmer- this line of thinking usually leads to one set of questions: What problem am I really trying to solve? Am a using the right tools to attack that problem? Mulling over the above questions usually presents a choice: 1. Learn and deploy a new tool that is better suited at attacking the problem than the tools I am currently comfortable with. 2. Stick with one of my better-known tools because it is stronger across a wider class of problems due to factors such as language flexibility, available libraries, widespread adoption, etc. So, if you feel in your gut that F# is better suited to your current or future programming problems than R, it may be worthwhile to invest some time learning the language. If you have the time, it can also be extremely valuable to learn a different language just to try a different approach to solving problems. Personally, I have done very little programming in functional languages- a little bit of Erlang and the tiniest amount of Haskell. But the week or two I have spend on those languages profoundly changed the way I program in R. I discovered a whole bunch of functional programming constructs in R that I feel have made my code smaller and cleaner. In the end I stick with R due to the wealth of libraries available on CRAN, the ease at which the language can be extended via packaging, and the fact that it allows for a variety of approaches to problems. However, it never hurts to have more tools in the toolbox. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/F-vs-R-tp2281084p2285402.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fast string comparison
Ralf B wrote: What is the fastest way to compare two strings in R? Ralf Which way is not fast enough? In other words, are you asking this question because profiling showed one of R's string comparison operations is causing a massive bottleneck in your code? If so, which one and how are you using it? -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Fast-string-comparison-tp2285156p2285409.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Passing a LaTeX length to Sweave
Thomas Levine wrote: I'd really love to do this \setkeys{Gin}{width=\columnwidth} label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth= plot(y~x) @ The \columnwidth macro does not work, of course, in the second line. What can I do instead? This may be difficult as there is no two-way communication between R and LaTeX in the current implementation of Sweave. In fact, there is hardly any communication at all- Sweave is just a preprocessor that turns .Rnw files into .tex files. Basically, there is no way to fetch the current value of \columnwidth because LaTeX is not even running during the time that Sweave is processing the file. Two-way communication is certainly possible, Cameron and I implemented an R - LaTeX callback to provide accurate font metrics to the R tikzDevice, but as far as I can tell this feature would need to be implemented as an extension to the current Sweave system. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Passing-a-LaTeX-length-to-Sweave-tp2284576p2284795.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to profile R interpreter?
Erich Neuwirth wrote: Look for Rprof in the utils package. This was already suggested- but the original poster clarified that he is looking to profile the R interpreter it's self, not R scripts. - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/how-to-profile-R-interpreter-tp2196633p2218846.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Path to R script
Johannes W. Dietrich wrote: At 19:29 Uhr -0400 12.05.2010, Gabor Grothendieck wrote: If you are running the file via source(myfile.R) then just put this in the file: this.dir - dirname(sys.frame(1)$ofile) This is a bit fragile since changes to the internals of source could break it but it does currently work. Great, this is the solution. It works if the script has been saved before running. Thank you, J. W. D. I *strongly* suggest you consider packages if you are sharing collections of R functions and scripts with other people. Compared to other programming languages I have used, R makes it dead simple to create packages. All you really need to get started is: ?package.skeleton() That command creates a set of folders whose structure is pretty self explanatory: package.skeleton( 'myPackage' ) Creates the beginnings of a package structure: myPackage/ R/ = Files containing your custom R functions go in here data/ = Data sets go in here man/ = For documentation files inst/ = Everything else such as scripts and config files The Writing R Extensions Manual can help you fill in the rest of the blanks. The bottom line is that creating a package cost a minimal investment of extra time and pays back huge dividends if the collection of scripts and data files you are sharing gets complex or you people ask you to document the software that they are starting to depend on. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Path-to-R-script-tp2196648p2216184.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Path to R script
Johannes W. Dietrich wrote: There is certainly a trivial solution for my question, but I can't find the answer in the documentation. I need a platform independent method to obtain the file path of the current R script. My working group uses R on several machines with different operating systems including Mac OS X, Windows and Linux, and for obvious reasons the file hierarchies are very different. Therefore, it would be useful to be able to address data files and external procedures relative to the path of the script. Thank you for any suggestion, J. W. D. -- The best recipie I have for dealing with this situation is: 1. Place R scripts in a package (a very good idea anyway if you are distributing code to others). 2. Place a configuration file in the package that contains info such as paths to data directories. 3. Customize the configuration file after installing the package (if necessary). Then your script accesses the configuration file, which is in a known fixed location, and uses the information inside to find other files that may be in unknown and changing locations. You could also place the configuration file in a location such as: ~/.MyPackageConf Since: path.expand( '~/' ) Has a pretty predictable behavior across platforms. This would save it from being overwritten every time you updated the package. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Path-to-R-script-tp2196648p2196929.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A primitive OO in R -- where next?
Ted.Harding-2 wrote: Greetings All, Out of curiosity, I've just done a very primitive experiment: Obj - list(Fun=sum, Dat=c(1,2,3,4)) Obj$Fun(Obj$Dat) # [1] 10 That sort of thing (much more sophisticated) must be documented mind-blowingly somewhere. Where? Where I stand right now: The above (and its immediately obvious generalisations, like Obj$Fun-cos) is all I know about it so far. Ted. You may want to take a look at the Proto package- it allows you to create objects that provide a reference to self inside their member functions. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/A-primitive-OO-in-R-where-next-tp2196862p2196948.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] inquiry about Version 2.11.0
Maria Clara Soto Velez wrote: Hello, I am trying to download the newest versión of R (R version 2.11.0), but I haven´t been able, because it seems that the file is not working properly. Could you help me? No. You have not provided enough information for us to even take a guess at what the problem is or how to fix it. At the minimum we would need to know: - What operating system you are using - What you mean by the file is not working properly * Which file? * How are you trying to install it? * What errors are you getting? Plus any other information you may feel could be helpful. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/inquiry-about-Version-2-11-0-tp2135896p2142385.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sourcing functions
David Winsemius wrote: If you read the Installation and Administration document you should find material on that process. Look for the section that describes the care and feeding of .Rprofile or type ?Startup # in an R console session. And when you are ready, the Writing R Extensions manual will show you how to store your functions in an R package that you can quickly load up on other machines. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Sourcing-functions-tp2122413p2122562.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merging files
Alex Jameson wrote: David, merg12 displays the files with this message at the bottom [reached getOption(max.print) -- omitted 321526 rows]] str(merg12) displays the following message 'data.frame' : 329218 obs. of 13 variables $ patientid: $ Name: $ Age: but no file is created in the folder mydata i would expect a file to be created, which is not happening Thank you Alex Why would you expect a file to be created? The help page for merge contains no mention of output to files as part of the function's execution. Generally, if the effect you are thinking of is not described in the help page for a function, then that function does not cause the effect. If a function does cause an effect that is not described in the help page, then the author of the help page did a poor job writing it. Since you mentioned that you are new to R, I would recommend spending some time studying the manuals. First, the Introduction to R which gives a good overview of the R language and describes the various objects you are trying to work with- specifically data.frame objects. A copy was probably included with your installation of R and you can access it online at: http://cran.r-project.org/doc/manuals/R-intro.html Second, you may want to look at the R Data Import/Export manual- this will help clarify how R interacts with files and the functions you need to execute to do so. A copy can be found online at: http://cran.r-project.org/doc/manuals/R-data.html Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Merging-files-tp2067796p2068316.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix package + mfcol/mfrow
Gildas Mazo wrote: Hi, When I load the Matrix package, I cannot get the par(mfrow=c(..,..)) to work, that is, I cannot get to display several images at a time. How can I fix this problem ? Thanks in advance, Gildas Mazo Hmm, the following: require(Matrix) par(mfrow=c(1,2)) plot(1,1,main='first') plot(1,1,main='second') Is working fine for me on R 2.10.0, Windows XP. Could you provide the following: * The version of R you are using * The operating system you are using it on * Example code that reproduces the problem on your computer -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Matrix-package-mfcol-mfrow-tp2067879p2068331.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] TikzDevice and texi2dvi
Lorenzo Isella wrote: I think I solved my problems by resorting to the Ubuntu packages at http://bit.ly/c8izKy Cheers Lorenzo Dear All, I am starting to use the tikzDevice package, but I am experiencing some (minor problems). If I try to run the script at the end of the email, I get the following error Error in tools::texi2dvi(normal.tex, pdf = T) : Running 'texi2dvi' on 'normal.tex' failed. Messages: sh: /usr/bin/texi2dvi: not found How do I install the missing texi2dvi? I found some reference to it at http://bit.ly/bSYbxk but I have not understood well whether it is should already be part of my R base installation or not. I am running R 2.11 on Ubuntu 9.10. Many thanks Lorenzo Hi Lorenzo, It appears you are missing the texi2dvi program- this is a tool provided by TeX or TeXinfo distributions, not R or tikzDevice. In order to use the tikzDevice, you will need to install a TeX distribution on your machine. As you are running Linux, I highly recommend the TeXlive distribution, which you can get from: http://www.tug.org/texlive/ I recommend using the net installer at: http://www.tug.org/texlive/acquire-netinstall.html I would advise this over Debian packages, as it has been my experience that the packages can be horribly out of data- for example the Ubuntu package repository lists a build based on TeXlive 2007 as being available for 9.10. The tikzDevice requires PGF/TikZ 2.00 to function properly which in turn requires TeXlive 2008 or later. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/TikzDevice-and-texi2dvi-tp2067230p2068350.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to create R package
Dinh Diep wrote: Hi, Can you tell me how to create R package in Windows, and give me an example that works ? Thanks. Hi Dinh, Check out the help page for the package.skeleton() function- it will create the outline of a package for you. The Writing R Extensions manual will tell you, with examples, how to flesh it out- you can find a copy online at: http://cran.r-project.org/doc/manuals/R-exts.html Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/How-to-create-R-package-tp2068592p2068646.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Scanning only specific columns into R from a VERY large file
Josh B-3 wrote: Hi, I turn to you, the R Sages, once again for help. You've never let me down! (1) Please make the following toy files: x - read.table(textConnection(var.1 var.2 var.3 var.1000 indv.1 1 5 9 7 indv.21 2 9 3 8), header = TRUE) y - read.table(textConnection(var.3 var.1000), header = TRUE) write.csv(x, file = x.csv) write.csv(y, file = y.csv) (2) Pretend you are starting with the files x.csv and y.csv. They come from another source -- an online database. Pretend that these files are much, much, much larger. Specifically: (a) Pretend that x.csv contains 1000 columns by 210,000 rows. (b) y.csv contains just header titles. Pretend that there are 90 header titles in y.csv in total. These header titles are a subset of the header titles in x.csv. (3) What I want to do is scan (or import, or whatever the appropriate word is) only a subset of the columns from x.csv into an R. Specifically, I only want to scan the columns of data from x.csv into R that are indicated in the file y.csv. I still want to scan in all 21 rows from x.csv, but only for the aforementioned columns listed in y.csv. Can you guys recommend a strategy for me? I think I need to use the scan command, based on the hugeness of x.csv, but I don't know what exactly to do. Specific code that gets the job done would be the most useful. Thank you very much in advance! Josh read.csv.sql() from the sqldf package looks like it may do what you want- it allows you to filter what gets read in from a CSV file using SQL statements, something like: SELECT list,of,column,names FROM file Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Scanning-only-specific-columns-into-R-from-a-VERY-large-file-tp2013646p2013653.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Efficiency of C Compiler in R CMD SHLIB
yehengxin wrote: Dear R experts: I attempted to compile c source code into DLL using R CMD SHLIB but I found the DLL run in R is almost twice slower than the codes compiled in C++ 6.0 when I chose release option and is as fast as the situation where I chose debug option in C++ 6.0. I wonder how to improve the efficiency of DLL compiled by gcc compiler in R. Thanks in advance! Xin What operating system are you using? What is C++ 6.0? What do you mean by release and debug. How do these settings alter the invocation of the compiler? The answers to these questions can help us provide insight on your first question. For your last question, on UNIX/Linux platforms gcc is invoked by R CMD SHLIB with the flags specified in $R_HOME/etc/system architecture/Makeconf . Important entries are: SHLIB_CFLAGS SHLIB_CXXFLAGS SHLIB_FFLAGS Hope this helps. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Efficiency-of-C-Compiler-in-R-CMD-SHLIB-tp1934429p1934478.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Does sink stand for anything?
Paul Miller wrote: Hello Everyone, Learning about R and its wonderful array of functions. If it's not obvious, I usually try to find out what a function stands for. I think this helps me remember better. One function that has me stumped is sink. Can anyone tell me if this stands for something? Thanks, Paul Sink captures R output and directs it elsewhere- common places are a file or device such as /dev/null Personally it always connected with the concept of a sink in a mathematical system as something that removes constituants from the system. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Does-sink-stand-for-anything-tp1934321p1934484.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R package documentation
pomchip wrote: Dear R users, I am currently writing the documentation for my first package. I have created a short user manual using sweave/pdflatex which is distinct from the manual/summary-of-package-functions created by R CMD CHECK. I was wondering how could I seamlessly combine both documents. Thanks for your help Sebastien The .Rd files are normally kept separate from the vignette- this is because Rd files have to be translated into several different formats such as html, man pages and pdf. The vignette allows for a more free-form discussion as it does not have the rigid structure that allows .Rd files to be translated. That being said, you could add the contents of .Rd files to something like an appendix in your vignette by converting the .Rd files to .tex and including them in your Sweave source. Something like the following would convert each .Rd file and append it to a single .tex file (on UNIX/Linux systems): cd yourPackage/man ls *.Rd | xargs -I % R CMD Rdconv -t latex % manPages.tex You could then move manPages.tex to yourPackage/inst/doc and include int in your Sweave source via \input{}. You will need to ensure $R_HOME/share/texmf is on your tex search path as the LaTeX compiler will need Rd.sty to define some of the macros in the code produced by R CMD Rdconv. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/R-package-documentation-tp1839589p1839922.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SSH Through R Script
afoo wrote: Hi, I am trying to SSH to a remote server through R script. In other words, I would like to know how I can get a SSH connection to the remote server and then execute commands on that server with the R script. So in bash, I would normally type ssh -lusername remoteserver.com; press enter and then wait for the password prompt to key in my password. I have tried system(ssh remoteserver.com) but that doesn't work because, from what I know, SSH requires user interactivity - I am required to key in my password. I tried looking up about putting password as a command line parameter, but SSH doesn't allow that, my only option then is to set up a private/public key pair. But the admin of the remoteserver doesn't allow me to do that. Is there a way in which I can SSH in? Or is there a command in R that allows me to interact with the command prompts interactively? thanks, afoo You can secure your public/private keys with a password if there is a concern about security. You can still use these keys to allow programs automatic access by using ssh-agent to hold the identities. For example, I could create a new key for my web server like so: ssh-keygen Enter file in which to save the key (/Users/Sharpie/.ssh/id_rsa): /Users/Sharpie/.ssh/webKey Enter passphrase (empty for no passphrase): superSecretPassword Enter same passphrase again: superSecretPassword The next step is to copy the public key, ~/.ssh/webKey.pub, to the remote server and add it to the authorized keys file. scp ~/.ssh/webKey.pub u...@webserver.com:~/.ssh ssh u...@webserver.com -e cd ~/.ssh;cat webKey.pub authorized_keys You could now sign in using the key: ssh -i ~/.ssh/webKey u...@webserver.com But you still have to provide a password since the key is protected. To ease this restriction, start ssh-agent. ssh-agent provides some environment variables that must be set, so it has to be run using eval ` `, like so: eval `ssh-agent` You can then add your key to the agent: ssh-add ~/.ssh/webKey You still have to enter your password, but from now on all processes spawned from this shell can use that key without requiring the password to be re-entered. Now you can start R and access ssh key free. The best way I can think of to run ssh from within R is to start the process on a pipe and have it write the output to a fifo. You can then use writeLines to send commands to the pipe and readLines to get the output from the fifo. First, make the fifo system('mkfifo sshOut') Then, connect to the pipe and the fifo from within R: # The redirects both stdout and stderr to the fifo sshIn - pipe( 'ssh -i ~/.ssh/webKey u...@server.com sshOut', open = 'w' sshOut - fifo( 'sshOut', 'r' ) Now you can queue commands to be executed with writeLines(), send them with flush() and get the results using readLines(): writeLines( 'ls', sshIn ) flush( sshIn ) readLines( sshOut ) [1] Pseudo-terminal will not be allocated because stdin is not a terminal. [2] backup [3] bin [4] cache [5] Cellar [6] code [7] dat [8] doc [9] gems [10] gitrepos [11] include [12] lib [13] libexec [14] logs [15] man [16] opt [17] share [18] source [19] specifications [20] stash [21] webapps Remember to run close() on sshIn when you want to sever the connection. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/SSH-Through-R-Script-tp1809635p1837919.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
Re: [R] SSH Through R Script
Sorry about the double post, but this line: Sharpie wrote: ssh u...@webserver.com -e cd ~/.ssh;cat webKey.pub authorized_keys Should be: ssh u...@webserver.com cd ~/.ssh;cat webKey.pub authorized_keys I.e., omit the -e flag. Apologies, -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/SSH-Through-R-Script-tp1809635p1837920.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating R packages, passing by reference and oo R.
Gabor Grothendieck wrote: Passing by value does not necessarily mean physical copying. Check out this: x - matrix(1:1000^2, 1000, 1000) gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 114520 3.1 35 9.4 35 9.4 Vcells 577124 4.51901092 14.6 1577448 12.1 f - function(x) { y - max(x); print(gc()); y } f(x) used (Mb) gc trigger (Mb) max used (Mb) Ncells 114560 3.1 35 9.4 35 9.4 Vcells 577133 4.51901092 14.6 1577448 12.1 [1] 100 R.version.string [1] R version 2.10.1 (2009-12-14) win.version() [1] Windows Vista (build 6002) Service Pack 2 Yes, but you might pay a price in memory if you start altering values in x within the function: x - matrix(1:1000^2, 1000, 1000) gc(TRUE) Garbage collection 5 = 1+0+4 (level 2) ... 3.2 Mbytes of cons cells used (34%) 4.5 Mbytes of vectors used (30%) used (Mb) gc trigger (Mb) max used (Mb) Ncells 119554 3.2 35 9.4 35 9.4 Vcells 578542 4.51902416 14.6 1581475 12.1 f - function(x) { x[100,100]-2; print(gc(TRUE)) } f(x) Garbage collection 7 = 1+0+6 (level 2) ... 3.2 Mbytes of cons cells used (34%) 12.1 Mbytes of vectors used (60%) used (Mb) gc trigger (Mb) max used (Mb) Ncells 119634 3.2 35 9.4 35 9.4 Vcells 1578573 12.12629025 20.1 2078567 15.9 R.version.string [1] R version 2.10.1 (2009-12-14) -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Creating-R-packages-passing-by-reference-and-oo-R-tp1751525p1751682.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.6 Support Question
Raadt, Timothy W. wrote: Hello, I have a question on the support of the R 2.6 software. We are in the process of planning for a hardware refresh and our new machines will be running Windows 7 and Internet Explorer 8. My question is if the R 2.6 software would be supported on a system running Windows 7 and Internet Explorer 8? Also, are you aware of any customers having issues with Windows 7 and/or Internet Explorer 8? Thank you for your time and any information you can provide. Tim Raadt Systems Developer Federated Insurance 121 East Park Square Owatonna, MN 55060 507-444-7163 Well, support given on this mailing list is a volunteer effort. It is important to understand that members of this list are in no way obligated to answer any questions- they do it in their free time as a service to the R community. A key part of this process is for volunteers to be able to quickly reproduce problems with the version of R they have installed. Generally, the most knowledgeable people on this list tend to run the newest version of R available-- which is currently 2.10.1. R 2.6 is nearly three years old, so it is unlikely that a significant number of people on this list still use it. Therefore, the answer to any questions posed concerning 2.6 is likely to be upgrade to the newest version and see if the problem goes away. If you want real technical support, then that will require purchasing from a company that provides commercially supported version of R. Two that I know of are R+ from XL Solutions and REvolution R from REvolution Computing. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/R-2-6-Support-Question-tp1751666p1751705.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rprintf not updating
Erik Wright wrote: Hello all, I am using Rprintf in a C for loop (from .Call) to print a progress indicator showing the current percent complete. The loop I am doing is an time intensive call to another function. I have noticed that Rprintf does not print to the R-window until the entire loop has been completed. When it reaches the end of the loop it suddenly prints 0 percent to 100 percent in a split second. For less intensive function calls it prints properly while looping. My question is this: is there any way to force Rprintf to print to the screen during a loop? On a related note, how can I show a percent sign in the output? For example, Rprintf(0%); only prints a zero. Thanks!, Erik Perhaps you could use a callback to R's built in progress bar functions to perform this for you in a nicely formatted way. Something of the form: pBar - txtProgressBar( min = , max = , type = 3 ) cResults - .Call( 'some_c_routine', some, args, including, pBar ) close( pBar ) Since you pass the progress bar to the C routine, you could perform a callback to the R function setTxtProgressBar() to update it every iteration. I posted an example of how to perform callbacks from C to R in this thread: http://n4.nabble.com/Writing-own-simulation-function-in-C-td1580190.html#a1580423 Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Rprintf-not-updating-tp1751703p1751725.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rprintf not updating
Erik Wright wrote: Hi Charlie, I like your idea of updating an R progress bar from C, but I don't at all understand how to call txtProgressBar from C. I have looked at Writing R Extensions and it is equally confusing. Any help would be appreciated. Thanks!, Erik Hi Erik, Did you look at the link I put in my last post? http://n4.nabble.com/Writing-own-simulation-function-in-C-td1580190.html#a1580423 I linked that post because it gives a step-by-step example for performing a callback to the runif function from C. Just change the execution environment from stats to utils and alter the function arguments appropriately and it should work for txtProgressBar and setTxtProgressBar. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Rprintf-not-updating-tp1751703p1752102.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rprintf not updating
Erik Wright wrote: Hi Charlie, Thanks, I got it working by looking at your myRunIfConcise function. SEXP changePercent(SEXP pBar) { int *rPercentComplete; SEXP utilsPackage, percentComplete; PROTECT(utilsPackage = eval(lang2(install(getNamespace), ScalarString(mkChar(utils))), R_GlobalEnv)); *rPercentComplete = 10; //this value increments eval(lang4(install(setTxtProgressBar), pBar, percentComplete, R_NilValue), utilsPackage); } Now I am wondering why the pBar doesn't show initially if the percent complete is 0%? Thanks again, Erik I did a quick check on the R side of things and txtProgressBars do not display until after the first call to setTxtProgressBar unless the initial parameter is set to something other than 0 (possible bug?). Try executing a call immediately after creation to set the value to 0. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Rprintf-not-updating-tp1751703p1752289.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] memory error
Janet Choate-2 wrote: Thanx for clarification on stating my problem, Charlie. I am attempting to merge to files, i.e.: hi39 = merge(comb[,c(hillID,geo)], hi.h39, by=c(hillID)) if this is relevant or helps to explain: the file 'comb' is 3 columns and 1127 rows the file 'hi.h39' is 5 columns and 19758564 rows i started a new clean R session in which i was able to read those 2 files in, but get the following error when i try to merge them: R(2175) malloc: *** mmap(size=79036416) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(2175) malloc: *** mmap(size=79036416) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(2175) malloc: *** mmap(size=158068736) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(2175) malloc: *** mmap(size=158068736) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(2175) malloc: *** mmap(size=158068736) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Error: cannot allocate vector of size 150.7 Mb so the final error is Cannot allocate vector of size 150.7 Mb, as suggested when R runs out of memory. i am running R version 2.9.2, on mac os X 10.5 - leopard. any suggestion on how to increase R's memory on a mac? thanx for any much needed help! Janet Ah, so it is indeed a shortage of memory problem. With R 2.9.2, you are likely running a 32 bit version of R which will be limited to accessing at most 4 GB of RAM. You may want to try the newest version of R, 2.10.1, as it includes a 64 bit version that will allow you to access significantly more memory- provided you have the RAM installed on your system. I'm not too hot on memory usage calculation, but someone else on this list may be able to give you a ballpark estimate of how much RAM this merge would require. If it turns out to be a ridiculous amount, you will need to consider breaking the merge up into chunks or finding an out-of-core (i.e. not dependent on RAM for storage) merge tool. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/memory-error-tp1747357p1747733.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] memory error
Janet Choate-2 wrote: Hi R community, i have what appears to be a memory allocation problem: R(51150) malloc: *** mmap(size=158068736) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug can anyone tell me how to increase the memory size for R on mac os X? thank you, Janet Setting memory limits was something that was done under OS 9- with OS X apps get as much memory as they request as long as free space is available. Also, when R runs out of memory, you usually see errors like: Cannot allocate vector of size X Some details may help pin this problem down: what were you doing when you got this error? Is it repeatable? Is it an error with a base R routine or with something provided by a package? If so, what version? Providing these details will help the people on this list understand what your problem is and suggest solutions. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/memory-error-tp1747357p1747558.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Confusing concept of vector and matrix in R
yehengxin wrote: Why does R need the concept of Vector? In my opinion, it is a useless and confusing concept. A vector is simply a special case of a matrix whose row or column number is equal to 1. When I take submatrix from one matrix and if row or column number is 1, R will automatically convert it into a vector. It is very straightforward that a submatrix of a matrix should be a matrix. In each time, I have to use as.matrix() to convert the vector back to matrix.It is very annoying! Except that to a computer all matricies and arrays are just vectors for which some human arbitrarily declared something like row break every n entries. And R can be told not to perform the conversion from sub-matrix to vector, open the help page for the subset operator: ?[ And play with the drop option. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Confusing-concept-of-vector-and-matrix-in-R-tp1707170p1735190.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Page width figures in Latex
Jim Lemon wrote: bRotheRs sisteRs, I am once again attempting to learn enough Latex voodoo to get something done, and failing comically. The document RJAuthorguide.pdf mentions that one can get page width figures through the use of the figure* or table* environments, but despite considerable searching through the mail archives and reading Frank Harrell's discussion of Using Latex Figure Environments for Plots until my eyes went on strike, I am nowhere near a solution. Would anyone be kind enough to point me to the Idiot's Guide to Latex Figure Environments? Jim As far as I can recall, figure* and table* are used to create figures/tables that span the entire page when the rest of the document is in twocolumn or multicol mode. I.e. these environments allow you to break out of a multi-column layout to place a figure that acts like it was in a normal single-column layout. There are a bunch of caveats such as the figure/table will only appear at the top or bottom of a page and will not appear on the same page as the point at which it was declared in the source. That is to say, when you declare a figure* in a LaTeX document, one page break must pass before the environment actually gets set in your document- no matter what !h or H vodoo you pull. If your document is not using multiple columns, then you may want to specify the width of your figure when you place it using \includegraphics. In order to scale the figure so that it spans the entire page, set the width argument equal to \textwidth: \begin{figure} \centering \caption{A graph of x verses y along with a linear regression fit.} \label{fig:xVsY} \includegraphics[width=\textwidth]{/path/to/your/figure} \end{figure} Some good resources are: The LaTeX Wikibook: http://en.wikibooks.org/wiki/LaTeX Getting to Grips with LaTeX: http://www.andy-roberts.net/misc/latex/ Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Page-width-figures-in-Latex-tp1694612p1694673.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Page width figures in Latex
Rolf Turner wrote: On 29/03/2010, at 4:21 PM, Sharpie wrote: SNIP There are a bunch of caveats such as the figure/table will only appear at the top or bottom of a page and will not appear on the same page as the point at which it was declared in the source. That is to say, when you declare a figure* in a LaTeX document, one page break must pass before the environment actually gets set in your document- no matter what !h or H vodoo you pull. SNIP I'm not convinced that this is correct; I'm sure I have had floats (including figures) placed where I asked them to be placed. :-) Be that as is it were; if you put: \usepackage{float} in your preamble and then do \begin{figure}[H] whatever \end{figure} the figure will appear ***exactly*** where you put it --- provided of course that there is room for it there. Elsewise you'll get a page break just before the figure. cheers, Rolf Turner Aye, that is exactly true for the figure environment. However, I was referring to the figure* environment (note the asterisk) which is used when setting a figure that spans a full page in a document with multiple columns. Under these conditions, I recall there being some gotchas such as the figure having to appear at the top or bottom of the page and one pagebreak having to pass before it appears. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Page-width-figures-in-Latex-tp1694612p1694686.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)
hadley wickham wrote: exp1^(a[case] * l * 10) would be better written out of the loop as b - exp1^(a * l * 10) And even better as b - exp(a * l * 10) Hadley Aye, exp() functions tend to be heavily optimized compared to general functions such as `^` even if e is used as the base of the exponent. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Competing-with-SPSS-and-SAS-improving-code-that-loops-through-rows-data-manipulation-tp1692848p1693763.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a vector of categories
Christoffer Karlsson wrote: Hi, I have a column in a data frame looking something like: $sex $language $count male english 0 male english 0 female english 32 male spanish 154 female english 11 female norweigan 7 and so on. What I want to do is to order these in to categories, for instance one category where count=0 count10 and so on.. I want my data to turn out looking something like: male english 0-10 1324 male english 11-20 756 . male spanish 0-10 354 ... female english 0-10 1557 ... and so on, where the right hand is the count of the number of people in each category. Up until now I've been subsetting the data frame into each category, and then counting number of rows in each subset. However I now have a large amount of different factor combinations which makes this process tedious. Any help would be appreciated! Chris You can quickly assign a category to each row in your data frame with the cut() function: testData - structure(list(sex = structure(c(2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L), .Label = c(female, male), class = factor), language = structure(c(1L, 1L, 1L, 3L, 1L, 2L, 3L, 3L, 1L), .Label = c(english, norweigan, spanish), class = factor), count = c(0L, 0L, 32L, 154L, 11L, 7L, 3L, 5L, 2L)), .Names = c(sex, language, count), class = data.frame, row.names = c(NA, -9L)) binMax - ceiling( max(testData$count) / 10 ) * 10 binBreaks - seq( 0, binMax, by = 10 ) testData$bin - cut( testData$count, binBreaks, include.lowest = TRUE ) And then as Petr said: with( testData, aggregate(count, list(sex, language, bin), length)) Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Creating-a-vector-of-categories-tp1691911p1692028.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a vector of categories
Sharpie wrote: testData$bin - cut( testData$count, binBreaks, include.lowest = TRUE ) I also made a slight mistake, you will want to replace inclde.lowest = TRUE with right = FALSE to the call to cut() to preserve the greater-than-or-equal boundary at the lower end of each bin. Sorry if that caused any confusion! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Creating-a-vector-of-categories-tp1691911p1692030.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More efficient alternative to combn()?
elgorgonzola wrote: Hi, i am working on a problem where i need to compute the products of all possible combinations of size m of the elements of a vector. I know that this can be achieved using the function combn(), e.g.: vector - 1:6 combn(x = vector, m = 3, FUN = function(y) prod(y)) In my case the vector has 2000 elements and i need to compute the values specified above for m = 32. Using combn() i encounter problems for m = 4. Is there any alternative to combn() that works more efficiently? Also my vector contains many duplicates, so there are actually only about 300 distinct values in the vector. This reduces the number of possible combinations significantly. Is there any way to use this fact to reduce the computational cost? Thanks in advance, El The unique() function can be used to quickly filter out duplicates in your input function. I am not aware of an alternative implementation of combn(), but that doesn't mean there isn't one out there. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/More-efficient-alternative-to-combn-tp1692117p1692128.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use the paste function to create an already used variable
quot;Biedermann, Jürgenquot; wrote: Perfekt! So, the code below does, what I want it does. for (m in 1:AnzRat) { Daten_akt - eval(parse(text=paste(Daten,m,_akt,sep=))) ... ... assign(paste(Daten,m,_akt,sep=),Daten_akt) } You may want to consider replacing eval(parse()) with a call to get(). eval(parse()) does the job- but it's like using a sledgehammer when you have a tack hammer available that will work just fine. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/How-to-use-the-paste-function-to-create-an-already-used-variable-tp1680508p1690769.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Insert .eps files in to an R plot.
mnstn wrote: Hello Everybody, I have an eps figure an awesome bacteria and a plot (generated using R) also in eps format. Now it looks like there is space for only one figure and I have to insert the picture of the bacteria into the plot. Is there a way to insert figures (eps/png/jpg) in to plots (may be control over placement of figures in the plot as well?) ? By plots I mean data represented using axes and points and such and by figures I mean cartoons, pictures taken by a camera and such. Thanks, MoonStone The grImport package on CRAN offers this functionality. Although I would caution that if you do this- consider carefully if adding the picture of bacteria enhances or distracts from the results or analysis you are presenting in the plot. If the picture is not strongly related to the data you are presentin, and I mean more related than just being a picture of the critter you analyzed, it may be better to just leave it out. Including it could lower the signal-to-noise ratio of the graph and decrease the impact of the analysis. I know it's a tough choice to omit a really good graphic when you have a space constraint, but it is usually not worth sacrificing the clarity of other graphics by smashing two things together if they are only marginally related. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Insert-eps-files-in-to-an-R-plot-tp1690704p1690852.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to deal with vector[0]?
Jin wrote: Hi, I have a vector with 4 elements, e.g., tau_i=c(100,200,300,400), but potentially tau_i[0]=0. In a for loop, tau_i=c(100,200,300,400) m=4 tau_i[0]=0 # --- ? P_i=1 for(i in 2:m) { P_i = P_i*(tau_i[i-1]-tau_i[i-2]) } Error in P_i = P_i * (tau_i[k - 1] - tau_i[k - 2]): replacement has length zero Unfortunately, I can add this potential element into tau_i because it has been defined initially and used mainly throughout all procedures. When I calculate k=2 tau_i[k-1]-tau_i[k-2] umeric(0) But, it should be 100. Is there anyone can help me solve this problem? Best, Jin NREL, Golden CO (303) 275-4642 I'm a little confused on exactly what you're trying to achieve here-- vector indexes in R start at 1, not 0, and so trying to assign any value to tau_i[ 0 ] is meaningless. Using tau_i[ 0 ] in a calculation is equivalent to using numeric( 0 ) -- i.e. a numeric vector of *length* zero, which contains no values at all. Does this help? -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/how-to-deal-with-vector-0-tp1690812p1690861.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Abstract classes
Albert-Jan Roskam wrote: Hi R lovers, I'm looking for more information about, and implementations of abstract classes. After reading Head First Design Patterns (O'Reilly). I want to know whether I could use this to build an interface, i.e. a placeholder for all possible methods in the underlying subclasses. The final goal is to end up with a more flexible/extensible design than could be achieved with inheritance and polymorphism. I installed the 'sp' package, because I read that the Spatial Class is an abstract class, but I don't know where to look for the file where that class lives. I tried, among others, the files in: R/i486-pc-linux-gnu-library/2.9/sp/R. Cheers!! Albert-Jan It looks like you were looking in the R library where R stores sp after installing it- the problem with this is that R converts all the code to a binary format and stores it in a single file. You want to download the source tarball from CRAN: http://cran.r-project.org/web/packages/sp/index.html Untar it and look in the R directory of the resulting folder. You will see a file called Class-Spatial.R that contains the S4 class definition. Another good study in S4 inheritance is the Matrix package which is now included in the R core. You can download it's source from: http://cran.r-project.org/web/packages/Matrix/index.html Look at the file called AllClass.R Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Abstract-classes-tp1690866p1690879.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Basic graphs: something like groups, but where each plot has independent axis?
Ben Bimber wrote: I am trying to graph weight data for our colony. We a data frame with Animal, Weight and Date. I'd like to display this data a series of simple xyplots. We only need to display these plots together, we do not need to make comparisons between animals. Each animal has been weighted over a different time period, so we do not want the same range for each X axis. Using the following, I can create one plot per animal: size - length(unique(data$id)) xyplot(weight ~ date | id, data=data, #type=o, layout=c(1,size), xlab=Date, ylab=Weight ); However, they share a common X axis. Is it possible to avoid this? In other words, I might want the first animal's plot to extend from 2008-01-01 through 2009-05-04, while the second plot extends from 2007-02-04 through 2010-01-01. Also, can I introduce more whitespace between each plot? Thank you for any help. You can do this in ggplot2 using facet_wrap( ~ id, scales = free_x ): colonyPlot - qplot( date, weight, data = data, xlab = Date, ylab = Weight ) + facet_wrap( ~ id, scales = free_x ) + theme_bw() print( colonyPlot ) Not sure about hot to do it using xyplot though. The following website may help for ggplot2: http://had.co.nz/ggplot2/facet_wrap.html Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Basic-graphs-something-like-groups-but-where-each-plot-has-independent-axis-tp1690870p1690937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Create blocks or observations
tj wrote: Anyone who can help me with this? I have 48 observations (I dont want to alter their order). I want to group these observations into 16 blocks. So I should have 3 observations for each block. This is what I did in R, but it has warnings. y #contains my 48 observations [1] 2.4 2.4 2.4 2.2 2.1 1.5 2.3 2.3 2.5 2.0 1.9 1.7 2.2 1.8 3.2 3.2 2.7 2.2 2.2 [20] 1.9 1.9 1.8 2.7 3.0 2.3 2.0 2.0 2.9 2.9 2.7 2.7 2.3 2.6 2.4 1.8 1.7 1.5 1.4 [39] 2.1 3.3 3.5 3.5 3.1 2.6 2.1 3.4 3.0 2.9 g=c(0,0,0) #storage vector for (i in 1:16){ + g[i]=y[(3*i-2) : (3*i)] + } There were 16 warnings (use warnings() to see them) g[1] [1] 2.4 g[2] [1] 2.2 ## g[1] should show 2.4 2.4 2.4 ## g[2] should show 2.2 2.1 1.5 ##g[16] should show 3.4 3.0 2.9 Can you please tell me how I should correct my program? Thank you. ~tj I think your main problem is that you created a vector g[] which is three elements long. Then you tried to set a single element of g equal to three elements of y which doesn't work too well- you can't wedge a vector of length 3 into a box designed to hold one element. I would suggest paring y with a group vector that indicates which group each element of y belongs to: numGroups - length( y ) / 3 group - unlist( lapply( 1:numGroups, rep.int, times = 3 ) ) Then you can use the split function to break y apart based on group: split( y, group ) Or you could pair them as columns in a data frame and use split() to split into sub-data frames or by() to split and execute a function on each sub-data frame. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Create-blocks-or-observations-tp1691606p1691660.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] netlabR package in English
Keith McMillan wrote: Dear R users, Is documentation for the netlabR package available in English? If not does anyone know if or when it will be? Regards, Keith I don't see a package named netlab or netlabR on CRAN, which package are you talking about? Where did you find it? -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/netlabR-package-in-English-tp1691599p1691663.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] install ncdf package
Pinto wrote: Dear R users I am attempting to add lncdf_1.6.tar.gz libraries within R, and have failed. I have R version 2.8.1, and are running on fedora 10 Kernel Linux 2.6.293.-60.fc10.x86_64. I've run R CMD INSTALL ncdf_1.6.tar.gz and I have the following --- * Installing to library '/usr/lib64/R/library' * Installing *source* package 'ncdf' ... checking for gcc... gcc -m64 -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -m64 -std=gnu99 accepts -g... yes checking for gcc -m64 -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking netcdf.h usability... yes checking netcdf.h presence... yes checking for netcdf.h... yes Found netcdf.h in: . checking for nc_open in -lnetcdf... yes Found netcdf library file libnetcdf.a in directory . configure: creating ./config.status config.status: creating R/load.R config.status: creating src/Makevars ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf2.c -o ncdf2.o gcc -m64 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf3.c -o ncdf3.o ncdf3.c: In function ‘R_nc_get_vara_charvarid’: ncdf3.c:221: warning: assignment discards qualifiers from pointer target type ncdf3.c: In function ‘R_nc_get_vara_numvarid’: ncdf3.c:267: warning: assignment discards qualifiers from pointer target type ncdf3.c:249: warning: ‘rv_data’ may be used uninitialized in this function gcc -m64 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf.c -o ncdf.o ncdf.c: In function ‘R_nc_get_vara_double’: ncdf.c:196: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c:202: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c: In function ‘R_nc_get_vara_int’: ncdf.c:239: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c:245: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c: In function ‘R_nc_get_vara_text’: ncdf.c:296: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c:302: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’ ncdf.c: In function ‘R_nc_ttc_to_nctype’: ncdf.c:424: warning: implicit declaration of function ‘exit’ ncdf.c:424: warning: incompatible implicit declaration of built-in function ‘exit’ ncdf.c: In function ‘R_nc_put_vara_double’: ncdf.c:582: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ ncdf.c:585: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf2.o ncdf3.o ncdf.o -L. -lnetcdf -L/usr/lib64/R/lib -lR /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 chmod: cannot access `/usr/lib64/R/library/ncdf/libs/*': No such file or directory ERROR: compilation failed for package 'ncdf' ** Removing '/usr/lib64/R/library/ncdf' --- Any help is strongly appreciated, thank you in advance Based on the error: /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC I would guess that R is complaining about libnetcdf.a was not compiled to use position independent code, hence the request for -fPIC. However, my expertise in these areas is amateur at best-- someone else may be able to provide a more informed opinion. Also, you stated you are using R 2.8.1 which is out of date by two, soon to be three, major releases. It is highly recommended to keep your version of R as current as possible. A newer
Re: [R] string problems in R
Muting Zhang wrote: Hello all I have been working on my thesis using R. I am a newbie to R and met a problem that bothered me for a while due to my lack of acquaintance of R. I am using R to query from SQL. I got a list of crsp_fundno of G-style mutual funds which is still alive. I use the following codes and got what I want: library(RODBC) channel-odbcConnect(CRSPFUND) g.crspfundno-sqlQuery(channel,select crsp_fundno from Fund_style where wbrger_obj_cd = 'G'order by crsp_fundno) g.crspfundno (got crsp_fundno of G-style fund from Fund_style table) y.crspfundno-sqlQuery(channel,select crsp_fundno from Fund_hdr where dead_flag = 'N'and end_dt=20091231 order by crsp_fundno) y.crspfundno (got crsp_fundno of still alive fund from Fund_hdr table) g$key-paste(g.crspfundno$crsp_fundno) y$key-paste(y.crspfundno$crsp_fundno) v.fundno-intersect(g$key,y$key) (using intersect to get crsp_fundno of G-style mutual funds which is still alive.) v.fundno What i need to do next is using the v.fundno I got to query from another table Monthly_return to get the mret coresponding to every v.fundno. I have only a basic idea of the code: for (i in 1:length(v.fundno)){ gmret-sqlQuery(channel,select mret from Monthly_returns where crsp_fundno = toString(v.fundno[i])) } gmret R gave me an error with undefined function toString I know there should be some details added in to get it right,like define an object or how to convert number to string.. I would be appreciated if anyone gives me any clue about it. Muting I'm going to take a wild guess and say that the following might work: gmret-sqlQuery(channel, paste( select mret from Monthly_returns where crsp_fundno =, v.fundno[i] ) ) If you could post example data, say the results of: head( v.fundno ) I could provide more than a wild guess. Hope it helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/string-problems-in-R-tp1685419p1685837.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multi-panel Pie Charts.
Gurmeet wrote: Hi All, I'm trying to find out a way to plot multi-panel pie charts. It may not be the best way to present data, but I would still need one. Would paneled bar charts not suffice? I don't mean to be harsh, but the only situation I can think of where I would consider a pie chart would be if I wanted to take advantage of the fact that people are worse at judging differences in area than they are at judging differences in length in order to hide some trend in my data. Anyway, the following code uses ggplot2 to produce a paneled bar plot from your data: require( ggplot2 ) productData - structure(list(variable = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c(ProdA, ProdB, ProdC, ProdD), class = factor), month = structure(c(3L, 2L, 4L, 1L, 3L, 2L, 4L, 1L, 3L, 2L, 4L, 1L, 3L, 2L, 4L, 1L), .Label = c(Apr, Feb, Jan, Mar), class = factor), value = c(25, 30, 25, 10, 25, 30, 50, 40, 40, 30, 20, 40, 10, 10, 5, 10)), .Names = c(variable, month, value), class = data.frame, row.names = c(NA, -16L)) productPlot - qplot( variable, value, data = productData, geom = 'bar', xlab = 'Product', ylab = 'Percentage' ) + facet_wrap( ~ month ) + theme_bw() print( productPlot ) I know it's not what you want, but I personally need a strong argument for generating pie charts before I would perpetuate their use. Gurmeet wrote: 1. Is anyone aware of some in-built script/function which can do this for me. I'm aware of one given in Deepayan's book, but anything apart from this? 2. I tried using Deepayan's script on following data set but it doesn't seem to work as expected - labels are getting repeated/overlapping. I'm really not sure what could be the problem, can anyone help please. I hope data is in the right format, as expected. Data read into object foo: variable month value ProdA Jan25 ProdA Feb30 ProdA Mar25 ProdA Apr10 ProdB Jan25 ProdB Feb30 ProdB Mar50 ProdB Apr40 ProdC Jan40 ProdC Feb30 ProdC Mar20 ProdC Apr40 ProdD Jan10 ProdD Feb10 ProdD Mar 5 ProdD Apr10 {SNIP} Thanks in advance, Gurmeet Providing data as a printed table, like you did, is not the most effective way to transmit example data on this list. There are two major disadvantages: * Tabulated data often gets mangled in email * Tabulated data can not be copied and pasted directly into R to regenerate the example data.frame- it takes me ~4 minutes of mucking around with Excel to regenerate a .csv file that R can ingest. This added time will limit the number of people who will attempt to investigate your problem. The best way to transmit the contents of a data frame is to paste the output of the dput() function. This function dumps the data frame to an R command that can be simply copied and pasted into a R session to regenerate the data.frame. The results of dput is the structure() command I used in my example above. Hope this helps in some way! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Multi-panel-Pie-Charts-tp1687026p1689524.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multi-panel Pie Charts.
Gary Miller wrote: Thanks for your reply Sharpie. I completely understand that it may not be the best to go with muti-panel pie charts, but my group would like to have this utility along with barplot/dotplot (may be, using it for proportions data). Thanks, Well, if the management trolls *DEMAND* pie, then these sites provide a good start with ggplot2: http://learnr.wordpress.com/2009/08/20/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-13-2/ http://had.co.nz/ggplot2/coord_polar.html Using the data I posted before, you could apply those approach with: productPie - qplot( factor(1), value/100, data = productData, geom = 'bar', fill = variable, xlab = '', ylab = '' ) + facet_wrap( ~ month, scales = 'free_y' ) + coord_polar( theta = 'y' ) + scale_y_continuous( formatter = 'percent' ) + theme_bw() print( productPie ) The beauty of ggplot2 is that that is basically the same chart I posted last time, the bars have just been bent into a pie through the use of coord_polar(). It probably needs some fine-tuning, but I'll leave that up to you. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Multi-panel-Pie-Charts-tp1687026p1689591.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write: write array to file without NAs
jannis-2 wrote: Dears, does anyone know, how I can get R to save the values of an array in a csv like file using write(), but without printing NA to the file? I use ';' to seperate the elements, so : a=c(1,NA,2,3,3) write(a) should produce 1;;2;3;3 in the file. Thanks in advance! When using Nabble to post questions, it would be best to use the New Topic button at the top left of the forum view rather than posting in a random thread. Your question is completely unrelated to creating multi-paneled pie charts and this: * Confuses those who are following the pie chart thread. * Makes your question invisible to people browsing the Nabble forum unless they happen to look at the pie chart question. In which case they may get confused. Anyway, the answer to your question can be found in the help pages for write.table(): ?write.table Specifically, you may want to play with the arguments sep and na. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Multi-panel-Pie-Charts-tp1687026p1689863.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating pdfs using qplot in qqplot2
Bos, Roger-2 wrote: I am trying to create plots within a for loop and output them to a pdf. Here is a working example using plot: gg - data.frame(datadate=1:4, spread=5:8) pdf() for (i in 1:3) { plot(gg$datadate, gg$spread, main=i) } dev.off() I am trying to learn more about ggplot2 so I try a slight modification and it doesn't work. Anyone know how to do this using qplot in ggplot2? gg - data.frame(datadate=1:4, spread=5:8) pdf() for (i in 1:3) { qplot(gg$datadate, gg$spread, geom=line, main=i) } dev.off() This question gets asked many, many times and is answered in FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f Basically, old-school functions like plot() execute plotting commands directly when they are called. With Lattice-based graphics, like ggplot2, the composition of the plot and the execution of the plotting commands are separated into two steps. qplot() returns an object that contains the composition of the plot, the print() method performs the actual execution of plotting commands to a graphics device. When functions are called interactively in the top-level environment, an implicit call to print() is executed to display the results. When these same functions are used inside another function or for() loop, you will need to explicitly add the call to print() in order to get the same effect. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Creating-pdfs-using-qplot-in-qqplot2-tp1679488p1679523.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If else statements
tj wrote: Thanks Sam for the short but very helpful answer. That's what I only want to know. Thanks.=) ~tj Even though you got the answer you were looking for, I would still browse the material Matthew posted. The Introduction to R is a standard R manual that helped me greatly when I was learning the R language. The question you asked is answered in this manual and Eric Raymond's essay explains why asking questions that are answered in the manual can be socially risky on software mailing lists. You don't want the last reply you ever get from a list to be RTFM! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/If-else-statements-tp1678705p1679530.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Operator overloading for custom classes
Chidambaram Annamalai wrote: Hi, I need some help to get some of the object orientation, specifically the methods that overload the basic arithmetic operations, from sample C++ code to R. I don't have experience with such advanced language features inside of R. So I was wondering if some of you could help me out in this regard. {snip} For S3 objects: ?base::Ops http://n4.nabble.com/Operator-overloading-td854452.html#a854452 http://n4.nabble.com/Overloading-td850827.html#a850828 For S4 objects: ?methods::Ops http://n4.nabble.com/How-to-define-new-operators-td974842.html#a974842 A good resource for reading material on S4 classes, which are more formally defined than S3 classes, can be found in the R wiki: http://rwiki.sciviews.org/doku.php?id=tips:classes-s4 Hope this can get you started! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Operator-overloading-for-custom-classes-tp1679467p1679573.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rpad ?
sjaffe wrote: Based on a private response, it seems that rpad is no longer being maintained and in fact no longer works with the latest R release. I noticed that the web site listed in the FAQ no longer works, the code is being hosted by google code but it appears no one is working on it. Looking at the R Web Interfaces section of the R FAQ I don't really see anything comparable -- does anyone have a suggestion for a similar web-based front-end to R? You could try Sage: http://www.sagemath.org You can get a notebook account at: http://www.sagenb.org Sage uses python to integrate several open-source and closed-source mathmatics/computation packages and R is among one of the options available. It provides a nice Mathematica-like notebook interface where you can mix computations and annotations. If you don't want to type Sage code, just choose 'r' from the drop-down menu at the top of the worksheet next to the Typeset checkbox and the contents of every cell you enter will be passed directly to R for evaluation. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/rpad-tp1679534p1679599.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rpad ?
sjaffe wrote: Yes, I've tried Sage (briefly) and it is very interesting. But what I'm looking for here is a client-server system that allows multiple users to access the results of R without exposing the details. Maybe you're looking for something similar to this webapp: http://rweb.stat.ucla.edu/ggplot2/ The author's website is at: http://www.stat.ucla.edu/~jeroen/live.html I believe he used RApache to drive the site, but I'm not positive. The widgets are done in ExtJS. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/rpad-tp1679534p1679624.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving tab/csv delimited data with NaN's
shankar-17 wrote: Hello, I am working multiple simulated data sets with missing values, I would like to store these data sets in either tab delimited format for .csv format with missing values marked as NaN's instead of NA's. I read the import/export document which mentions that write.table command converts NaN's to NA. Is there any other way I can store the NaN's. I tried the write syntax it gives me error codes. Each data files are of dimensions 1000 x 21 . I would appreciate any help in this regard. Many thanks foo - matrix(0,nrow=3,ncol=3) foo [,1] [,2] [,3] [1,]000 [2,]000 [3,]000 foo[3,3] - NA foo [,1] [,2] [,3] [1,]000 [2,]000 [3,]00 NA write.csv( foo, file='tst.csv', na = NaN, row.names = F ) readLines( 'tst.csv' ) [1] \V1\,\V2\,\V3\ 0,0,00,0,0 [4] 0,0,NaN Seems to work fine for me. If you post a reproducible example, we could probably figure out why it is not working for you. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Saving-tab-csv-delimited-data-with-NaN-s-tp1679673p1679844.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving tab/csv delimited data with NaN's
Rolf Turner wrote: On 24/03/2010, at 12:34 PM, Sharpie wrote: foo - matrix(0,nrow=3,ncol=3) foo [,1] [,2] [,3] [1,]000 [2,]000 [3,]000 foo[3,3] - NA foo [,1] [,2] [,3] [1,]000 [2,]000 [3,]00 NA write.csv( foo, file='tst.csv', na = NaN, row.names = F ) readLines( 'tst.csv' ) [1] \V1\,\V2\,\V3\ 0,0,00,0,0 [4] 0,0,NaN Seems to work fine for me. If you post a reproducible example, we could probably figure out why it is not working for you. This doesn't work if you have both NAs and NaNs in your data frame and you want to distinguish between these. I.e. when you read the data back in, all NAs will have been converted to NaNs. Admittedly the OP said he wanted to represent all NAs as NaNs, so your solution would seem to work for him. cheers, Rolf Turner Aye, it still works if I replace the NA in my matrix with NaN. If there is a mixture of NAs and NaNs, there will be some loss of distinction as you say. However, I can not tell if this is the case from the original post-- hence the need for an example! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Saving-tab-csv-delimited-data-with-NaN-s-tp1679673p1679909.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Embed R code in C++
mans wrote: Hi, Can anyone tell me how to embed R code in a C++ file. I am actually using a mac running on the OSX 10.6.2 and the IDE Xcode Version 3.2 and I would like to embed the basic function like geometric, binomial, normal and hyper geometric distributions in a sample cpp file. I heard about the library RInside and i have downloaded the source code for mac but i do not know how to build it in order to use it with my IDE XCode. Could anyone help me step by step because I am new in programming to show me how to get this done? Thanks for your help. Mans. I use R on OS X, but haven't used Xcode that much- so I can't really offer any advice. However, you may try posting this question on the Mac-specific mailing list: https://stat.ethz.ch/mailman/listinfo/r-sig-mac Your question will probably get better answers there. Good luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Embed-R-code-in-C-tp1677784p1678051.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] importing .bil files
Barry Rowlingson wrote: GIS and spatial data formats can often be handled by readGDAL (for raster grids) from the rgdal package. .bil files seem to be handled by the Ehdr driver in GDAL: http://www.gdal.org/frmt_various.html so if your rgdal package has that driver (run gdalDrivers() to see) then you may be sorted. Barry I think it may be useful to add that rgdal is not provided as a pre-built binary package for OS X-- you have to build it from source. This is because it interfaces with the GDAL library which is a fairly intricate piece of software that one may wish to custom build. There are two options I know of for installing rgdal on OS X. The first is to use GDAL binaries provided by William Kyngesburye-- he has framework versions of GDAL along with a pre-built rgdal binary at: http://www.kyngchaos.com/software/frameworks#gdal The second option is to roll your own GDAL and build rgdal from source to link against it. You may want to use this option if William's binary version doesn't include the Ehdr driver. I posted some instructions for building the rgdal package from source at: http://n4.nabble.com/Help-with-RGDAL-td908487.html#a908488 Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/importing-bil-files-tp1677546p1678071.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Embed R code in C++
mans wrote: Hi thanks for your help but I tried to install the pakage but i have got a installing error: {SNIP} I do not understand what's going on to be honest. Anyone can help me? When debugging, it's usually a good idea to start with the first error: Error in loadNamespace(name) : there is no package called 'Rcpp' Did you install Rcpp? mans wrote: By the way i subscribed to the xcode forum for R and i sent a message to : r-sig-...@stat.math.ethz.ch. But the message is replied to me without any answer. Any Idea of what's going on? I am assuming you are referring to r-sig-mac as the xcode forum for R. Did you sign up for R-Sig-Mac at the following website: https://stat.ethz.ch/mailman/listinfo/r-sig-mac And then did you reply to the confirmation email before sending a message to r-sig-...@stat.math.ethz.ch? -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Embed-R-code-in-C-tp1677784p1678470.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ctable error with Hmisc and Sweave (on a Mac)
Clay Heaton wrote: Hi, pretty new with R and LaTeX here... I'm trying to use the latex() function from the Hmisc table with Sweave. When I try: pdflatex myfile.tex I get an error that reads: ! Undefined control sequence. l.22 \ctable It seems like this is an optional package for Tex that I haven't installed? My googling skills have neglected to locate instructions for how to install ctable on a Mac, though I've locate the ctable package. I reinstalled MacTex-2009 in hopes of solving the problem, but so far it hasn't helped. Can anybody shed light on this error and how I might fix it? Thanks, Clay The undefined control sequence error from LaTeX usually means you haven't loaded a latex package that provides a given command or environment. Just as you have to load a package in R using library() or require() before you can use functions from that package, you have to specify in your LaTeX document that you are going to use a given package before you can use commands for that package. This is indicated by adding: \usepackage{packageName} Somewhere before the \begin{document} statement in your Sweave/LaTeX file. If you don't have the package installed, you will get an error message that looks like: ! LaTeX Error: File `packageName.sty' not found. You can check to see if a given LaTeX package is installed on your system using the kpesewhich command that works similarly to the Unix/Linux command which: kpsewhich packageName.sty If kpsewhich doesn't return a path to a .sty file, then the package you attempted to find is not installed on your LaTeX search path. Since you are using MacTex 2009 which is based on TeXlive 2009, you can use the TeXlive package manager to install missing packages from the command line: tlmgr install packageName Since you are using a Mac, there is a GUI option to perform all this searching and installing without having to use the command line (although it is always a good idea to know how to do something from the command line). Simply download Tex Live Utility from the following website: http://code.google.com/p/mactlmgr/ It provides a nice GUI from which you can install and update TeX based packages and utilities. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/ctable-error-with-Hmisc-and-Sweave-on-a-Mac-tp1678494p1678588.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] calling external .EXE file in R macOSX
Alex Anderson wrote: Hi All, I am currently working on an analysis which requires a call to an external FORTRAN routine contained within a file called MCDS.EXE. This file is usually called from within a WINDOWS program called DISTANCE. I have some R script from the developers of the original software which apparently makes a call to this .EXE file which i need to re-engineer slightly, but i am having difficulty interpreting how the script makes this call and passes to the EXE file the relevant input command file and data file for processing. I am also unsure if making such a call will work within the OSX environment for a (windows?) executable file. Below is an example from the script which is supposed to make the call. Any suggestions would be much appreciated. Cheers A {snip} Hrm, I really can't tell what that function you posted does-- it seems to be mostly comments. But I would imagine MCDS.EXE is being run using something like a call to the system() function. The problem with running the program on OS X is that MCDS.EXE is a Windows binary. You can't just run a binary compiled for Winows on OS X or Linux more than you could run a binary compiled for OS X or Linux on Windows. Your options include: 1. Get the Fortran source code, recompile MCDS on OS X , and run the program using something like system('mcds') 2. Get the Fortran source code, refactor and recompile MCDS as a shared library, load directly into R, and run the routines using .Fortran() 3. Try using an emulator, such as Wine (www.winehq.ort), and run the program using something like system('wine MCDS.EXE') Number three would require the least amount of hassle, but is not guaranteed to work. Other people may have better suggestions and you might try asking on the mac-specific R mailing list: https://stat.ethz.ch/mailman/listinfo/r-sig-mac The people there may be able to give you better answers concerning R and OS X Good Luck! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/calling-external-EXE-file-in-R-macOSX-tp1677148p1677162.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] EM algorithm in R
tj wrote: Thanks David. I already tried two different programs for this. The first one has errors. I'm working right now on my alternative program ( i hope it will work), BUT I still prefer to use the first program I made because it is more detailed. So, I'm trying how to correct the errors in the first R program. After doing two different programs, I just felt frustrated of getting errors all the time that's why I asked someone's help. Thank you. ~tj I think what David meant is that if you want help with working out errors in a homework problem, then you need to post the work you have done so far. You won't get good answers from My problem is to calculate x from y by using steps one two and three-- please show me how but you may get answers from I am trying to calculate x from y using Fisher's Test for Funkiness but I'm stuck when I try to calculate the coefficient of crumple. My code below attempts to calculate crumple by integrating the doohicky distribution over the range -1 to 1 but R is throwing a wobbly when I use integrate(). Is there something I am doing wrong? In other words, if you are getting frustrated by errors then you need to show us what you are doing and what kind of errors you are getting. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/EM-algorithm-in-R-tp1663020p1676023.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unable to install Cairo package
Alla Bulashevska wrote: Dear R users, I'm running R version 2.10.1. I tried installing the Cairo package and I got the following message: * installing *source* package Cairo ... {snip} checking cairo.h usability... no checking cairo.h presence... no checking for cairo.h... no configure: error: Cannot find cairo.h! Please install cairo (http://www.cairogra phics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly. ERROR: configuration failed for package Cairo Any help would be greatly appreciated. Alla The Cairo package for R provides an interface to the Cairo graphics library- therefore that library must be installed for the package to work. Configure scripts are notorious for having cryptic error messages, but this one is actually very explicit about stating what the problem is. You need to: 1. Install Cairo and try installing the package again. Or, if you have Cairo installed in a non-standard location that the configure script can't find: 2. Set -L/path/to/libcairo in the CAIRO_CFLAGS option and try installing again. In cases when package installation is failing, it is also very important to tell us what operating system you are using as these issues are often platform-dependent. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Unable-to-install-Cairo-package-tp1598140p1598264.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] list names
Robert M. Flight wrote: So I have a list variable, and each item has a name. Is it possible to return just the names in the list and not the contents of each one? Example: Currently, if I have a list variable matrices, and it contains 3 matrices, M1, M2, and M3, if I type: matrices, R returns $M1 - listing of numbers in matrix; $M2 - listing of numbers in matrix, and $M3 - listing of numbers in the matrix. Is there a way to have it return only the names $M1, $M2, $M3? I know this seems trivial and I'm sure it has been asked before, but I can't find it. Thanks in advance. -Robert ?names The help.search() function can be useful for finding functions when you know what you want to get done, but not which function does it. For example: help.search( names ) Would list several functions and their descriptions would help you find the one you wanted. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/list-names-tp1598316p1598330.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R front end help
rrp wrote: hi I am doing a project in R language.I need help with creating a front end in R language. i created a dialog box with file menu n file consists of load ,save and quit options. But these options are not working.I try to load my data into r using these options but its not working. pls help. thanks in advance. the dialog box looks like below. Based on the information you have given us, there is no way to help you because there is no code we can examine or run to try and reproduce your problem. Please read the posting guide for this mailing list as it details the information that we need in order to attempt to answer your questions: http://www.r-project.org/posting-guide.html -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/R-front-end-help-tp1598548p1598563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Substitute NAs in a data frame
Marsh wrote: Excuse me for what I'm sure is a stupid beginner's question, but I've given up trying to find the answer to this question from the help, RSiteSearch, or any of the usual places. I have a list that looks like this: myList $first [1] -- 18 8 32 $second [1] -- -- 40 54 I want a straightforward way to replace -- with NA so that the list looks like: myList $first [1] NA 18 8 32 $second [1] NA NA 40 54 Now I know I can do something like: myList$first - sub(--,NA,myList$first) but the real list has lots of components. So is there some easy way to do something like: myList - applier(myList,sub,--,NA) where applier is a function that will do what I want? I tried using lapply, sapply, etc. without luck. Thank, Marsh You had it correct if you use lapply, you just need to name the additional arguments you are passing: myList - lapply( myList, sub, pattern = '--', replacement = NA ) The sub-lists of myList will be positionally matched to the third argument of the sub function, which is x. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Substitute-NAs-in-a-data-frame-tp1598621p1598638.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Writing own simulation function in C
TheSavageSam wrote: Thanks for the huge help. I have learned a lot and been able to start writing my own code. If you could give me a reference(a link, name of a book, etc.) to a good manual of how to use and manipulate and use SEXP variables in C (considering creating R libraries) it would be great help to me. Unfortunately, I can't really recommend anything beyond what has already been mentioned in this thread- I learned most of what I know about interacting with R at the C level from Writing R Extensions and by browsing the comments in the R source. If anyone else knows of good books/articles/blog posts that discuss hacking around with R at the C level, I would be interested to see them as well. -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Writing-own-simulation-function-in-C-tp1580190p1597080.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave and kile
pomchip wrote: Dear R-users, I want to give a try to Sweave and Latex but I am having some problems compiling my .Rnw files within Kile. I have followed the recommendations given in http://tolstoy.newcastle.edu.au/R/e5/help/08/10/4277, but they do not seem to address my particular problem. I am using R 2.11.0 and Kile v 2.0.83 on an OpenSUSE11.2 installation (KDE 4.3 environment). According to the log (see below), Kile is unable to locate the Sweave.sty file (which is actually stored in /usr/lib/R/share/texmf/). Any advise would be welcome. Sebastien {snip} ! LaTeX Error: File `Sweave.sty' not found. Type X to quit or lt;RETURNgt; to proceed, Sweave uses a LaTeX style file, Sweave.sty, via \usepackage{Sweave} to format R input/output in the final report. It looks like this file is not on your LaTeX search path. I believe it can be found in: R_HOME/share/texmf You could try: mkdir ~/texmf ln -s $R_HOME/share/texmf/Sweave.sty /home/your user name/texmf/Sweave.sty texhash As LaTeX will usually include ~/texmf as a place it will look for style files on Linux. The texhash command will cause the database of available files to be rebuilt. If the command: kpsewhich Sweave.sty Returns nothing, then LaTeX won't be able to find the file Sweave.sty during compilation unless it is in the same folder as the .tex file you are compiling. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Sweave-and-kile-tp1597376p1597388.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help running a Fortran subroutine from R
dc896148 wrote: useR's, I need help getting a Fortran DLL successfully returning the correct output. The attached fortran source code (filter2d.f) and DLL (filter2d.dll) are attached. Also, I attached a text file for which I want to apply the filter to (time702.txt). Here is what I am doing... dyn.load(C:/f/NEW/filter2d.dll) is.loaded(filter2d) [1] TRUE Then I pass the parameters according to the order they are specified in the filter: array - data.matrix(read.table(time702.txt,header=F)) array1 - array nx - 60 ny - 120 halfintx - 3 halfinty - 3 mask - matrix(array(rep(1.0,25)),5,5) subarray - matrix(0,5,5) subarray1 - matrix(0,5,5) Then I run the Fortran subroutine... out - .Fortran(filter2d, as.single(array), as.single(array), as.integer(nx), as.integer(ny), as.integer(halfintx), as.integer(halfinty), as.single(mask), as.single(subarray), as.single(subarray1)) The smoothed output is 'array1', which I just passed as 'array' in the specification. It can be any matrix, but must be the same dimension as 'array', which is given as nx by ny. Missing values in time702.txt are denoted by 999.00, and are defined that way in the subroutine. Can anyone see where I may be doing something wrong? I am not good with fortran, as this code was previously written and now I am trying to adapt it to R on the fly. Basically, filter2d smooths 'array' by averaging within the window halfintx by halfinty. Can anyone please help me out or provide some clarification? You have done a great job of showing us how you set up the call to Fortran- but you haven't clearly stated what the problem is. As far as I can tell from your post, the Fortran DLL is not returning the correct output. Could you elaborate on what output, if any, you are getting and what output you were expecting? -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Help-running-a-Fortran-subroutine-from-R-tp1595641p1595739.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating images without X11
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 -- View this message in context: http://n4.nabble.com/Creating-images-without-X11-tp1592016p1592201.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help! I need to use R to calculate a recursive function!
anan1986 wrote: I tried! but my solution is not correc! What is not correct? What did you try? You need to supply us with details! Specifically, the details that are mentioned in the posting guide for this mailing list: http://www.r-project.org/posting-guide.html Data! Data! Data! he cried impatiently. I can't make bricks without clay. -Sherlock Holmes: The Adventure of the Copper Beeches - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Help-I-need-to-use-R-to-calculate-a-recursive-function-tp1586189p1586809.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Writing own simulation function in C
TheSavageSam wrote: I am wishing to write my own random distribution simulation function using C programmin language(for speed) via R. I am familiar with R programming but somewhat new to C programming. I was trying to understand Writing R extensions -guide and its part 6.16, but I found it hard to understand(http://cran.r-project.org/doc/manuals/R-exts.html#Standalone-Mathlib). I also tried to get familiar with the example codes, but it didn't make me any wiser. The biggest problem seems to be how to get(what code to write in C) random uniform numbers using Rmath. That seems to be too complicated to me at the moment. So if someone of you could give a small example and it would definitely help me a lot. All I wish to do first is to finally write(and understand) my own function similar to what you run in R Command line via command runif. And all this I am hoping to do without recompiling my whole R. Instead of that I think that it is possible to use dyn.load(code.so) in R. (Yes, I use linux) If the code in this message gets mangled by the mailing list, try viewing it on nabble: http://n4.nabble.com/Writing-own-simulation-function-in-C-td1580190.html#a1580190 ... Actually, funny story... I wrote this post using Nabble, but the Spam Detector refuses to let me post it claiming that there are too many sex words due some constructs in the R language. So I guess this confirms that using R is the quickest way to increase your statistical manhood/womanhood. As a result of this, all code chunks have been moved to a gist at GitHub-- links are provided. ... I would suggest first learning how to implement callbacks to R functions from C functions rather than diving straight into calling the C implementations of R functions. The reasons are: 1. You already know how the R functions is supposed to be called. 2. You don't have to search through the R source to track down the C implementation of the function you are after. I would also bet that the overhead of calling an R function that calls it's compiled implementation is not that significant-- but I haven't done any profiling. The way I would approach this problem would be to create a new package since the package structure helps manage the steps involved in loading and testing the compiled code. So, here's an example of calling the R function runif() from C (tested on Linux Mint 8 with R 2.10.1): Start an R terminal and execute the following: setwd( 'path/to/wherever/you/like/to/work' ) # Create a dummy wrapper function to start the package with myRunif - function( n, min = 0, max = 1 ){} # Start the package package.skeleton( 'RtoC' ) Now, quit R. You'll notice that a folder called RtoC appeared in the directory where R was working. Edit RtoC/R/myRunif.R to contain the following: see: http://gist.github.com/323498#file_my_runif.r The above R function is a wrapper for our compiled C function. It states that we will be calling a C routine named myRuinf and passing the parameters n, min and max. The .Call() interface will pass these arguments as separate SEXP objects, which are the C-level representation of R objects. The alternatives to .Call are .External which gathers all the arguments up and passes them as a single SEXP and .C() which passes them directly as basic C variables (care must be used with .C(), you may need to wrap things in as.double(), as.integer(), etc.). I am using .Call() over .C() because .Call() allows an SEXP (i.e. native R object) to be returned directly. .External() also returns a SEXP, but we are calling back to an R function so we would have to split each argument into a separate SEXP anyway. With .C() we would have to coerce the C types to separate SEXP variables. Furthermore, with .C(), an additional variable to hold the return value would have to be included as an argument the function as we are expecting to return a vector and all the arguments are scalars. So, now the task is to write the C implementation of myRunif. Create the following folder in the package: mkdir RtoC/src Any C or Fortran code placed in the /src folder of an R package will be automagically compiled to a shared library that will be included when the package is installed. So, let's add a C routine, RtoC/src/myRunif.c: see: http://gist.github.com/323498#file_m_runif.c The first thing that myRunif.c does is to locate the namespace of the stats function. This is important as runif() lives in that namespace and we will be executing a call to it later. The first thing to note is that results returned by R are assigned inside of a PROTECT() statement. This is because SEXPs are *pointers* to data and we don't want the R garbage collecter to munch the data we're pointing to before we get a chance to use it. After finding the stats namespace, the second operation is to set up the call back to the R function ruinf()-- this is started by creating a vector of type language that has a
Re: [R] Three most useful R package
Ralf B wrote: Hi R-fans, I would like put out a question to all R users on this list and hope it will create some feedback and discussion. 1) What are your 3 most useful R package? and 2) What R package do you still miss and why do you think it would make a useful addition? Pulling answers together for these questions will serve as a guide for new users and help people who just want to get a hint where to look first. Happy replying! Best, Ralf 1. ggplot2 2. plyr 3. rgdal And any package such as RJava that allows native, or near native access to other programming languages. Strength in numbers! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Three-most-useful-R-package-tp1575671p1575949.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] turn character string into unevaluated R object
Tim Calkins-2 wrote: fortune('parse') -- Tim Calkins 0406 753 997 Or would that be: fortune( 106 ) ? - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/turn-character-string-into-unevaluated-R-object-tp1575839p1576045.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove from mailing list
mirauta wrote: Hello, I receive a lot of emails from the forum members.Is there any way to make the option for a daily summary?If not can may email be removed from the list?I want to continue using the forum but the numebr of emails I receive dialy is too big :) Thanks,Bogdan This mailing list is managed by GNU mailman. As with all mailman lists, you can choose to receive a daily summary or remove yourself from the list by visiting the mailman server page. For r-help this page is at: https://stat.ethz.ch/mailman/listinfo/r-help All this information should have been contained in the 'Welcome to the R-help mailing list' email you received after signing up. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/remove-from-mailing-list-tp1573270p1573288.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] wrap long lines in table using latex in Hmisc
Tao Shi wrote: Thank you guys for the wonderful suggestions! Charlie, You obviously foresaw my problem! It took me a while to figure out that the \raggedright and other justification commands should be applied to each cell. It didn't work for me when applied to the headings. See this nice document here: http://nepsweb.co.uk/docs/tableTricks.pdf Thanks again. ...Tao This article also contains some nice tricks for table formatting: http://www.tug.org/pracjourn/2007-1/mori/mori.pdf And for aligning columns of numeric values, I highly recommend the S column descriptor provided by the siunitx package: http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=siunitx -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/wrap-long-lines-in-table-using-latex-in-Hmisc-tp1571298p1574173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] capturing errors in Sweave
Sundar Dorai-Raj-2 wrote: Hi, I'm writing a manual using Sweave and I want to be able to print errors from bad code. Here's an example: Function-4a= MySqrt - function(x) { if (missing(x)) { stop('x' is missing with no default) } if (!is.numeric(x)) { stop('x' should only be numeric) } if (x 0) { stop('x' should be non-negative) } return(sqrt(x)) } MySqrt() MySqrt(a) MySqrt(-2) MySqrt(4) @ And I would like the output to be: MySqrt - function(x) { ... } MySqrt() Error in MySqrt() : 'x' is missing with no default MySqrt(a) Error in MySqrt(a) : 'x' should only be numeric MySqrt(-2) Error in MySqrt(-2) : 'x' should be non-negative MySqrt(2) [1] 1.414214 I.e. I want the Error statements to print in the tex file and not just make Sweave to bomb. Thanks, --sundar You can catch errors in R using the try() function: foo - try( log(A), silent = TRUE ) if( class( foo ) == 'try-error' ){ print( unclass( foo ) ) } [1] Error in log(\A\) : Non-numeric argument to mathematical function\n There might be a more clever way to override the default error handling that would save you from wrapping everything in try()-- but this method should work. Hope it helps! -Charlie - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/capturing-errors-in-Sweave-tp1574642p1574686.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Slightly OT: Does anyone use latex2rtf with sweave output ?
Paul Hurley wrote: Hello, I'm trying to use R (and Sweave) to pull some data out of a database and produce some standard reports. unfortunaltey, the people who want the reports want them in an editable format so they can add wordy bits to the automatically generate tables and graphs. My current plan is to use R to call a standard sweave document and pass variables to tell what data to pull out of the db, then use latex2rtf to turn the tex file into rtf. However I'm stuck with latex2rtf. It's chocking on some of the latex that sweave wrote (such as {Schunk} {Soutput} {Sinput}. Has anyone used latex2rtf succesfully with sweave and is willing to share their experiences ? Thanks Paul. Some possibilities: - Use a different output format that can be more easily converted to Word or RTF. Possibilities are HTML via the R2HTML Sweave driver or an Open Office document via the odfWeave driver. - Use a different report generation tool that doesn't add as much extra markup to the output, such as brew. - Try converting the tex to HTML instead of RTF-- plasTeX or tex4ht may be more robust (though I still doubt they would know what to do with the Schunk, Sin and Sout tags as those are non-standard LaTeX). I happen to be working on a project that may end up doing the same thing-- automatically generated reports containing summary graphs and tables. I love LaTeX myself, but I'm currently planning to produce the reports in HTML format just in case someone less typographically inclined needs to edit them. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/Slightly-OT-Does-anyone-use-latex2rtf-with-sweave-output-tp1572533p1572839.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help question: How can we enable useRs to contribute corrections to help files faster ?
Duncan Murdoch wrote: Yes, I agree. In fact, I think the whole system needs to be updated. Anyone like doing HTML design? If I had the time, I would raise my hand for this one-- unfortunately school, work and other commitments leave me with a full schedule for the foreseeable future. Now that all R man pages are presented using a HTML server, it would be nice to overhaul the presentation. Perhaps something like the output of Python's Sphinx: http://docs.python.org/3.1/tutorial/ The key elements I'm thinking of are: - A sidebar with table of contents/navigation - A search box Personally, I try to put an \author{} field with an email in all of my .Rd files-- adding this as a requirement to R CMD check could enforce this behavior. It could also break 99% of all the package builds on CRAN. Another way package author/maintainer emails can be quickly obtained is through the packageDescription() function: packageDescription('packageName')$Maintainer -Charlie -- View this message in context: http://n4.nabble.com/R-help-question-How-can-we-enable-useRs-to-contribute-corrections-to-help-files-faster-tp1572568p1572854.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help question: How can we enable useRs to contribute corrections to help files faster ?
After reading some more, I think Tal's Wiki idea was also a good one-- conceivably a server could be set up that pulled tarballs from CRAN, unpacked them, and converted the man folders to HTML. Then the server could provide a sort of a master list version of help.start() where each page was editable using some sort of wiki system. Users could fix documentation and developers could download patchfiles that contained the diff between the current wiki page and the their version of the documentation that was stored on CRAN. Sigh, my lack of free time is frustrating this morning... -Charlie -- View this message in context: http://n4.nabble.com/R-help-question-How-can-we-enable-useRs-to-contribute-corrections-to-help-files-faster-tp1572568p1572865.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A slight trap in read.table/read.csv.
Rolf Turner wrote: I solved the problem by putting in a colClasses argument in my call to read.csv(). But I really think that the read functions are being too clever by half here. If field entries are surrounded by quotes, shouldn't they be left as character? Even if they are all F's and T's? It has been my experience that fields surrounded by quotes are interpreted as factors unless the stringsAsFactors switch has been set to false. So it seems the default behavior of read.table is to be clever. Annoying as these behaviors are, changing them would probably break existing code that expects the function to execute the way it does. -Charlie -- View this message in context: http://n4.nabble.com/A-slight-trap-in-read-table-read-csv-tp1573007p1573018.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why software fails in scientific research
John Maindonald wrote: I came across this notice of an upcoming webinar. The issues identified in the first paragraph below seem to me exactly those that the R project is designed to address. The claim that most research software is barely fit for purpose compared to equivalent systems in the commercial world seems to me not quite accurate! Comments! WEBINAR SERIES A Crack in the Code: Why software fails in scientific research, and how to fix it. Thursday, March 25, 2010, 3:00 PM GMT http://physicsworld.com/cws/go/webinar9 In the 60 years since the invention of the digital computer, millions of lines of code have been developed to support scientific research. Although an increasingly important part of almost all research projects, most research software is barely fit for purpose compared to equivalent systems in the commercial world. The code is hard to understand or maintain, lacking documentation and version control, and is continually ‘re-invented’ as the code writers move on to new jobs. This represents a tremendous waste of the already inadequate resources that are put into its development. We will investigate how this situation has come about, why it is important to the future of research, and what can be done about it. Robert McGreevy will draw on his extensive experience at the STFC ISIS Facility, and explain how these issues are being addressed for the benefit of research science globally. Nicholas Draper, consultant at Tessella, will then expand on this, using the example of the Mantid project at ISIS. Tessella (www.tessella.com) is a technology and consultancy firm, based in Oxford. ISIS (International Species Information System) (www.isis.org) has as its mission the facilitation of international collaboration in the collection and sharing of knowledge on animals and their environments for zoos, aquariums and related organizationsvalues the use of objective data to benefit conservation, science, animal welfare, education, and collection management. John Maindonald email: john.maindon...@anu.edu.au phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Mathematics Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. http://www.maths.anu.edu.au/~johnm I personally feel that a lot of this is a result of failing to publish the code that was developed to perform research along with the results of the research. When setting out to do start a new project, one can dig up tons of journal articles that will happily inform how data was gathered, what equations were used and wrap it all up with nicely formatted tables and graphs that show X is correlated to Y. What these articles fail to report is the code that was developed to filter and process the raw data and then apply the equations to produce the figures and tables. The next generation of researchers that are seeking to extend the results then end up writing their own code rather than building upon what has already been done. The R community has done a tremendous job in encouraging truly reproducible research through the package system and tools like Sweave which provide a means to combine and maintain data, code and reports-- but we need more. In my opinion, we need to start seeing websites that provide services similar to github or bitbucket-- but with a focus on scientific research. I should be able to set up a versioned repository somewhere in the cloud for my research projects that hosts not only my code, but my data and reports. I could then choose to make this resource publicly available and other researchers could fork my work with a single mouse click and start collaborating on my project or extend what I've done into a project of their own. And that's my two cents on the state of software in research. -Charlie -- View this message in context: http://n4.nabble.com/Why-software-fails-in-scientific-research-tp1573062p1573068.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Aerodynamic Package(s)?
Charles Annis, P.E. wrote: Jason: What are you trying to do? Your reference link provides several Fortran programs. Why can't you use those? Or you could translate them into R code if you would like to take advantage of R's wonderful graphics and multitudinous other statistical adjuncts. It's also worth noting that R could most likely access the Fortran code directly if it was built into a shared library using R CMD SHLIB or, better yet, placed into the src/ directory of an R package. Then, rather than spending the time to re-write the Fortran in R, R could be as an interface which provided front end data preparation and back end data analysis and visualization. -Charlie Charles Annis, P.E. wrote: Your request seems too broad to allow a more focused response. Perhaps we could be more helpful if you told us what you are trying to accomplish. Charles Annis, P.E. -- View this message in context: http://n4.nabble.com/R-Aerodynamic-Package-s-tp1565840p1572212.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Best Hardware OS For Large Data Sets
David Winsemius wrote: Perhaps the fact that the stable CRAN version of R for (any) Windows is 32-bit? It would expand your memory space somewhat but not as much as you might naively expect. (There was a recent announcement that an experimental version of a 64- bit R was available (even with an installer) and there are vendors who will supply a 64-bit Windows version for an un-announced price. The fact that there was not as of January support for binary packages seems to a bit of a constraint on who would be able to step up to use full 64 bit R capabilities on Win64. According to this post by Dr. Ripley: http://n4.nabble.com/R-on-64-Bit-td1563895.html CRAN is building 64bit Windows packages for R 2.11 which is currently under development. From the looks of it, 64 bit support may be coming to Windows with the next major release of R. David Winsemius wrote: I'm guessing from the your failure to mention potential software constraints that you are not among that more capable group, as I am also not.) https://stat.ethz.ch/pipermail/r-devel/2010-January/056301.html https://stat.ethz.ch/pipermail/r-devel/2010-January/056411.html -- View this message in context: http://n4.nabble.com/Best-Hardware-OS-For-Large-Data-Sets-tp1572129p1572256.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text editors
Dwayne Blind wrote: Dear all, Do you use a text editor ? What would you recommend for Windows users ? What about Tinn-R ? Thank you very much, Dwayne Learning a text editor is a significant and very valuable investment of your time. In order to maximize the return from this investment you will want to choose an editor that works well with all the languages and operating systems you currently use, as well as the ones you may use in the future. For example, I spend an equal amount of time working on Windows, OS X and Linux. There are a ton of great Windows-only editors out there, but they aren't a good option for me because I only use windows 1/3 of the time I'm at a computer. Some good editors I know of that fall into this category are Emacs, Vim and Eclipse. For integrating with R, Emacs has the ESS plug-in and Eclipse has an extension called StatET. Eclipse is a rather large in terms of file size compared to Emacs or Vim-- also I know Emacs and Vim can be used through a ssh connection. I'm not sure about Eclipse as I haven't used it much. This is important because if you happen to be stuck on a computer that is locked down and doesn't have your editor of choice installed there is still a chance that you will be able to use ssh to reach a computer that does. Personally, I use Vim and have found it just fine for my needs. ESS: http://ess.r-project.org/ StatET: http://www.walware.de/?page=/;jsessionid=b4d82261e53bd419d41609155e9e -Charlie -- View this message in context: http://n4.nabble.com/text-editors-tp1570848p1571021.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text editors
Sharpie wrote: For example, I spend an equal amount of time working on Windows, OS X and Linux. There are a ton of great Windows-only editors out there, but they aren't a good option for me because I only use windows 1/3 of the time I'm at a computer. Some good editors I know of that fall into this category are Emacs, Vim and Eclipse. For integrating with R, Emacs has the ESS plug-in and Eclipse has an extension called StatET. Sigh, I really need to remember-- coffee *before* mailing list. What I meant to say is Some good editors I know of that fall into the category of being platform-neutral are Emacs, Vim and Eclipse Sorry for any confusion. -Charlie -- View this message in context: http://n4.nabble.com/text-editors-tp1570848p1571038.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] wrap long lines in table using latex in Hmisc
Ista Zahn wrote: Hi Tao, Just set the appropriate *.just argument, e.g.: Dat - data.frame(x1 = rep(this value consists of a long string of text, 5), x2 = rep(this value consists of an even longer string of text, 5)) library(Hmisc) latex(Dat, col.just = rep(p{1in}, 2)) You can also set justification for column headings, column group headings etc. See ?latex for details. Best, Ista As Ista said, you can use the p{}, m{} and b{} LaTeX column specifications to create a table column that enforces a line wrap on it's contents. See: http://en.wikibooks.org/wiki/LaTeX/Tables#The_tabular_environment for full details. However, one problem with using say, p{2in}, is that the text is set *fully justified*. This means that the inter-word spacing in each line is expanded so that the line fully occupies the allotted 2 inches of space. For some tables the results are a typographical travesty. The solution is to prepend a {justificationCommand} to your column specification, such as: {\centering}p{2in} The justification commands you can use are : \centering- Centers wrapped text \raggedright - *left* aligns wrapped text \raggedleft - *right* aligns wrapped text Remember to double the backslash if you are passing this command as an argument in R. This trick will cause a LaTeX compilation error if used to specify the right-most column in a table, unless the hmisc latex() command produces tables that use \tabularnewline to invoke table row breaks instead of \\. Hope this helps. -Charlie -- View this message in context: http://n4.nabble.com/wrap-long-lines-in-table-using-latex-in-Hmisc-tp1571298p1571496.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginners
Patrick Burns wrote: * What were your biggest misconceptions or stumbling blocks to getting up and running with R? R was the first scripting language that I *really* invested time in learning. Prior to R I had a few years experience programming in Fortran and had worked on a few projects using Matlab. Because most of my programming experience was with Fortran, the toughest thing to get my head around was definitely lexical scoping and that unlike Fortran subroutines, R function results had to be assigned to something in order to persist outside of the function. Patrick Burns wrote: * What documents helped you the most in this initial phase? Definitely the An Introduction to R manual that ships with the core distribution. It helped me translate my knowledge of programming concepts to the R language very quickly. Patrick Burns wrote: I especially want to hear from people who are lazy and impatient. Feel free to write to me off-list. Definitely write off-list if you are just confirming what has been said on-list. -- Patrick Burns -- View this message in context: http://n4.nabble.com/two-questions-for-R-beginners-tp1569384p1569901.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Graphics into Latex
Lars Bishop-2 wrote: Hi, I'm new in Latex and I'm trying to include an R chart into a Latex document. This is what I'm doing: 1) In R: save the chart as a a Postcript in a folder C:/xxx/Density.eps So, to be clear, your graphic is saved on the C drive. Lars Bishop-2 wrote: 2) In Latex (using TexWorks on windows xp) : In the preambule: \documentclass[11pt]{article} \usepackage{graphicx} \begin{document} blah..blah blah \begin{figure} \centering \includegraphics{C:/xxx/Density.eps} \label{fig:Density} \end{figure} --This is the Error Message I'm getting: LaTeX Warning: File `R:/MarsTH/Studies/Misc/LIA QA/R/Density.eps' not found on input line 26. And LaTeX is looking on the R drive. Not quite sure how to fix this as you did specify C:/xxx/Density.eps in your call to \includegraphics{}. TeX and LaTeX were developed in UNIX environments where there are no C drives or R drives that segment the file system-- everything is contained under /. There may be some special way you have to enter Windows paths. Lars Bishop-2 wrote: ! LaTeX Error: Unknown graphics extension: .eps. You said you were using TeXworks which uses pdflatex as the default compiler. pdflatex compiles directly from .tex to .pdf and supports a wide variety of graphic inputs *EXCEPT* for .eps as the warning message above indicates. The older method of compiling LaTeX documents is to use the latex compiler which produces a .dvi file, then running dvips to produce a postscript file and then running ps2pdf to produce a pdf file. The latex compiler *ONLY* supports .eps as a graphic input. Personally, I would stick with the pdflatex compiler and switch to using the pdf() device in R for your graphics output. Hope this helps! -Charlie Lars Bishop-2 wrote: See the LaTeX manual or LaTeX Companion for explanation. Type H return for immediate help. I'll appreciate your help. Thanks in advance, Lars. -- View this message in context: http://n4.nabble.com/R-Graphics-into-Latex-tp1568266p1568391.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use a 'hidden' function directly?
Dale Steele wrote: I would like to be able to use two functions; qansari and pansari which are found in the function ansari.test. How can I evaluate these functions independently? Thanks. --Dale For example, when I load the function ... qansari - function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } and attempt to evaluate ... qansari( 0.025, 5, 5) Error in qansari(0.025, 5, 5) : object 'R_qansari' not found If R_qansari is the name of a compiled C subroutine you are trying to execute, then it needs to be passed to .C as a quoted string: .C( R_qansari , as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q Otherwise R, as usual, is looking for a *variable* named R_qansari that it assumes holds a string that will tell it which C routine to call. It does not find such a variable and gives the error message shown above. -Charlie Dale Steele wrote: methods(ansari.test) stats:::ansari.test.default the two functions that are part of ansari.test.default: qansari - function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } pansari - function(q, m, n) { .C(R_pansari, as.integer(length(q)), p = as.double(q), as.integer(m), as.integer(n))$p } -- View this message in context: http://n4.nabble.com/How-to-use-a-hidden-function-directly-tp1568392p1568401.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use a 'hidden' function directly?
Dale Steele wrote: methods(ansari.test) stats:::ansari.test.default the two functions that are part of ansari.test.default: qansari - function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } pansari - function(q, m, n) { .C(R_pansari, as.integer(length(q)), p = as.double(q), as.integer(m), as.integer(n))$p } Sorry, I didn't consider this part of your message carefully. R_quansari and R_pansari are indeed variables, but they are unexported variables in the stats namespace. Therefore if you want to use these functions outside of their namespace, you will need something like: pansari - function(q, m, n) { .C( stats:::R_pansari, as.integer(length(q)), p = as.double(q), as.integer(m), as.integer(n))$p } Hope this helps! -Charlie -- View this message in context: http://n4.nabble.com/How-to-use-a-hidden-function-directly-tp1568392p1568408.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to pass external parameters to an R script
mauede wrote: How, if possible, can I run an R script, from command line, passing external parameters just like I can run a C main program passing parameters: # Cprog p1 p2 p3 Cprog can access its arguments (p1,p2,p3) through the built-in structures argv and argc. Since R is built on C language I would expect the same feature to be available with R scripts as well ... ? Please, notice that I do not mean to open an interactive R session, assign values to p1, p2, p3 and then call the R script from the same interactive session. This way I daresay that p1, p2, p3 would be known to the R script as global variables. Thank you very much. Maura Command line arguments can be retrieved using the commandArgs() function. For more complicated argument processing, CRAN has the getopt and optparse packages. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/how-to-pass-external-parameters-to-an-R-script-tp1566077p1566487.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exporting Graphs
Karthik wrote: Hello Tal, This is the code. hist(rnorm(100)) jpeg(histogram.jpeg) --- Even when I decrease the quality, I still have the same problem. hist(rnorm(100)) jpeg(histogram.jpeg,quality=30) Thank you for taking a look. Karthik Hi Karthic, You have things a little mixed around there-- use plotting commands after you open an output device. Like so: jpeg( histogram.jpeg ) hist( rnorm(100) ) And when you're done, don't forget to call dev.off(). As you mentioned that you are a beginner, I would strongly suggest flipping through the Introduction to R manual. A copy can be accessed online at: http://cran.r-project.org/doc/manuals/R-intro.html Section 12 provides a good overview of graphics in R. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/Exporting-Graphs-tp1563718p1563753.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on 64-Bit…
Axel Urbiz wrote: Dear R users, I know this issue came up in the list several times. Im currently running R on 32-bit on Windows and due to memory limitation problems would like to move to a 64-bit environment. Im exploring my options and would appreciate your expertise: 1) Windows 64-bit: Prof. Brian Ripley recently posted the experimental built of R for win 64-bit. Ill appreciate any feedback on anyone who has been testing this. He also mentioned that for now, ...this as only being of interest for those who only use a few relatively simple packages. But if one uses packages beyond those relatively simple, how possible is today to have those installed? As far as I know, the problems with running 64-bit R on windows are due to the lack of a well-developed, 64 bit minGW compiler. Therefore I would imagine that the packages that may have trouble installing under the experimental 64 bit build are those that include either C or Fortran source code that needs to be compiled. You may also find that you need to compile packages yourself-- prebuilt 64 bit versions for windows may not be available on CRAN. Axel Urbiz wrote: 2) MacOS or Unix. Sorry for my ignorance on this but if I use any of these environments on 64-bit and installed R on any of those, this is all I need to have R working on 64-bit. How about installing specialized packages? Are the packages on the CRAN repositories ready tho use on these systems or do I have to do any additional work to get them going? Thanks in advance for your help! Axel. MacOS/Unix/Linux shouldn't have a problem with running 64 bit R and building 64 bit R packages-- this is because the GNU project provides a very mature set of 64 bit compilers that these systems can use. I personally use 64 bit R on Mac OS and have had no problems developing and installing packages for the 64 bit system. -Charlie -- View this message in context: http://n4.nabble.com/R-on-64-Bit-tp1563895p1564056.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] READ.TABLE for Mac
Mestat wrote: Hi listers, I just got a MAC, so I am trying to use the command READ.TABLE but I am getting a error that is probably caused by the wrong path that I am using... The command is the following... file-read.table(/Users/Márcio/UdeM/Travail Dirigé/Data/MU284 Population.txt,header=T,skip=24) And I am getting the following error... Erro em file(file, rt) : não é possível abrir a conexão Além disso: Warning message: In file(file, rt) : cannot open file '/User/Márcio/UdeM/Travail_Dirigé/Data/MU284_Population.txt': No such file or directory I checked already the messages but I didn't find what could be my mistake... Any suggestions??? Thanks in advance, Marcio Well there are a couple inconsistencies between the example command you give and the error message you are reporting: 1. The root path '/Users' is '/User' in the error message. 2. The file name 'MU284 Population.txt' is 'MU284_Population.txt' in the error message. The same thing has happened to the directory name Travail Dirigé I also use R on OS X and have never observed it alter or sanitize my file names-- I suspect you may have mistyped the path. If this is the case, use the TAB key to help you autofill the path rather then trying to type it all out correctly yourself. Just type the first few letters of a folder or file name and push TAB to have the rest autocompleted. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/READ-TABLE-for-Mac-tp1557879p1557965.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Keyboard
Steven Martin wrote: All, I installed R-2.10.1 with Readline=no. Now for some reason R does not recognize some key strokes like the directional arrows. I am not sure if Readline is the problem or not. Yes-- readline supplies functionality such as command history. Steven Martin wrote: I have tried .Cofigure with Readline = yes but it doesn't fix the problem nor do I really know if readline is the problem to start with. Has anybody else run into similar problems? Thanks, Steve Did you try: make distclean ./configure with readline make make install ? If that doesn't work, try: which R To see if the version of R being run is the one that you just compiled/installed. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/Keyboard-tp1558126p1558185.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract the data that match
Roslina Zakaria wrote: Hi r-users, I would like to extract the data that match. I'm interested in matchind the value in column 'intg' with value in column 'rand_no' Match how? Rows where intg equals rand_no at the same position? The rows of intg that are present somewhere in rand_no regardless of position? You need to be more specific. Roslina Zakaria wrote: Attached is my data: cbind(z=z,intg=dd,rand_no = rr) z intg rand_no [1,] 0.00 0.000 0.001 [2,] 0.01 0.000 0.002 snip Thank you for your help. This isn't a good way to provide tabular data-- people that want to help you can't just paste it into R and start working. They will have to reprocess the columns so that they can be read in by a function like read.table or read.csv. This will take some time and most won't bother-- they will just ignore your question. The best way to provide tabulated R data is to run your data frame through the dput() function and post that output. It won't look as nice, but any list user will be able to paste the code into their console and regenerate your table. -Charlie -- View this message in context: http://n4.nabble.com/extract-the-data-that-match-tp1558193p1558200.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting character vector hh:mm to chron or strptime 24 clock time vectors
Jim Lemon wrote: On 02/16/2010 09:47 PM, Alex Anderson wrote: ... This is the problem 6 96.88 2008/04/24 24:00 Error in `$-.data.frame`(`*tmp*`, time2, value = list(sec = c(0, 0, : replacement has 9 rows, data has 10 Hi Alex, You have a problem with an invalid time. The line should read: 6 96.88 2008/05/24 00:00 However, there is something else going on here that puzzles me. When I tried this with your sample data: tdata$datetime-strptime(paste(tdata$date,tdata$time,sep=-),%Y/%m/%d-%H:%M) Error in `$-.data.frame`(`*tmp*`, datetime, value = list(sec = c(0, : replacement has 9 rows, data has 6 Yet: datetime-strptime(paste(tdata$date,tdata$time,sep=-), %Y/%m/%d-%H:%M) datetime [1] 2008-04-24 02:00:00 2008-04-24 04:00:00 2008-04-24 06:00:00 [4] 2008-04-24 08:00:00 2008-04-24 10:00:00 2008-05-24 00:00:00 length(datetime) [1] 9 This is the first time I have encountered a discrepancy between length and the printed extent of an object, and I can't work out what is going on. Jim This is because you are working with a POSIXlt object which has 9 components and therefore always has a length of 9. That second part has always struck me as an odd design decision-- but one which we will have to live with. The important detail is that each component of POSIXlt, such as min, are the length you would expect them to be. I.E. if you have a POSIXlt object storing 15 timestamps: length( object ) = 9 - not what you expect length( object$min ) = 15 - what you expect If it gets too confusing, just coerce your POSIXlt objects to POSIXct objects which don't have issues with odd lengths. Hope this helps! -Charlie -- View this message in context: http://n4.nabble.com/converting-character-vector-hh-mm-to-chron-or-strptime-24-clock-time-vectors-tp1557308p1558213.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Printing 2 digits after decimal point [SOLVED]
T.Wunder wrote: Hi, I'm sorry, I've found the right answer: x - 0 formatC(x,digits=2, format=f) [1] 0.00 The above worked perfectly! Thanks Best wishes ;) Tom That old warhorse, sprintf(), can also be a trusty steed in situations like this. -Charlie -- View this message in context: http://n4.nabble.com/Printing-2-digits-after-decimal-point-tp1555981p1555987.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] executable R script under xp (to avoid migration toward Matlab or C++)
PtitBleu wrote: Hello, I discovered R two years ago and thanks to the R-community I managed to write some scripts to analyze my data stored in mysql databases. The only problem is that I am the only one using R in the lab. Colleagues mainly use Matlab (but not with mysql, only with text files) but regularly come to me to get data treated with R-scripts !!!. To allow the use of my scripts by other people, my boss asked me to make executables (.exe) with my scripts or to pay someone (I'm only end-user and not a computer scientist) to translate them into matlab langage (and then into .exe) or into C++ meaning abandoning R. And I don't want to. So is it possible to make executables from R scripts ? It seems it is not the case but I hope I missed a way to do it. Thanks in advance for your answers, Have a nice day, Ptit Bleu. Unfortunately there is no compiler that can turn a set of R scripts into an executable such as mcc does for MATLAB. My suggestion would be to turn pack your scripts up into a R package that could be easily installed on other computers that are running R. You might be able to convince your boss that this approach would be quicker and cheaper than paying for the work to be translated into another programming language. Good luck! -Charlie -- View this message in context: http://n4.nabble.com/executable-R-script-under-xp-to-avoid-migration-toward-Matlab-or-C-tp1555965p1555991.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.