Re: [R] translation
On 20/05/2012 00:01, Duncan Murdoch wrote: On 12-05-18 2:23 PM, David Winsemius wrote: On May 18, 2012, at 10:52 AM, Duncan Murdoch wrote: On 12-05-18 5:15 AM, gholi bahrami wrote: Dear Sir/Madam I am a BSc student studying statistics in Ferdowsi University of Mashhad,Iran. Translating R messages to Farsi is my thesis and I have already downloaded *poEdit* to translate those messages.However, the created .mo files for R.pot and RGui.pot are not useful at all. I would like to be informed if there is something wrong with right- to-left encoding or Farsi fonts or Farsi support. I am eagerly looking forward to hearing from you soon. I greatly appreciate the assistance you may provided me. Could you please repost to the R-devel list, with some more details? As far as I know Farsi would be our first right-to-left language, so I'd expect problems. Hebrew? We had an earlier question relating to plotting displays about right-to-left displaying Hebrew text improperly, but as far as I know the console displays were working properly. I don't think we have Hebrew translations of messages, but I might be wrong about that. I don't know that we do either, but as messages are just streams of bytes, their direction is not relevant at the translation stage. What is relevant is how the translated messages are displayed, and we do have experience with that in Hebrew. We don't have an OS mentioned here: as I wrote to you privately, experience suggests that Hebrew is displayed correctly in Linux, but mixed English-Hebrew lines are not on Windows. Duncan Murdoch A search for right-to-left with RSeek suggests you may get some support with package:ISOcodes. However, I do not see Farsi in the list of languages supported at: http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt But my knowledge in this area is very skimpy and the glyph-set needed may go by another name. I don't know if they are solvable with a reasonable effort, but that's the place to get started. Examples of details: Do other displays of Farsi strings in R work properly? e.g. cat(some Farsi string) or print(some Farsi string). Can readLine() read a text file with Farsi text and display it properly? What is the usual encoding used for Farsi text? Duncan Murdoch David Winsemius, MD West Hartford, CT -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anovas ss typeI vs typeIII
On May 20, 2012, at 00:58 , jacaranda tree wrote: Hi all, I have been struggling with ANOVAs on R. I am new to R, so I created a simple data frame, and I do some analyses on R just to learn R and then check them on SPSS to make sure that I am doing fine. Here is the problem that I've run into: when we use the aov function, it uses SS Type I as default (on SPSS it is Type III). Then I used the Anova function under cars package using the command: mod - lm(DV ~ IV1*IV2, data = mydata, contrasts=list(IV1=contr.sum, IV2=contr.sum)) Anova(mod, type=”3”) Above, both of my IVs are between-SS variables. But still, results from this model do not match the results from SPSS (I have to say they are not too different either). But I was wondering if I am doing something wrong. If what I am doing is okay, then my next question is can I use the same set of commands (for Anova function) if one of my IVs was within-SS and the other IV was between-SS? Please at least provide some output to show the difference (both systems). It's pretty hard to guess what might have gone wrong based on partial code for one system and no data... (There are good reasons that base R doesn't do Type III SS. In my experience, they are either identical to Type I or test a hypothesis much more bizarre than the user expects.) Thank you very much! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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.xls
On 5/19/2012 7:59 PM, Jim Holtman wrote: I have been using XLConnect to write multisheet Excel without any problems. Thanks very much. That looks like it will solve my problems. Best Wishes, Spencer p.s. findFn{sos} identified thatt for me, but for some unknown reason, I overlooked it. I'll study it more carefully now. Sent from my iPad On May 19, 2012, at 21:32, Spencer Gravesspencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found library(WriteXLS) testPerl() #Perl found. #The following Perl modules were not found on this system: #Text::CSV_XS #If you have more than one Perl installation, be sure the correct one was used here. #Otherwise, please install the missing modules. See the package INSTALL file for more information. # *** NOTE: I may be able to fix this for myself. # *** However, I want to use this in the 'sos' package, # *** and if it doesn't work easily for me, it may not work for others. library(RODBC) xlsFile- odbcConnectExcel(outFile, readOnly=FALSE) # NOTE: This works with R 2.15.0 32-bit. # However, with 64-bit, I get the following error message here: # Error in odbcConnectExcel(outFile, readOnly = FALSE) : # odbcConnectExcel is only usable with 32-bit Windows # When this works, the following 3 lines of code #suffice to create the outFile: sqlSave(xlsFile, df1, tablename='sheet1') sqlSave(xlsFile, df2, tablename='sheet2') odbcClose(xlsFile) sessionInfo() #R version 2.15.0 (2012-03-30) #Platform: x86_64-pc-mingw32/x64 (64-bit) #locale: #[1] LC_COLLATE=English_United States.1252 #[2] LC_CTYPE=English_United States.1252 #[3] LC_MONETARY=English_United States.1252 #[4] LC_NUMERIC=C #[5] LC_TIME=English_United States.1252 #attached base packages: #[1] stats graphics grDevices utils datasets methods base #other attached packages: #[1] RODBC_1.3-5 WriteXLS_2.1.0 dataframes2xls_0.4.5 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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.xls
On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd - list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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 csv to image file
Dear Simon, I understand better now and it is running. //Belay On Sat, May 19, 2012 at 1:22 PM, Simon Knapp sleepingw...@gmail.com wrote: I'm not sure what line you mean. The thing you pass to raster should be a matrix of the dimensions of your image data. You should have have xmin, xmax, ymin and ymax defined as something like: xmin - min(x) - cw/2 xmax - max(x) + cw/2 ymin - min(y) - cw/2 ymax - max(y) + cw/2 presuming that your x and y correspond to cell centres and where cw is your cell width (and if it is different in the two directions then you would 'cw.x' and 'cw.y'... if you know what I mean). Cheers, Simon On Sat, May 19, 2012 at 9:42 PM, Belay Gebregiorgis belay...@gmail.com wrote: Thanks Simon. I have other vectors in the CSV file so after naming my latitude and longitude x and y, I tried this. The first two lines run fine but I get error in the second line. r - raster(as.matrix(F1)) extent(r) - extent(xmin, xmax, ymin, ymax) F1-data.frame(x, y,z) Error in function (classes, fdef, mtable) : unable to find an inherited method for function extent, for signature stand Thankyou. Belay On Sat, May 19, 2012 at 12:22 PM, Simon Knapp sleepingw...@gmail.com wrote: provided you get the call to read.table (or perhaps read.csv) right and presuming that file contains only the image data, you should be able to say: r - raster(as.matrix(read.csv(file.csv))) extent(r) - extent(xmin, xmax, ymin, ymax) and not worry about the projection (if it is plain old decimal degrees) Regards, Simon On Sat, May 19, 2012 at 7:49 PM, Belay Gebregiorgis belay...@gmail.com wrote: Hello everyone, I want to get a 1km by lkm grid raster image using my csv data. If I call latitude=a, longitude=b and preciptation=c. a-(1,2,3,4,5) b-(6,7,8,9,10) c-(10,20, 30,40, 50) Then I found an example in r help which goes like pts = read.table(file.csv,..) library(sp) library(rgdal) proj4string(pts)=CRS(+init=epsg:4326) # set it to lat-long pts = spTransform(pts,CRS(insert your proj4 string here)) gridded(pts) = TRUE r = raster(pts) projection(r) = CRS(insert your proj4 string here) Because I am new to R, I have no idea what to put into the proj4 string and all that. Can anyone help me on this? If there is a different way of doing this, that is also fine. Kind Regards, Belay [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write.xls
On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd - list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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.xls
On May 19, 2012, at 8:32 PM, Spencer Graves wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found library(WriteXLS) testPerl() #Perl found. #The following Perl modules were not found on this system: #Text::CSV_XS #If you have more than one Perl installation, be sure the correct one was used here. #Otherwise, please install the missing modules. See the package INSTALL file for more information. # *** NOTE: I may be able to fix this for myself. # *** However, I want to use this in the 'sos' package, # *** and if it doesn't work easily for me, it may not work for others. library(RODBC) xlsFile - odbcConnectExcel(outFile, readOnly=FALSE) # NOTE: This works with R 2.15.0 32-bit. # However, with 64-bit, I get the following error message here: # Error in odbcConnectExcel(outFile, readOnly = FALSE) : # odbcConnectExcel is only usable with 32-bit Windows # When this works, the following 3 lines of code #suffice to create the outFile: sqlSave(xlsFile, df1, tablename='sheet1') sqlSave(xlsFile, df2, tablename='sheet2') odbcClose(xlsFile) sessionInfo() #R version 2.15.0 (2012-03-30) #Platform: x86_64-pc-mingw32/x64 (64-bit) #locale: #[1] LC_COLLATE=English_United States.1252 #[2] LC_CTYPE=English_United States.1252 #[3] LC_MONETARY=English_United States.1252 #[4] LC_NUMERIC=C #[5] LC_TIME=English_United States.1252 #attached base packages: #[1] stats graphics grDevices utils datasets methods base #other attached packages: #[1] RODBC_1.3-5 WriteXLS_2.1.0 dataframes2xls_0.4.5 Hi Spencer, The INSTALL file referenced for WriteXLS is also available on CRAN: http://cran.r-project.org/web/packages/WriteXLS/INSTALL The missing Perl modules cannot be provided with the CRAN package as they contain C code that must be compiled for the target platform. So one either needs to install the source Perl package from CPAN via the CLI and have a C compiler on their computer or use a Perl package manager infrastructure (eg. ActiveState Perl) that provides pre-compiled binaries for each OS and a nice GUI. The INSTALL file provides instructions for Windows, OSX and Linux as to how to address that issue. Note that the key issue that you face is that some of the mechanisms that you are trying will be OS specific (primarily Windows), such as RODBC, since ODBC drivers for Excel will be Windows only. If you want to provide your users of sos with cross-platform functionality, then you would need to look at solutions using Perl such as WriteXLS, Java such as XLConnect or Python such as dataframes2xls. Each will have installation issues, depending upon the OS and the useR's skill sets in ensuring the presence of the required foundation. Some users may have issues in certain environments in installing Perl, Python or Java due to IT/Security issues, so something to consider. The path of least resistance would be to simply write CSV files, which can then be opened with Excel or similar applications. It just depends upon what assumptions you want to make pertaining to maximizing your potential user base, while minimizing the installation challenges useRs may face with your package. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write.xls
On May 20, 2012, at 7:30 AM, Gabor Grothendieck wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd - list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) Thanks Gabor. Note that since WriteXLS version 2.0 (2010), WriteXLS can accept a named list and write out each list element data frame to an XLS file. An example is given in ?WriteXLS: iris.split - split(iris, iris$Species) WriteXLS(iris.split, irissplit.xls) You end up with a worksheet in the XLS file for each factor level in iris$Species. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] removeing only rows/columns with na value from square ( symmetrical ) matrix.
I have some square matrices with na values in corresponding rows and columns. M-matrix(1:2,10,10) M[6,1:2]-NA M[10,9]-NA M-as.matrix(as.dist(M)) print (M) 1 2 3 4 5 6 7 8 9 10 1 0 2 1 2 1 NA 1 2 1 2 2 2 0 1 2 1 NA 1 2 1 2 3 1 1 0 2 1 2 1 2 1 2 4 2 2 2 0 1 2 1 2 1 2 5 1 1 1 1 0 2 1 2 1 2 6 NA NA 2 2 2 0 1 2 1 2 7 1 1 1 1 1 1 0 2 1 2 8 2 2 2 2 2 2 2 0 1 2 9 1 1 1 1 1 1 1 1 0 NA 10 2 2 2 2 2 2 2 2 NA 0 How do I remove just the row/column pair( in this trivial example row 6 and 10 and column 6 and 10) containing the NA values? so that I end up with all rows/ columns that are not NA - e.g. 1 2 3 4 5 7 8 9 1 0 2 1 2 1 1 2 1 2 2 0 1 2 1 1 2 1 3 1 1 0 2 1 1 2 1 4 2 2 2 0 1 1 2 1 5 1 1 1 1 0 1 2 1 7 1 1 1 1 1 0 2 1 8 2 2 2 2 2 2 0 1 9 1 1 1 1 1 1 1 0 if i use na omit I lose rows 1,2,6, and 9 which is not what I want. thanks -- Nevil Amos Molecular Ecology Research Group Australian Centre for Biodiversity Monash University CLAYTON VIC 3800 Australia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] removeing only rows/columns with na value from square ( symmetrical ) matrix.
Your problem is not well-defined. In your example below, why not remove rows 1,2,6, and 10, all of which contain NA's? Is the matrix supposed to be symmetric? Do NA's always occur symmetrically? You either need to rethink what you want to do or clarify your statement of it. -- Bert On Sun, May 20, 2012 at 7:17 AM, Nevil Amos nevil.a...@monash.edu wrote: I have some square matrices with na values in corresponding rows and columns. M-matrix(1:2,10,10) M[6,1:2]-NA M[10,9]-NA M-as.matrix(as.dist(M)) print (M) 1 2 3 4 5 6 7 8 9 10 1 0 2 1 2 1 NA 1 2 1 2 2 2 0 1 2 1 NA 1 2 1 2 3 1 1 0 2 1 2 1 2 1 2 4 2 2 2 0 1 2 1 2 1 2 5 1 1 1 1 0 2 1 2 1 2 6 NA NA 2 2 2 0 1 2 1 2 7 1 1 1 1 1 1 0 2 1 2 8 2 2 2 2 2 2 2 0 1 2 9 1 1 1 1 1 1 1 1 0 NA 10 2 2 2 2 2 2 2 2 NA 0 How do I remove just the row/column pair( in this trivial example row 6 and 10 and column 6 and 10) containing the NA values? so that I end up with all rows/ columns that are not NA - e.g. 1 2 3 4 5 7 8 9 1 0 2 1 2 1 1 2 1 2 2 0 1 2 1 1 2 1 3 1 1 0 2 1 1 2 1 4 2 2 2 0 1 1 2 1 5 1 1 1 1 0 1 2 1 7 1 1 1 1 1 0 2 1 8 2 2 2 2 2 2 0 1 9 1 1 1 1 1 1 1 0 if i use na omit I lose rows 1,2,6, and 9 which is not what I want. thanks -- Nevil Amos Molecular Ecology Research Group Australian Centre for Biodiversity Monash University CLAYTON VIC 3800 Australia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] removeing only rows/columns with na value from square ( symmetrical ) matrix.
On Sun, May 20, 2012 at 10:17 AM, Nevil Amos nevil.a...@monash.edu wrote: I have some square matrices with na values in corresponding rows and columns. M-matrix(1:2,10,10) M[6,1:2]-NA M[10,9]-NA M-as.matrix(as.dist(M)) print (M) 1 2 3 4 5 6 7 8 9 10 1 0 2 1 2 1 NA 1 2 1 2 2 2 0 1 2 1 NA 1 2 1 2 3 1 1 0 2 1 2 1 2 1 2 4 2 2 2 0 1 2 1 2 1 2 5 1 1 1 1 0 2 1 2 1 2 6 NA NA 2 2 2 0 1 2 1 2 7 1 1 1 1 1 1 0 2 1 2 8 2 2 2 2 2 2 2 0 1 2 9 1 1 1 1 1 1 1 1 0 NA 10 2 2 2 2 2 2 2 2 NA 0 How do I remove just the row/column pair( in this trivial example row 6 and 10 and column 6 and 10) containing the NA values? so that I end up with all rows/ columns that are not NA - e.g. 1 2 3 4 5 7 8 9 1 0 2 1 2 1 1 2 1 2 2 0 1 2 1 1 2 1 3 1 1 0 2 1 1 2 1 4 2 2 2 0 1 1 2 1 5 1 1 1 1 0 1 2 1 7 1 1 1 1 1 0 2 1 8 2 2 2 2 2 2 0 1 9 1 1 1 1 1 1 1 0 Try this: ix - na.action(na.omit(replace(M, upper.tri(M), 0))) M[-ix, -ix] -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] removeing only rows/columns with na value from square ( symmetrical ) matrix.
On Sun, May 20, 2012 at 10:52 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, May 20, 2012 at 10:17 AM, Nevil Amos nevil.a...@monash.edu wrote: I have some square matrices with na values in corresponding rows and columns. M-matrix(1:2,10,10) M[6,1:2]-NA M[10,9]-NA M-as.matrix(as.dist(M)) print (M) 1 2 3 4 5 6 7 8 9 10 1 0 2 1 2 1 NA 1 2 1 2 2 2 0 1 2 1 NA 1 2 1 2 3 1 1 0 2 1 2 1 2 1 2 4 2 2 2 0 1 2 1 2 1 2 5 1 1 1 1 0 2 1 2 1 2 6 NA NA 2 2 2 0 1 2 1 2 7 1 1 1 1 1 1 0 2 1 2 8 2 2 2 2 2 2 2 0 1 2 9 1 1 1 1 1 1 1 1 0 NA 10 2 2 2 2 2 2 2 2 NA 0 How do I remove just the row/column pair( in this trivial example row 6 and 10 and column 6 and 10) containing the NA values? so that I end up with all rows/ columns that are not NA - e.g. 1 2 3 4 5 7 8 9 1 0 2 1 2 1 1 2 1 2 2 0 1 2 1 1 2 1 3 1 1 0 2 1 1 2 1 4 2 2 2 0 1 1 2 1 5 1 1 1 1 0 1 2 1 7 1 1 1 1 1 0 2 1 8 2 2 2 2 2 2 0 1 9 1 1 1 1 1 1 1 0 Try this: ix - na.action(na.omit(replace(M, upper.tri(M), 0))) M[-ix, -ix] and here is a minor variation which is slightly shorter: ix - complete.cases(replace(M, upper.tri(M), 0)) M[ix, ix] -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] removeing only rows/columns with na value from square ( symmetrical ) matrix.
On May 20, 2012, at 16:37 , Bert Gunter wrote: Your problem is not well-defined. In your example below, why not remove rows 1,2,6, and 10, all of which contain NA's? Is the matrix supposed to be symmetric? Do NA's always occur symmetrically? ...and even if they do, how do you decide whether to remove row/col 9 or row/col 10 in the example? (Or, for that matter, between (1 and 2) and 6. In that case you might chose to remove the smallest no. of row/cols but in 9 vs. 10, the situation is completely symmetric.) You either need to rethink what you want to do or clarify your statement of it. -- Bert On Sun, May 20, 2012 at 7:17 AM, Nevil Amos nevil.a...@monash.edu wrote: I have some square matrices with na values in corresponding rows and columns. M-matrix(1:2,10,10) M[6,1:2]-NA M[10,9]-NA M-as.matrix(as.dist(M)) print (M) 1 2 3 4 5 6 7 8 9 10 1 0 2 1 2 1 NA 1 2 1 2 2 2 0 1 2 1 NA 1 2 1 2 3 1 1 0 2 1 2 1 2 1 2 4 2 2 2 0 1 2 1 2 1 2 5 1 1 1 1 0 2 1 2 1 2 6 NA NA 2 2 2 0 1 2 1 2 7 1 1 1 1 1 1 0 2 1 2 8 2 2 2 2 2 2 2 0 1 2 9 1 1 1 1 1 1 1 1 0 NA 10 2 2 2 2 2 2 2 2 NA 0 How do I remove just the row/column pair( in this trivial example row 6 and 10 and column 6 and 10) containing the NA values? so that I end up with all rows/ columns that are not NA - e.g. 1 2 3 4 5 7 8 9 1 0 2 1 2 1 1 2 1 2 2 0 1 2 1 1 2 1 3 1 1 0 2 1 1 2 1 4 2 2 2 0 1 1 2 1 5 1 1 1 1 0 1 2 1 7 1 1 1 1 1 0 2 1 8 2 2 2 2 2 2 0 1 9 1 1 1 1 1 1 1 0 if i use na omit I lose rows 1,2,6, and 9 which is not what I want. thanks -- Nevil Amos Molecular Ecology Research Group Australian Centre for Biodiversity Monash University CLAYTON VIC 3800 Australia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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.xls
Hi, Gabor: Thanks. I'll try that. Spencer On 5/20/2012 5:52 AM, Gabor Grothendieck wrote: On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd- list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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] dot - comma problem
Dear all I am trying to use the ODB package to connect to an libreoffice-odb database. The libreoffice package is german, thus, decimal separator is a comma. However, I can open the database and upload a it without error, library(ODB) db - odb.open(Test.odb) but a soon as the odb.open command is executed, the decimal separator in R is changed to comma. Before loading the database: a - 10.1 a [1] 10.1 After loading the database db - odb.open(Buchhaltung.odb) a [1] 10,1 but assigning a numeric value to a variable still requires a dot: a - 5,1 Error: Unexpected ',' in a - 5, Futhermore, printed variables still use the comma as decimal separator: write.csv(a) ,x 1,10,1 Since this leads to serious parsing errors when odb sets up sql-queries (eg 5,1 becomes 51), I need to get rid of that behaviour such that numeric values are correctly displayed with a dot as a decimal separator. Does anyone has an idea? Thanks Karl Ps: The following does not work: a - as.character(a) a [1] 10,1 a - sub(,,.,a) a [1] 10.1 a - as.numeric(a) a [1] 10,1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (no subject)
Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] KEGGSOAP installation error
Hi Martin, I've already checked XML library in R but it seems there's no issues regarding it. I've also tried to update all installed R packages and to install several libraries related to libxml2 library in ubuntu, but the problem is still there. I will try to post the same problem in the bioconductor mailing list. Thanks, Matteo -- View this message in context: http://r.789695.n4.nabble.com/KEGGSOAP-installation-error-tp4630053p4630660.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] R Memory Issues
-- Forwarded message -- From: Emiliano Zapata ezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about sign test
Hi, I want to compute p value of sign test for sample size=15 from normal distr., sd=0.5, mean=1, alternative should be two sided. Is this code correct in this situation? binom.test(sum(rnorm(15,1,0.5)0),15,p=0.5,alternative=two)$p.value Or should I use another code (function) e.g. rbinom? Thank you very much. kind regards, T. Bal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Memory Issues
Try memory.limit(92000) sent from my HTC On May 21, 2012 1:27 AM, Emiliano Zapata ezapata...@gmail.com wrote: -- Forwarded message -- From: Emiliano Zapata ezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Memory Issues
At the point in time that you get the error message, how big are the objects that you have in memory? What does 'memory.size()' show as being used? What does 'memory.limit()' show? Have you tried using 'gc()' periodically to do some garbage collection? It might be that you memory is fragmented. You need to supply some additional information. On Sun, May 20, 2012 at 12:09 PM, Emiliano Zapata ezapata...@gmail.com wrote: -- Forwarded message -- From: Emiliano Zapata ezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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.xls
On 5/20/2012 6:47 AM, Marc Schwartz wrote: On May 19, 2012, at 8:32 PM, Spencer Graves wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found library(WriteXLS) testPerl() #Perl found. #The following Perl modules were not found on this system: #Text::CSV_XS #If you have more than one Perl installation, be sure the correct one was used here. #Otherwise, please install the missing modules. See the package INSTALL file for more information. # *** NOTE: I may be able to fix this for myself. # *** However, I want to use this in the 'sos' package, # *** and if it doesn't work easily for me, it may not work for others. library(RODBC) xlsFile- odbcConnectExcel(outFile, readOnly=FALSE) # NOTE: This works with R 2.15.0 32-bit. # However, with 64-bit, I get the following error message here: # Error in odbcConnectExcel(outFile, readOnly = FALSE) : # odbcConnectExcel is only usable with 32-bit Windows # When this works, the following 3 lines of code #suffice to create the outFile: sqlSave(xlsFile, df1, tablename='sheet1') sqlSave(xlsFile, df2, tablename='sheet2') odbcClose(xlsFile) sessionInfo() #R version 2.15.0 (2012-03-30) #Platform: x86_64-pc-mingw32/x64 (64-bit) #locale: #[1] LC_COLLATE=English_United States.1252 #[2] LC_CTYPE=English_United States.1252 #[3] LC_MONETARY=English_United States.1252 #[4] LC_NUMERIC=C #[5] LC_TIME=English_United States.1252 #attached base packages: #[1] stats graphics grDevices utils datasets methods base #other attached packages: #[1] RODBC_1.3-5 WriteXLS_2.1.0 dataframes2xls_0.4.5 Hi Spencer, The INSTALL file referenced for WriteXLS is also available on CRAN: http://cran.r-project.org/web/packages/WriteXLS/INSTALL The missing Perl modules cannot be provided with the CRAN package as they contain C code that must be compiled for the target platform. So one either needs to install the source Perl package from CPAN via the CLI and have a C compiler on their computer or use a Perl package manager infrastructure (eg. ActiveState Perl) that provides pre-compiled binaries for each OS and a nice GUI. The INSTALL file provides instructions for Windows, OSX and Linux as to how to address that issue. Note that the key issue that you face is that some of the mechanisms that you are trying will be OS specific (primarily Windows), such as RODBC, since ODBC drivers for Excel will be Windows only. If you want to provide your users of sos with cross-platform functionality, then you would need to look at solutions using Perl such as WriteXLS, Java such as XLConnect or Python such as dataframes2xls. Each will have installation issues, depending upon the OS and the useR's skill sets in ensuring the presence of the required foundation. Some users may have issues in certain environments in installing Perl, Python or Java due to IT/Security issues, so something to consider. The path of least resistance would be to simply write CSV files, which can then be opened with Excel or similar applications. It just depends upon what assumptions you want to make pertaining to maximizing your potential user base, while minimizing the installation challenges useRs may face with your package. Thanks, Marc. The current code first tries WriteXLS If that fails, it then tries RODBC. If that fails, it writes csv files. If I can get dataframes2xls and / or XLConnect to work, I plan to start with one of those. These other packages are suggests, so sos will load without them. Best Wishes, Spencer Regards, Marc Schwartz -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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 Memory Issues
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 Have you read the documentation? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Emiliano Zapata ezapata...@gmail.com wrote: -- Forwarded message -- From: Emiliano Zapata ezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
On 20.05.2012 18:09, Emiliano Zapata wrote: Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I suspect you are running a 32-bit version of R. From ?memory.size: For a 64-bit versions of R under 64-bit Windows the limit is currently 8Tb. Best, Uwe Ligges I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Memory Issues
You are on a 64-bit machine, but are you using 64-bit R? Are you using memory intensive constructs like those discussed in Circle 2 of 'The R Inferno'? http://www.burns-stat.com/pages/Tutor/R_inferno.pdf Pat On 20/05/2012 17:09, Emiliano Zapata wrote: -- Forwarded message -- From: Emiliano Zapataezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dot - comma problem
Please report bugs in the ODB package (wherever that is from: you did not tell us) to its maintainer. ?Sys.setlocale will explain how to undo the damage. On 20/05/2012 14:52, may.k...@yahoo.de wrote: Dear all I am trying to use the ODB package to connect to an libreoffice-odb database. The libreoffice package is german, thus, decimal separator is a comma. However, I can open the database and upload a it without error, library(ODB) db- odb.open(Test.odb) but a soon as the odb.open command is executed, the decimal separator in R is changed to comma. Before loading the database: a- 10.1 a [1] 10.1 After loading the database db- odb.open(Buchhaltung.odb) a [1] 10,1 but assigning a numeric value to a variable still requires a dot: a- 5,1 Error: Unexpected ',' in a- 5, Futhermore, printed variables still use the comma as decimal separator: write.csv(a) ,x 1,10,1 Since this leads to serious parsing errors when odb sets up sql-queries (eg 5,1 becomes 51), I need to get rid of that behaviour such that numeric values are correctly displayed with a dot as a decimal separator. Does anyone has an idea? Thanks Karl Ps: The following does not work: a- as.character(a) a [1] 10,1 a- sub(,,.,a) a [1] 10.1 a- as.numeric(a) a [1] 10,1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Memory Issues
On 20/05/2012 18:42, jim holtman wrote: At the point in time that you get the error message, how big are the objects that you have in memory? What does 'memory.size()' show as being used? What does 'memory.limit()' show? Have you tried using 'gc()' periodically to do some garbage collection? It might be that you memory is fragmented. You need to supply some additional information. Either this is a 32-bit version of R in which case the wrong version is being used, or your advice is wrong: there are no credible fragmentation issues (and no need to use gc()) on a 64-bit build of R. But, we have a posting guide, we require 'at a minimum information', and the OP failed to give it to us so we are all guessing, completely unnecessarily. On Sun, May 20, 2012 at 12:09 PM, Emiliano Zapataezapata...@gmail.com wrote: -- Forwarded message -- From: Emiliano Zapataezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Axis mayhem in plot3d
Wise people, I have a plot of age, vertebral level and depth of the spinal cord from the skin in children that I can interact with in sculpt3d: sculpt3d(Depth[,4],Depth$LevelNo,Depth$Depth,type=s,radius=.3, alpha=.5) decorate3d(axes=FALSE, box=FALSE,xlab=Age, ylab=Level,zlab=Depth) To make it more intelligible I would like to replace the x, y and z labels with something more meaningful namely Age, Level and Depth. My problem is that I cannot find a way of getting rid of the x, y and z This means that, for example, Age overwrites the x making it look messy. I have tried things like xaxt=n to no avail Any thoughts? Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Histograms with bin proportions on the y-axis
I have what is probably a simple problem. I have a data file from an MCMC Bayes estimation problem that is a vector of 500,000 numeric values (just one variable) ranging from 100,000 to 700,000. I need to display the histogram of this data in a high quality graphic for a figure in a journal publication. I want 100 bins so as to display a reasonable complete and smooth histogram, and I need the Y-axis to display the bin proportions. I'm new to all of the graphics capabilities of R. Can anyone provide me with the command I need to issue to the call to hist to get the output that I desire? I assume that once I have the desired histogram I will be able to save it in a format like .eps that will permit it to be reproduced in high resolution. But any suggestions for this task would also be appreciated. Regards, Nick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Memory Issues
Already then, thank you everyone. This information was extremly useful, and I'll do a better job on the web next time. On Sun, May 20, 2012 at 2:10 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On 20/05/2012 18:42, jim holtman wrote: At the point in time that you get the error message, how big are the objects that you have in memory? What does 'memory.size()' show as being used? What does 'memory.limit()' show? Have you tried using 'gc()' periodically to do some garbage collection? It might be that you memory is fragmented. You need to supply some additional information. Either this is a 32-bit version of R in which case the wrong version is being used, or your advice is wrong: there are no credible fragmentation issues (and no need to use gc()) on a 64-bit build of R. But, we have a posting guide, we require 'at a minimum information', and the OP failed to give it to us so we are all guessing, completely unnecessarily. On Sun, May 20, 2012 at 12:09 PM, Emiliano Zapataezapata...@gmail.com wrote: -- Forwarded message -- From: Emiliano Zapataezapata...@gmail.com Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to run, and got the massage: cannot allocate memory block of size 2.1 Gb I read on the web that if you increase the memory you have to reinstall R; would that be enough. Could I just increase the memory manually. Take you for any comments, or links on the web. EZ [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~**ripley/http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dot - comma problem
Le dimanche 20 mai 2012 à 23:52 +1000, may.k...@yahoo.de a écrit : Dear all I am trying to use the ODB package to connect to an libreoffice-odb database. The libreoffice package is german, thus, decimal separator is a comma. However, I can open the database and upload a it without error, library(ODB) db - odb.open(Test.odb) but a soon as the odb.open command is executed, the decimal separator in R is changed to comma. Before loading the database: a - 10.1 a [1] 10.1 After loading the database db - odb.open(Buchhaltung.odb) a [1] 10,1 but assigning a numeric value to a variable still requires a dot: a - 5,1 Error: Unexpected ',' in a - 5, Futhermore, printed variables still use the comma as decimal separator: write.csv(a) ,x 1,10,1 Since this leads to serious parsing errors when odb sets up sql-queries (eg 5,1 becomes 51), I need to get rid of that behaviour such that numeric values are correctly displayed with a dot as a decimal separator. Does anyone has an idea? I recently experienced this with a totally unrelated package. The culprit turned out to be RWeka (which depends on rJava, like ODB) when used with Java 7 (on Fedora Linux 17). Can you simply try loading RJDBC and print a decimal number? Please also check your Java version, and give us system information as requested by Brian Ripley. Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histograms with bin proportions on the y-axis
To open a graphics device, you usually use a function like png() or eps() then do your plotting then dev.off() to close it when you're done. Sounds like you need something like hist(x, breaks = 100, freq = TRUE) Hope that helps, Michael On Sun, May 20, 2012 at 3:07 PM, Nick Gayeski n...@wildfishconservancy.org wrote: I have what is probably a simple problem. I have a data file from an MCMC Bayes estimation problem that is a vector of 500,000 numeric values (just one variable) ranging from 100,000 to 700,000. I need to display the histogram of this data in a high quality graphic for a figure in a journal publication. I want 100 bins so as to display a reasonable complete and smooth histogram, and I need the Y-axis to display the bin proportions. I'm new to all of the graphics capabilities of R. Can anyone provide me with the command I need to issue to the call to hist to get the output that I desire? I assume that once I have the desired histogram I will be able to save it in a format like .eps that will permit it to be reproduced in high resolution. But any suggestions for this task would also be appreciated. Regards, Nick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histograms with bin proportions on the y-axis
See in-line below. On 20-May-2012 19:07:55 Nick Gayeski wrote: I have what is probably a simple problem. I have a data file from an MCMC Bayes estimation problem that is a vector of 500,000 numeric values (just one variable) ranging from 100,000 to 700,000. I need to display the histogram of this data in a high quality graphic for a figure in a journal publication. I want 100 bins so as to display a reasonable complete and smooth histogram, and I need the Y-axis to display the bin proportions. I'm new to all of the graphics capabilities of R. Can anyone provide me with the command I need to issue to the call to hist to get the output that I desire? The following illustrates how to customise the behaviour of hist() to achieve a desired effect (such as the one you want): N - 50 ## sample size Y - rnorm(N,mean=40,sd=10) ## the sample ## Now make a non-plotted object which contains the histogram info: H0 - hist(Y,breaks=100,plot=FALSE) ## the bin values are counts C - H0$counts ## extract the counts ## Now convert these to proportions (percent or fraction as you wish): P - 100*C/N ## or P - C/N for fractional proportions ## Now copy the histigram object H0 to H1 and modify H1: H1 - H0 ; H1$counts - P ## replaces the counts by the proportions ## Now plot it: plot(H1,ylab=% proportions in bins) I assume that once I have the desired histogram I will be able to save it in a format like .eps that will permit it to be reproduced in high resolution. But any suggestions for this task would also be appreciated. Regards, Nick As Michael Weylandt has suggested, you can encapsulate the final plot() command between the opening of a graphics device and the closure of the device. So if you want an EPS file you can use the postscript device: postscript(myhistoplot.eps,horizontal=FALSE) plot(H1,ylab=% proportions in bins) dev.off() and the result will be an EPS file myhistoplot.eps. You will probably want to at least vary the aspect ratio (height:width) and maybe some other things, so give the command ?postscript to find out what the various (and many .. ) options are. Hoping this helps to get you started! Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 20-May-2012 Time: 22:27:13 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Q - scatterplot, plot function trellis linear regressions???
HI R-listers, Thanks for the replies I am convinced of Q 1 and 2. Q 3 - I am still unsuccessful. Aeventexhumed has three events A, B and C. I am unable to make 3 windows of scatterplot graphs side by side showing the difference in regression of each event. With and without lattice I have tried, but the only graph that is produced is one graph with all three events (A, B, and C) plotted in one window (R script below). I want to show the 3 Aeventexhumed events separately in 3 plots next to each other in one window. Previously, I have been able to make this is trellis.par.set with boxplots. library(car) library(lattice) trellis.par.set(col.whitebg()) par(mfrow=c(1,3)) scatterplot(HSuccess~Veg|Aeventexhumed, + data = data.to.analyze, + xlab =Distance to vegetation border, + ylab = Hatching success (%)) Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/Q-scatterplot-plot-function-trellis-linear-regressions-tp4630562p4630686.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] CRAN (and crantastic) updates this week
CRAN (and crantastic) updates this week New packages * bisectr (0.0.2) Maintainer: Winston Chang Author(s): Winston Chang wins...@stdout.org License: GPL-2 http://crantastic.org/packages/bisectr Tools to find bad commits with git bisect * CUMP (1.0) Maintainer: Xuan Liu Author(s): Xuan Liu liux...@bu.edu and Qiong Yang qy...@bu.edu License: GPL (= 2) http://crantastic.org/packages/CUMP Combining Univariate Association Test Results of Multiple Phenotypes for Detecting Pleiotropy * cumplyr (0.1-1) Maintainer: John Myles White Author(s): John Myles White License: MIT http://crantastic.org/packages/cumplyr Extends ddply to allow calculation of cumulative quantities. * dma (1.1) Maintainer: Tyler H. McCormick Author(s): Tyler H. McCormick, Adrian Raftery, David Madigan License: GPL-2 http://crantastic.org/packages/dma Dynamic model averaging for binary and continuous outcomes. * fanc (0.18) Maintainer: Kei Hirose Author(s): Kei Hirose, Michio Yamamoto License: GPL (= 2) http://crantastic.org/packages/fanc This package computes the penalized maximum likelihood estimates of factor loadings and unique variances for various tuning parameters. The pathwise coordinate descent along with EM algorithm is used. * fishmove (0.0-1) Maintainer: Johannes Radinger Author(s): Johannes Radinger License: GPL (= 2) http://crantastic.org/packages/fishmove Functions to predict fish movement parameters based on multiple regression and plotting leptokurtic fish dispersal kernels * googlePublicData (0.12.05) Maintainer: George Vega Yon Author(s): George Vega Yon License: GPL (= 3) http://crantastic.org/packages/googlePublicData package provides a collection of functions to set up Google Public Data Explorer data visualization tool with your own data, building automaticaly the corresponding DSPL (XML) metadata file jointly with the CSV files. All zipped up and ready to be published at Public Data Explorer. * gsmaRt (1.0) Maintainer: Stephan Artmann Author(s): Stephan Artmann, Mathias Fuchs License: GPL http://crantastic.org/packages/gsmaRt combined miRNA- and mRNA-testing * HIest (1.0) Maintainer: Unknown Author(s): Ben Fitzpatrick License: GPL (= 3) http://crantastic.org/packages/HIest Uses likelihood to estimate ancestry and heterozygosity. Evaluates simple hybrid classifications (parentals, F1, F2, backcrosses). Estimates genomic clines. * igraphdata (0.1) Maintainer: Gabor Csardi Author(s): Gabor Csardi csardi.ga...@gmail.com License: GPL (= 2) + file LICENSE http://crantastic.org/packages/igraphdata A small collection of various network data sets, to use with the igraph package. They also work with the igraph0 package. * irtrees (0.1.0) Maintainer: Ivailo Partchev Author(s): Ivailo Partchev and Paul De Boeck License: GPL (= 2) http://crantastic.org/packages/irtrees Helper functions and example data sets accompanying De Boeck, P. and Partchev, I. (2012) IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software - Code Snippets, 48(1), 1-28. * lava (1.0-5) Maintainer: Klaus. K. Holst Author(s): Klaus K. Holst License: GPL-3 http://crantastic.org/packages/lava Estimation and simulation of latent variable models * lava.tobit (0.4-6) Maintainer: Klaus. K. Holst Author(s): Klaus K. Holst License: GPL-3 http://crantastic.org/packages/lava-tobit lava plugin allowing combinations of left and right censored and binary outcomes * LeafAngle (1.1) Maintainer: Unknown Author(s): Remko Duursma License: GPL http://crantastic.org/packages/LeafAngle A leaf angle distribution is a special distribution that is defined between 0 and 90 degrees, and a number of distributions are used to characterize the leaf angle distribution in real plant canopies. This package includes methods to fit distributions to data, visualize the fit, and compare fits of nine different distributions. * makeProject (1.0) Maintainer: Noah Silverman Author(s): Noah Silverman License: GPL-3 http://crantastic.org/packages/makeProject This package creates an empty framework of files and directories for the quot;Load, Clean, Func, Doquot; structure described by Josh Reich. * mcmcse (0.1) Maintainer: James M. Flegal Author(s): James M. Flegal jfle...@ucr.edu License: GPL http://crantastic.org/packages/mcmcse Tools for calculating Monte Carlo standard errors (MCSE) in Markov chain Monte Carlo (MCMC) settings. This package considers standard errors for expectation and quantile estimators. * MetaDE (1.0) Maintainer: Jia Li Author(s): Jia Li and Xingbin Wang License: GPL-2 http://crantastic.org/packages/MetaDE A collection of functions for conducting genomic meta-analysis in R. * mets (0.1-8) Maintainer: Klaus. K. Holst Author(s): Klaus K. Holst and Thomas Scheike License: GPL (= 2)
Re: [R] Names of Greek letters stored as character strings; plotmath.
-Original Message- From: William Dunlap Sent: Saturday, May 19, 2012 11:07 AM To: Rolf Turner Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings;plotmath. parse(text=paste(...)) works in simple cases but not in others. The fortune about it is there because it is tempting to use but if you bury it in a general purpose function it will cause problems when people start using nonstandard names for variables. bquote(), substitute(), call(), and relatives work in all cases. E.g., par(mfrow=c(2,1)) power - gamma ; x - Waist ; y - Weight # valid R variable names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # same as previous power - gamma ; x - Waist Size (cm) ; y - Weight (kg) # invalid R names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # whoops Error in parse(text = paste0(x, ^, power, /, y)) : text:1:7: unexpected symbol 1: Waist Size ^ Now you might say that serves me right for using weird variable names, but some of us use R as a back end to a GUI system (one not designed around R) and don't want to inflict on users R's rules for names when we do not have to. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Saturday, May 19, 2012 7:24 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings; plotmath. ... and here is another incantation that may be informative. xnm- as.name(gamma') ## This does the parsing plot(0, xlab =bquote(.(xnm)) The initial puzzle is that if you just set xnm - gamma bquote will insert the string gamma rather than the symbol. After all, that's what plotmath sees for xnm. So the key is telling plotmath that it's a symbol, not a string. This can either be done before, as above, or inline, as you and Gabor showed. Unsurprisingly. this also does it, since as.name() is doing the parsing: xnm - gamma plot(0,xlab=bquote(.(as.name(xnm AND we are adhering to Thomas's dictum: bquote is a wrapper for substitute(), which is what he recommends as the preferable alternative to eval(parse(...)) . But, heck -- all such software principles are just guidelines. Whatever works (robustly). HTH. Cheers, Bert On Sat, May 19, 2012 at 3:17 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 1:18 AM, Rolf Turner rolf.tur...@xtra.co.nz wrote: I had such good luck with my previous question to r-help, (a few minutes ago) that I thought I would try again with the following query: Suppose I have xNm - gamma I would like to be able to do plot(1:10,xlab = something involving xNm) and get the x axis label to be the Greek letter gamma (rather than the literal text string gamma). Is this possible? I've messed around with substitute() and bquote() and got nowhere. Then, just before clicking on Send, I had one more thimk, and blow me down, I got something that worked: plot(1:10,xlab=eval(expression(parse(text=xNm That can be shortened to: plot(0, xlab = parse(text = xNm)) -- snip -- This discussion has been exceedingly helpful, sort of. Every time I try to do a task involving this I read the documentation for bquote(), expression(), plotmath(), etc., over and over, and I still fail to get the big picture of how R parses things under the hood. Typically, I only succeed each time by frustrating trial and error. Can I ask how you guys got a handle on the bigger (besides your usual brilliance G)? Is there more comprehensive documentation in the developer literature or is there a user wiki that you would recommend for those who never quite get the big picture? If not, this would be a worthy topic for an R Journal article if someone has knowledge and the time to do it. Wish I were knowledgeable enough to do it myself. Thanks, Rob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A. T. Still University of Health Sciences 800 W. Jefferson St. Kirksville, MO 63501 660-626-2322 FAX 660-626-2965 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Axis mayhem in plot3d
On 12-05-20 4:01 PM, Andrew Roberts wrote: Wise people, I have a plot of age, vertebral level and depth of the spinal cord from the skin in children that I can interact with in sculpt3d: Your subject says plot3d, but your example uses sculpt3d, and you don't say what packages you're using. plot3d and decorate3d are in rgl, but I've never heard of sculpt3d before. From your description below, the problem lies in sculpt3d: it is drawing the axis labels even when you don't want it to. So I'd suggest you contact the author or maintainer of whatever package contains that function. And please don't blame my functions for mayhem caused by other people. Duncan Murdoch sculpt3d(Depth[,4],Depth$LevelNo,Depth$Depth,type=s,radius=.3, alpha=.5) decorate3d(axes=FALSE, box=FALSE,xlab=Age, ylab=Level,zlab=Depth) To make it more intelligible I would like to replace the x, y and z labels with something more meaningful namely Age, Level and Depth. My problem is that I cannot find a way of getting rid of the x, y and z This means that, for example, Age overwrites the x making it look messy. I have tried things like xaxt=n to no avail Any thoughts? Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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.xls
On 5/20/2012 5:52 AM, Gabor Grothendieck wrote: On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd- list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) Hi, Gabor: Thanks. I think we're gaining on it, but I'm still not quite there. Consider the following extension of my previous toy example: library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(quote(c(df1, df2)), outFile)) # works df2x - function(x, file) do.call(write.xls, list(x, file)) df2x(quote(c(df1, df2)), outFile) # works df2 - function(x1, x2, file){ x23 - quote(c(x1, x2)) do.call(write.xls, list(x23, file)) } df2(df1, df2, outFile) # Error in get(s[i]) : object 'x1' not found This is closer to what I need. The answer may lie in getting the right envir argument for do.call. However, I haven't yet found something that works there. Thanks, Spencer and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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] Names of Greek letters stored as character strings; plotmath.
On 21/05/12 10:53, Robert Baer wrote: SNIP This discussion has been exceedingly helpful, sort of. Every time I try to do a task involving this I read the documentation for bquote(), expression(), plotmath(), etc., over and over, and I still fail to get the big picture of how R parses things under the hood. Typically, I only succeed each time by frustrating trial and error. Can I ask how you guys got a handle on the bigger (besides your usual brilliance G)? Is there more comprehensive documentation in the developer literature or is there a user wiki that you would recommend for those who never quite get the big picture? If not, this would be a worthy topic for an R Journal article if someone has knowledge and the time to do it. Wish I were knowledgeable enough to do it myself. Amen. My experience/reaction exactly. I think though that the concepts involved are really truly subtle and it may be difficult for the brilliant guys to explain them in such a way that those of us who are less brilliant can understand them. cheers, Rolf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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.xls
Here is what it take to write out two sheets with XLConnect # function to write out a sheet to an EXCEL file that I use f.writeXLSheet - function (data, sheet, fileToWrite, rownames = NULL) { require(XLConnect) writeWorksheetToFile(fileToWrite, data = data, sheet = sheet, rownames = rownames, styleAction = XLC$STYLE_ACTION.NONE) } df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' unlink(outFile) # make sure there is no file to start with f.writeXLSheet(df1, 'df1', outFile) f.writeXLSheet(df2, 'df2', outFile) I have attached the resulting Excel file (see how far it makes it). On Sun, May 20, 2012 at 7:15 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/20/2012 5:52 AM, Gabor Grothendieck wrote: On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd- list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) Hi, Gabor: Thanks. I think we're gaining on it, but I'm still not quite there. Consider the following extension of my previous toy example: library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(quote(c(df1, df2)), outFile)) # works df2x - function(x, file) do.call(write.xls, list(x, file)) df2x(quote(c(df1, df2)), outFile) # works df2 - function(x1, x2, file){ x23 - quote(c(x1, x2)) do.call(write.xls, list(x23, file)) } df2(df1, df2, outFile) # Error in get(s[i]) : object 'x1' not found This is closer to what I need. The answer may lie in getting the right envir argument for do.call. However, I haven't yet found something that works there. Thanks, Spencer and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Names of Greek letters stored as character strings; plotmath.
On 12-05-20 6:53 PM, Robert Baer wrote: -Original Message- From: William Dunlap Sent: Saturday, May 19, 2012 11:07 AM To: Rolf Turner Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings;plotmath. parse(text=paste(...)) works in simple cases but not in others. The fortune about it is there because it is tempting to use but if you bury it in a general purpose function it will cause problems when people start using nonstandard names for variables. bquote(), substitute(), call(), and relatives work in all cases. E.g., par(mfrow=c(2,1)) power- gamma ; x- Waist ; y- Weight # valid R variable names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # same as previous power- gamma ; x- Waist Size (cm) ; y- Weight (kg) # invalid R names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # whoops Error in parse(text = paste0(x, ^, power, /, y)) : text:1:7: unexpected symbol 1: Waist Size ^ Now you might say that serves me right for using weird variable names, but some of us use R as a back end to a GUI system (one not designed around R) and don't want to inflict on users R's rules for names when we do not have to. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Saturday, May 19, 2012 7:24 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings; plotmath. ... and here is another incantation that may be informative. xnm- as.name(gamma') ## This does the parsing plot(0, xlab =bquote(.(xnm)) The initial puzzle is that if you just set xnm- gamma bquote will insert the string gamma rather than the symbol. After all, that's what plotmath sees for xnm. So the key is telling plotmath that it's a symbol, not a string. This can either be done before, as above, or inline, as you and Gabor showed. Unsurprisingly. this also does it, since as.name() is doing the parsing: xnm- gamma plot(0,xlab=bquote(.(as.name(xnm AND we are adhering to Thomas's dictum: bquote is a wrapper for substitute(), which is what he recommends as the preferable alternative to eval(parse(...)) . But, heck -- all such software principles are just guidelines. Whatever works (robustly). HTH. Cheers, Bert On Sat, May 19, 2012 at 3:17 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 1:18 AM, Rolf Turnerrolf.tur...@xtra.co.nz wrote: I had such good luck with my previous question to r-help, (a few minutes ago) that I thought I would try again with the following query: Suppose I have xNm- gamma I would like to be able to do plot(1:10,xlab =something involving xNm) and get the x axis label to be the Greek letter gamma (rather than the literal text string gamma). Is this possible? I've messed around with substitute() and bquote() and got nowhere. Then, just before clicking on Send, I had one more thimk, and blow me down, I got something that worked: plot(1:10,xlab=eval(expression(parse(text=xNm That can be shortened to: plot(0, xlab = parse(text = xNm)) -- snip -- This discussion has been exceedingly helpful, sort of. Every time I try to do a task involving this I read the documentation for bquote(), expression(), plotmath(), etc., over and over, and I still fail to get the big picture of how R parses things under the hood. Typically, I only succeed each time by frustrating trial and error. Can I ask how you guys got a handle on the bigger (besides your usual brillianceG)? Is there more comprehensive documentation in the developer literature or is there a user wiki that you would recommend for those who never quite get the big picture? If not, this would be a worthy topic for an R Journal article if someone has knowledge and the time to do it. Wish I were knowledgeable enough to do it myself. I think you have to try writing C code to work with R objects to really understand what's going on. Reading those sections of the Writing R Extensions manual will probably help, but actually writing C code to do it may be necessary. It's not really a very complicated system, it's just that things that are obviously different in C (e.g. the R symbol name gamma versus the string gamma) look confusingly similar in R. You might be able to figure this out by studying the result of str(x) (or the low level .Internal(inspect(x))) for lots of different x objects, but I don't think it's going to make sense unless you know what's going on behind the curtain. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] write.xls
Hi, Jim: On 5/20/2012 4:54 PM, jim holtman wrote: Here is what it take to write out two sheets with XLConnect # function to write out a sheet to an EXCEL file that I use f.writeXLSheet- function (data, sheet, fileToWrite, rownames = NULL) { require(XLConnect) writeWorksheetToFile(fileToWrite, data = data, sheet = sheet, rownames = rownames, styleAction = XLC$STYLE_ACTION.NONE) } Thanks. Unfortunately, I can't get that far: library(XLConnect) Loading required package: XLConnectJars Loading required package: rJava Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package 'rJava' could not be loaded sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base Best Wishes, Spencer df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' unlink(outFile) # make sure there is no file to start with f.writeXLSheet(df1, 'df1', outFile) f.writeXLSheet(df2, 'df2', outFile) I have attached the resulting Excel file (see how far it makes it). On Sun, May 20, 2012 at 7:15 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/20/2012 5:52 AM, Gabor Grothendieck wrote: On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.comwrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.comwrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd- list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) Hi, Gabor: Thanks. I think we're gaining on it, but I'm still not quite there. Consider the following extension of my previous toy example: library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(quote(c(df1, df2)), outFile)) # works df2x- function(x, file) do.call(write.xls, list(x, file)) df2x(quote(c(df1, df2)), outFile) # works df2- function(x1, x2, file){ x23- quote(c(x1, x2)) do.call(write.xls, list(x23, file)) } df2(df1, df2, outFile) # Error in get(s[i]) : object 'x1' not found This is closer to what I need. The answer may lie in getting the right envir argument for do.call. However, I haven't yet found something that works there. Thanks, Spencer and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write.xls
On Sun, May 20, 2012 at 7:15 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/20/2012 5:52 AM, Gabor Grothendieck wrote: On Sun, May 20, 2012 at 8:30 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 9:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: The writeFindFn2xls function in the sos package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with multiple sheets. Unfortunately, I can't get any of them to work consistently for me. Below please find test cases that illustrate the problems. Any suggestions for how to solve this problem will be appreciated. Thanks, Spencer library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(c(df1, df2), outFile)) # Error in get(s[i]) : object 'structure(list(c1=1:2' not found Try this: dd- list(df1 = df1, df2 = df2) do.call(WriteXLS, list(dd, outFile)) or this: do.call(WriteXLS, list(c(df1, df2), outFile) That was for WriteXLS. For dataframes2xls try this: do.call(write.xls, list(quote(c(df1, df2)), outFile)) Hi, Gabor: Thanks. I think we're gaining on it, but I'm still not quite there. Consider the following extension of my previous toy example: library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' write.xls(c(df1,df2), outFile) # works do.call(write.xls, list(quote(c(df1, df2)), outFile)) # works df2x - function(x, file) do.call(write.xls, list(x, file)) df2x(quote(c(df1, df2)), outFile) # works df2 - function(x1, x2, file){ x23 - quote(c(x1, x2)) do.call(write.xls, list(x23, file)) } df2(df1, df2, outFile) # Error in get(s[i]) : object 'x1' not found This is closer to what I need. The answer may lie in getting the right envir argument for do.call. However, I haven't yet found something that works there. Thanks, Spencer and also check out this page: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com Unfortunately this is getting increasingly complex due to the non-standard evaluation done by dataframes2xls but if you want to do it then this will do it. We copy dataframes2xls to the current environment and reset write.xls's environment so that it finds the arguments. run - function(x1, x2, file){ df.names - paste0(deparse(substitute(x1)), :::, deparse(substitute(x2))) # copy dataframe2xls namespace contents here reset environment of write.xls here - environment() ns - asNamespace(dataframes2xls) for(nm in ls(ns)) here[[nm]] - ns[[nm]] environment(write.xls) - here x23 - quote(c(x1, x2)) do.call(write.xls, list(x23, file, sh.names = df.names)) } library(dataframes2xls) df1 - data.frame(c1=1:2, c2=3:4, c3=5:6) df2 - data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile - 'df12.xls' run(df1, df2, outFile) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] Names of Greek letters stored as character strings; plotmath.
Well, that's not very comforting, Duncan. It's like saying that you have to read the engineering specs to drive the car successfully. I am certainly ignorant of the internals, but I honestly believe well-written documentation on these points would help. I learned a lot when I read VR's S Programming some years ago, so I think that's an existence theorem. Unfortunately, writing such documentation is hard, maybe harder than writing the code even (my own experience documenting my own code). And your logical response -- Bert, R is open source and would welcome your efforts -- is not going to get much traction. Like you, I don't have the time (nor, in my case, the smarts). Nevertheless, I agree with Robert's sentiment that it could be done. In particular, plotmath docs really should expand their explanation of appropriate syntax, imho. As always, I end by acknowledging the extraordinary efforts of R's developers. Your success is what has led to such carping. A response of Aw shaddup would therefore not be out of line. Best, Bert On Sun, May 20, 2012 at 5:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-05-20 6:53 PM, Robert Baer wrote: -Original Message- From: William Dunlap Sent: Saturday, May 19, 2012 11:07 AM To: Rolf Turner Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings;plotmath. parse(text=paste(...)) works in simple cases but not in others. The fortune about it is there because it is tempting to use but if you bury it in a general purpose function it will cause problems when people start using nonstandard names for variables. bquote(), substitute(), call(), and relatives work in all cases. E.g., par(mfrow=c(2,1)) power- gamma ; x- Waist ; y- Weight # valid R variable names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # same as previous power- gamma ; x- Waist Size (cm) ; y- Weight (kg) # invalid R names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # whoops Error in parse(text = paste0(x, ^, power, /, y)) : text:1:7: unexpected symbol 1: Waist Size ^ Now you might say that serves me right for using weird variable names, but some of us use R as a back end to a GUI system (one not designed around R) and don't want to inflict on users R's rules for names when we do not have to. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Saturday, May 19, 2012 7:24 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings; plotmath. ... and here is another incantation that may be informative. xnm- as.name(gamma') ## This does the parsing plot(0, xlab =bquote(.(xnm)) The initial puzzle is that if you just set xnm- gamma bquote will insert the string gamma rather than the symbol. After all, that's what plotmath sees for xnm. So the key is telling plotmath that it's a symbol, not a string. This can either be done before, as above, or inline, as you and Gabor showed. Unsurprisingly. this also does it, since as.name() is doing the parsing: xnm- gamma plot(0,xlab=bquote(.(as.name(xnm AND we are adhering to Thomas's dictum: bquote is a wrapper for substitute(), which is what he recommends as the preferable alternative to eval(parse(...)) . But, heck -- all such software principles are just guidelines. Whatever works (robustly). HTH. Cheers, Bert On Sat, May 19, 2012 at 3:17 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 1:18 AM, Rolf Turnerrolf.tur...@xtra.co.nz wrote: I had such good luck with my previous question to r-help, (a few minutes ago) that I thought I would try again with the following query: Suppose I have xNm- gamma I would like to be able to do plot(1:10,xlab =something involving xNm) and get the x axis label to be the Greek letter gamma (rather than the literal text string gamma). Is this possible? I've messed around with substitute() and bquote() and got nowhere. Then, just before clicking on Send, I had one more thimk, and blow me down, I got something that worked: plot(1:10,xlab=eval(expression(parse(text=xNm That can be shortened to: plot(0, xlab = parse(text = xNm)) -- snip -- This discussion has been exceedingly helpful, sort of. Every time I try to do a task involving this I read the documentation for bquote(), expression(), plotmath(), etc., over and over, and I still fail to get the big picture of how R parses things under the hood. Typically, I only succeed each time by frustrating trial and error. Can I ask how you guys got a handle on the bigger (besides your usual brillianceG)? Is
Re: [R] Names of Greek letters stored as character strings; plotmath.
This may be a profoundly bad idea, but if deduction is beyond the skill of those with time, perhaps an inferential approach could be used. Create examples of when one approach versus another works. A book of spells, if you will, so that rather than hoping and typing wildly, the magic incantation can simply be looked up. Josh On May 20, 2012, at 19:28, Bert Gunter gunter.ber...@gene.com wrote: Well, that's not very comforting, Duncan. It's like saying that you have to read the engineering specs to drive the car successfully. I am certainly ignorant of the internals, but I honestly believe well-written documentation on these points would help. I learned a lot when I read VR's S Programming some years ago, so I think that's an existence theorem. Unfortunately, writing such documentation is hard, maybe harder than writing the code even (my own experience documenting my own code). And your logical response -- Bert, R is open source and would welcome your efforts -- is not going to get much traction. Like you, I don't have the time (nor, in my case, the smarts). Nevertheless, I agree with Robert's sentiment that it could be done. In particular, plotmath docs really should expand their explanation of appropriate syntax, imho. As always, I end by acknowledging the extraordinary efforts of R's developers. Your success is what has led to such carping. A response of Aw shaddup would therefore not be out of line. Best, Bert On Sun, May 20, 2012 at 5:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-05-20 6:53 PM, Robert Baer wrote: -Original Message- From: William Dunlap Sent: Saturday, May 19, 2012 11:07 AM To: Rolf Turner Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings;plotmath. parse(text=paste(...)) works in simple cases but not in others. The fortune about it is there because it is tempting to use but if you bury it in a general purpose function it will cause problems when people start using nonstandard names for variables. bquote(), substitute(), call(), and relatives work in all cases. E.g., par(mfrow=c(2,1)) power- gamma ; x- Waist ; y- Weight # valid R variable names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # same as previous power- gamma ; x- Waist Size (cm) ; y- Weight (kg) # invalid R names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # whoops Error in parse(text = paste0(x, ^, power, /, y)) : text:1:7: unexpected symbol 1: Waist Size ^ Now you might say that serves me right for using weird variable names, but some of us use R as a back end to a GUI system (one not designed around R) and don't want to inflict on users R's rules for names when we do not have to. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Saturday, May 19, 2012 7:24 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings; plotmath. ... and here is another incantation that may be informative. xnm- as.name(gamma') ## This does the parsing plot(0, xlab =bquote(.(xnm)) The initial puzzle is that if you just set xnm- gamma bquote will insert the string gamma rather than the symbol. After all, that's what plotmath sees for xnm. So the key is telling plotmath that it's a symbol, not a string. This can either be done before, as above, or inline, as you and Gabor showed. Unsurprisingly. this also does it, since as.name() is doing the parsing: xnm- gamma plot(0,xlab=bquote(.(as.name(xnm AND we are adhering to Thomas's dictum: bquote is a wrapper for substitute(), which is what he recommends as the preferable alternative to eval(parse(...)) . But, heck -- all such software principles are just guidelines. Whatever works (robustly). HTH. Cheers, Bert On Sat, May 19, 2012 at 3:17 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, May 19, 2012 at 1:18 AM, Rolf Turnerrolf.tur...@xtra.co.nz wrote: I had such good luck with my previous question to r-help, (a few minutes ago) that I thought I would try again with the following query: Suppose I have xNm- gamma I would like to be able to do plot(1:10,xlab =something involving xNm) and get the x axis label to be the Greek letter gamma (rather than the literal text string gamma). Is this possible? I've messed around with substitute() and bquote() and got nowhere. Then, just before clicking on Send, I had one more thimk, and blow me down, I got something that worked: plot(1:10,xlab=eval(expression(parse(text=xNm That can be shortened to: plot(0, xlab =
Re: [R] Names of Greek letters stored as character strings; plotmath.
On 12-05-20 10:28 PM, Bert Gunter wrote: Well, that's not very comforting, Duncan. It's like saying that you have to read the engineering specs to drive the car successfully. I think Robert's message that I responded to was asking for a deeper understanding than simply driving the car. He appeared to want to know why the car worked the way it did, and describing that entirely in terms of things you can see without opening the hood is hard. I am certainly ignorant of the internals, but I honestly believe well-written documentation on these points would help. I learned a lot when I read VR's S Programming some years ago, so I think that's an existence theorem. I wouldn't disagree with that. Both V and R knew an awful lot about S when they wrote that, and they know how to communicate well. Unfortunately, writing such documentation is hard, maybe harder than writing the code even (my own experience documenting my own code). And your logical response -- Bert, R is open source and would welcome your efforts -- is not going to get much traction. Like you, I don't have the time (nor, in my case, the smarts). Nevertheless, I agree with Robert's sentiment that it could be done. In particular, plotmath docs really should expand their explanation of appropriate syntax, imho. I don't think it's impossible to write the book Robert wants, and since there are a lot of R books out there, someone may have already done it. If they have, maybe they did it by explaining R internals. If not, I think my advice stands. Duncan Murdoch As always, I end by acknowledging the extraordinary efforts of R's developers. Your success is what has led to such carping. A response of Aw shaddup would therefore not be out of line. Best, Bert On Sun, May 20, 2012 at 5:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-05-20 6:53 PM, Robert Baer wrote: -Original Message- From: William Dunlap Sent: Saturday, May 19, 2012 11:07 AM To: Rolf Turner Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings;plotmath. parse(text=paste(...)) works in simple cases but not in others. The fortune about it is there because it is tempting to use but if you bury it in a general purpose function it will cause problems when people start using nonstandard names for variables. bquote(), substitute(), call(), and relatives work in all cases. E.g., par(mfrow=c(2,1)) power- gamma ; x- Waist ; y- Weight # valid R variable names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # same as previous power- gamma ; x- Waist Size (cm) ; y- Weight (kg) # invalid R names plot(0, main=bquote(.(as.name(x))^.(as.name(power))/.(as.name(y plot(0, main=parse(text=paste0(x, ^, power, /, y))) # whoops Error in parse(text = paste0(x, ^, power, /, y)) : text:1:7: unexpected symbol 1: Waist Size ^ Now you might say that serves me right for using weird variable names, but some of us use R as a back end to a GUI system (one not designed around R) and don't want to inflict on users R's rules for names when we do not have to. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Saturday, May 19, 2012 7:24 AM To: Gabor Grothendieck Cc: r-help Subject: Re: [R] Names of Greek letters stored as character strings; plotmath. ... and here is another incantation that may be informative. xnm- as.name(gamma') ## This does the parsing plot(0, xlab =bquote(.(xnm)) The initial puzzle is that if you just set xnm- gamma bquote will insert the string gamma rather than the symbol. After all, that's what plotmath sees for xnm. So the key is telling plotmath that it's a symbol, not a string. This can either be done before, as above, or inline, as you and Gabor showed. Unsurprisingly. this also does it, since as.name() is doing the parsing: xnm- gamma plot(0,xlab=bquote(.(as.name(xnm AND we are adhering to Thomas's dictum: bquote is a wrapper for substitute(), which is what he recommends as the preferable alternative to eval(parse(...)) . But, heck -- all such software principles are just guidelines. Whatever works (robustly). HTH. Cheers, Bert On Sat, May 19, 2012 at 3:17 AM, Gabor Grothendieck ggrothendi...@gmail.comwrote: On Sat, May 19, 2012 at 1:18 AM, Rolf Turnerrolf.tur...@xtra.co.nz wrote: I had such good luck with my previous question to r-help, (a few minutes ago) that I thought I would try again with the following query: Suppose I have xNm- gamma I would like to be able to do plot(1:10,xlab =something involving xNm) and get the x axis label to be the Greek letter gamma (rather than the literal text string gamma). Is this possible? I've messed around with substitute() and bquote() and got nowhere.
Re: [R] write.xls
On 5/20/2012 5:37 PM, Gabor Grothendieck wrote: snip Unfortunately this is getting increasingly complex due to the non-standard evaluation done by dataframes2xls but if you want to do it then this will do it. We copy dataframes2xls to the current environment and reset write.xls's environment so that it finds the arguments. run- function(x1, x2, file){ df.names- paste0(deparse(substitute(x1)), :::, deparse(substitute(x2))) # copy dataframe2xls namespace contents here reset environment of write.xls here- environment() ns- asNamespace(dataframes2xls) for(nm in ls(ns)) here[[nm]]- ns[[nm]] environment(write.xls)- here x23- quote(c(x1, x2)) do.call(write.xls, list(x23, file, sh.names = df.names)) } library(dataframes2xls) df1- data.frame(c1=1:2, c2=3:4, c3=5:6) df2- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) ) outFile- 'df12.xls' run(df1, df2, outFile) Thanks very much. I got this to work. However, I discovered three other problems with write.xls: (1) With \n in a character string in the data.frame, it fails to write a file, noting, Infile name is not a valid csv file without throwing an error. (2) With , in a character string in the data.frame, it splits that element over multiple columns, thereby corrupting what is written. (3) It insists on quoting all all character strings. I don't need or want those extraneous quotes, but I don't know how to get rid of them. I've modified the code to gsub('\n|,', ' ', strings); this provides an acceptable fix to the first two problems. I plan to ignore the third if I can't fix it. Thanks again, Spencer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about sign test
Hi, That seems a reasonable enough approach to me. (p - pnorm(0, mean = 1, sd = .5)) is the probability of a value being less than or up to 0 from the distribution you specified. Using that, lets repeat your little test 1000 times using your code, and then using ribnom() where the probability that a value is 1 is 1 - p (i.e., if p is the probability = 0, then 1 - p is the probability of 0). res1 - replicate(1000, binom.test(sum(rnorm(15, 1, 0.5) 0), 15, p = 0.5, alternative=two)$p.value) res2 - replicate(1000, binom.test(sum(rbinom(15, 1, 1 - p)), 15, p = 0.5, alternative=two)$p.value) now we can look at the average p-value from both techniques: mean(res1) mean(res2) they are quite similar. I ran each of them with 100,000 replicates for stability and got: mean(res1) [1] 0.0007627936 mean(res2) [1] 0.0007608844 I hope this helps, Josh On Sun, May 20, 2012 at 9:34 AM, T Bal studentt...@gmail.com wrote: Hi, I want to compute p value of sign test for sample size=15 from normal distr., sd=0.5, mean=1, alternative should be two sided. Is this code correct in this situation? binom.test(sum(rnorm(15,1,0.5)0),15,p=0.5,alternative=two)$p.value Or should I use another code (function) e.g. rbinom? Thank you very much. kind regards, T. Bal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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] convert function in RTAQ package for high frequency data analysis
Hello Everyone, I am trying to convert the txt file into RData format by using convert function in RTAQ package.The txt file looks like: 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9600 300 T 0 0 The code I am using is: convert(from=2010-07-01,to=2010-07 -01,datasource=C:\\workdirectory\\TAQdata,datadestination=C:\\workdirectory\\datadestination,trades=T,quotes=F,ticker=SBUX,dir=F,format=%Y-%m-%d %H:%M:%S,) Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'C:\workdirectory\TAQdata/2010-07-01/SBUX_trades.txt' sbux.t - TAQLoad(tickers=SBUX,from=2010-07-01,to=2010-07-01,trades=T,quotes=F,datasource=C:\\workdirectory\\datadestination) head(sbux.t,3) I am getting the following output: SYMBOL EX PRICE SIZE COND CORR G127 NA 2010-07-01 SBUX 24.9500 100 1 0 0 NA 2010-07-01 SBUX 24.9500 100 1 0 0 NA 2010-07-01 SBUX 24.9600 300 1 0 0 Warning message: timezone of object (GMT) is different than current timezone (). But my desired output is: SYMBOL EX PRICE SIZE COND CORR G127 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9600 300 T 0 0 Can someone please help? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in convert function in RTAQ package
Do you get any errors? I am not too familiar with RTAQ, but I am not seeing aynthing you are doing obviously wrong. Another possibility I guess is that R may not have write permission to the datadestination folder. It may help if you could report some more information, maybe upload the text file you are using online. You could also try starting R with administrative privileges. I am not sure that is the problem, just thinking out loud (or out written perhaps). Cheers, Josh On Sat, May 19, 2012 at 11:44 PM, rahul deora rahulsparx2...@gmail.com wrote: Hi All, I am using convert() function in RTAQ package to convert the text file into xts object.The code I am using is shown below: convert(from=2010-07-01,to=2010-07-01,datasource=C:\\TAQdata,datadestination=C:\\datadestination,trades=T,quotes=F,ticker=SUBX,dir=F) The problem is that I am not getting the text files named Ticker.trades in .RData format in the destination folder.The sample data I am using is: DATE TIME SYMBOL EX PRICE SIZE COND CORR G127 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9500 100 T 0 0 2010-07-01 08:04:28 SBUX Q 24.9600 300 T 0 0 Please help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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.