Re: [R] empty files created with trellis xyplot jpeg device
I'm guessing R FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html The subtlety is that in an interactive session print is automatically called at the final evaluation of most everything, but you have to prompt it in interactive use (and depending on details, in some function calls) Michael Weylandt On Sat, Dec 31, 2011 at 6:50 PM, Mike Dahman mike.dah...@gmail.com wrote: New years greetings. I have been setting up a function to generate multiple jpeg charts. When the calls are issued at the interactive console, the jpeg files are generated without an issue. When I try to issue the same calls from a function, some chart files are empty. It appears to only be related to trellis charts. Any help to troubleshoot this is appreciated. Regards, -mike R version 2.14.0 (2011-10-31) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) # validate devices capabilities() jpeg png tiff tcltk X11 aqua http/ftp sockets TRUE FALSE FALSE FALSE TRUE FALSE TRUE TRUE libxml fifo cledit iconv NLS profmem cairo TRUE TRUE TRUE TRUE TRUE FALSE FALSE # Example functionality from the interactive console # I am going to use a zone variable to help duplicate the code in the function zone [1] isoranp-z1 # call a function to pull in data and assign it to a data frame testz-get_zonedata_url(2011,51,zone) # validate the data frame str(testz) 'data.frame': 2016 obs. of 14 variables: $ ts : Factor w/ 2016 levels 12/18/2011 00:00,..: 1 2 3 4 5 6 7 8 9 10 ... $ server : Factor w/ 1 level phx1npf4sn2: 1 1 1 1 1 1 1 1 1 1 ... $ zone : Factor w/ 1 level isoranp-z1: 1 1 1 1 1 1 1 1 1 1 ... $ pool : Factor w/ 1 level ORA-S1: 1 1 1 1 1 1 1 1 1 1 ... $ cpucap : num 4 4 4 4 4 4 4 4 4 4 ... $ memcap : int 26 26 26 26 26 26 26 26 26 26 ... $ swapcap: int 26 26 26 26 26 26 26 26 26 26 ... $ cpu : num 78.2 206.8 198.4 366.4 112.1 ... $ poolsz : int 42 42 42 42 42 42 42 42 42 42 ... $ mem : num 75.5 75.3 75.6 74.5 74.3 ... $ swp : num 80.2 80.1 79.6 79 78.9 ... $ dates : chr 12/18/2011 12/18/2011 12/18/2011 12/18/2011 ... $ times : chr 00:00:00 00:05:00 00:10:00 00:15:00 ... $ dt :Classes 'chron', 'dates', 'times' atomic [1:2016] 15326 15326 15326 15326 15326 ... .. ..- attr(*, format)= chr [1:2] m/d/y h:m:s .. ..- attr(*, origin)= Named num [1:3] 1 1 1970 .. .. ..- attr(*, names)= chr [1:3] month day year # set up a jpeg device trellis.device(jpeg,file=paste(charts/,zone,.zone_util.jpg,sep=)) # call a function to generate the chart # the plot_zone_util function uses xyplot plot_zone_util(testz) #close the device dev.off() The jpeg file is generated as expected: (User and group has been removed) ls -l isoranp-z1.zone_util.jpg -rw-rw-r-- 1 32123 Dec 31 16:13 isoranp-z1.zone_util.jpg # here is the plot_zone_util function for reference plot_zone_util - function(zone_df){ xyplot(cpu~dt|server,data=zone_df,ylim=c(0,100), main=paste(zone_df$zone[1], CPU (Blue) Memory (Red) Util\n,zone_df$ts[1],-,zone_df$ts[nrow(zone_df)],sep=), xlab=date, ylab=utilization (%), panel=function(x,y,subscripts){ panel.lines(x,y) panel.lines(zone_df$dt[subscripts],zone_df$mem[subscripts],col=red) }, as.Table=T, subscripts=T) } ## # Try and do the same thing within a function::: gen_zone_charts(zone,2011,51) # Note the zone_util.jpg file is zero length. It is a lattice chart. The other two charts generate ok. User and group has been removed. -rw-rw-r-- 1 22376 Dec 31 16:20 isoranp-z1.zone_cpu.jpg -rw-rw-r-- 1 18910 Dec 31 16:20 isoranp-z1.zone_mem.jpg -rw-rw-r-- 1 0 Dec 31 16:20 isoranp-z1.zone_util.jpg # here is the gen_zone_charts function: gen_zone_charts function(zone,year,wk){ data_frame-get_zonedata_url(year,wk,zone) # this results in a 0 length file # i have tried using jpeg(), and trellis.device() with the same results #jpeg(file=paste(charts/,zone,.zone_util.jpg,sep=)) trellis.device(jpeg,file=paste(charts/,zone,.zone_util.jpg,sep=)) #uses xyplot - works fine being called from the console plot_zone_util(data_frame) dev.off() # this works ok jpeg(file=paste(charts/,zone,.zone_cpu.jpg,sep=)) # uses combination of boxplot and plot with a preceeding par() plot_zone_cpu(data_frame) dev.off() # this works ok jpeg(file=paste(charts/,zone,.zone_mem.jpg,sep=)) # uses combination of plot and plot with a preceeding par() plot_zone_mem(data_frame) dev.off() } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list
Re: [R] Is it possible to right align text in R graphics?
Hi Duncan, Thank you for your reply. I am also using Win 7. And I would be surprised if this would be different in any OS. I guess the answer is that there is no way for making text in a graph in R be right-to-left. Thanks again, and happy new year, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sun, Jan 1, 2012 at 5:34 AM, Duncan Mackay mac...@northnet.com.auwrote: Hi Tal I think it might be an OS problem whether it is a graphics as well I do not know. I Just copied and pasted the line into R and it seems ok OS win 7 version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 14.1 year 2011 month 12 day22 svn rev57956 language R version.string R version 2.14.1 (2011-12-22) Regards Regards Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email: home mac...@northnet.com.au At 02:52 30/12/2011, you wrote: Content-Type: text/plain Content-Disposition: inline Content-length: 796 Hello all, The following line of code includes a right-to-left language text, yet the R graphics engine displays it from left to right. One problem this causes is when there are parenthesis in the test, here is a basic example? plot(1:10, main = ש××× (×קס×)) Is there a way to make sure the text is displayed from right to left? Many thanks for any suggestions, Tal Contact Details:--**--**--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) --**--** --** [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-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. __** 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. [[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] Histogram omitting/collapsing groups
On Jan 1, 2012, at 07:40 , Joshua Wiley wrote: If you just want a plot of the frequencies at each hour why not just call barplot on the output of table? Histograms create bins and count in those, which doesn't sound like what you're after. Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Cheers, Josh On Dec 31, 2011, at 21:37, jim holtman jholt...@gmail.com wrote: Fast fingers; notice that there is still a problem in the counts; I was only looking at the last. Happy New Year -- up too late. On Sun, Jan 1, 2012 at 12:33 AM, jim holtman jholt...@gmail.com wrote: Here is a test I ran and looks fine, but then I created the data, so it might have something to do with your data: x - sample(0:23, 10, TRUE) a - hist(x, breaks = 24) a[1:5] $breaks [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 $counts [1] 8262 4114 4186 4106 4153 4234 4206 4155 4157 4203 4186 4158 4132 4139 4231 4216 4158 4054 4185 4153 [21] 4281 4110 4221 $intensities [1] 0.08262 0.04114 0.04186 0.04106 0.04153 0.04234 0.04206 0.04155 0.04157 0.04203 0.04186 0.04158 [13] 0.04132 0.04139 0.04231 0.04216 0.04158 0.04054 0.04185 0.04153 0.04281 0.04110 0.04221 $density [1] 0.08262 0.04114 0.04186 0.04106 0.04153 0.04234 0.04206 0.04155 0.04157 0.04203 0.04186 0.04158 [13] 0.04132 0.04139 0.04231 0.04216 0.04158 0.04054 0.04185 0.04153 0.04281 0.04110 0.04221 $mids [1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5 15.5 16.5 17.5 18.5 19.5 [21] 20.5 21.5 22.5 table(x) x 0123456789 10 11 12 13 14 15 16 17 18 19 20 4168 4094 4114 4186 4106 4153 4234 4206 4155 4157 4203 4186 4158 4132 4139 4231 4216 4158 4054 4185 4153 21 22 23 4281 4110 4221 On Sat, Dec 31, 2011 at 11:20 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi, I think you're not understanding quite what's going on with hist. Reread the help, and take a look at this small example. The solution I'd use is the last item. x - rep(1:10, times=1:10) table(x) x 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 hist(x, plot=FALSE, right=TRUE)$counts [1] 3 3 4 5 6 7 8 9 10 hist(x, plot=FALSE, right=TRUE)$breaks [1] 1 2 3 4 5 6 7 8 9 10 hist(x, plot=FALSE, right=TRUE)$mids [1] 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 hist(x, plot=FALSE, right=FALSE)$counts [1] 1 2 3 4 5 6 7 8 19 hist(x, plot=FALSE, right=FALSE)$breaks [1] 1 2 3 4 5 6 7 8 9 10 hist(x, plot=FALSE, right=FALSE)$mids [1] 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 hist(x, plot=FALSE, breaks=seq(.5, 10.5, by=1))$counts [1] 1 2 3 4 5 6 7 8 9 10 hist(x, plot=FALSE, breaks=seq(.5, 10.5, by=1))$breaks [1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 hist(x, plot=FALSE, breaks=seq(.5, 10.5, by=1))$mids [1] 1 2 3 4 5 6 7 8 9 10 Sarah On Sat, Dec 31, 2011 at 10:25 AM, Aren Cambre a...@arencambre.com wrote: I have two large datasets (156K and 2.06M records). Each row has the hour that an event happened, represented by an integer from 0 to 23. R's histogram is combining some data. Here's the command I ran to get the histogram: histinfo - hist(crashes$hour, right=FALSE) Here's histinfo: histinfo $breaks [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 $counts [1] 4755 4618 5959 3292 2378 2715 4592 6144 6860 5598 5601 6596 7152 7490 8166 [16] 9758 11301 11745 9943 7494 6272 6220 11669 $intensities [1] 0.03041876 0.02954234 0.03812101 0.02105963 0.01521258 0.01736844 0.02937602 0.03930449 [9] 0.04388490 0.03581161 0.03583081 0.04219604 0.04575289 0.04791515 0.05223967 0.06242403 [17] 0.07229494 0.07513530 0.06360752 0.04794074 0.04012334 0.03979068 0.07464911 $density [1] 0.03041876 0.02954234 0.03812101 0.02105963 0.01521258 0.01736844 0.02937602 0.03930449 [9] 0.04388490 0.03581161 0.03583081 0.04219604 0.04575289 0.04791515 0.05223967 0.06242403 [17] 0.07229494 0.07513530 0.06360752 0.04794074 0.04012334 0.03979068 0.07464911 $mids [1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5 15.5 16.5 17.5 [19] 18.5 19.5 20.5 21.5 22.5 $xname [1] crashes$hour $equidist [1] TRUE attr(,class) [1] histogram Note how the last value in counts is 11669. It's relevant to the output of
[R] R report generator (for Word)?
Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? My work is about analysing data... My current work-flow: 1. Everyday my bosses give me some small steps/tasks for analysing data - which are parts of one bigger/whole project. 2. Everyday I send tens of emails to bosses/colleagues to report my findings in each step. 3. Bosses/colleagues often respond to my findings in real-time and suggest new experiments/steps and ask what-if questions. 4. I often have to manually copy and paste the results from R console and put them into an Excel and decorate a bit and send out. 5. Every one week and 2 weeks, we need to present to more senior bosses with more nice-looking presentations which is a summary of our findings in those 1-2 weeks. It's this time that is most chaotic because my colleagues and I have to dig into all the hundreds of emails in the past 1-2 weeks and copy and paste and organize those data again and make a nice overall summary for presentation... 6. As I am a hard-working guy, I myself often run my own random/ad-hoc experiments using out-of-work time and whenever I have interesting findings, I will send to immediate bosses and colleagues to seek their comments. 7. All these experiments are in fact variations of different versions/ideas of one big/whole project. Lets say in one big project bosses/colleagues and I have come up with a few big ideas, then we have a few sub-projects: MyProjectIdea1 MyProjectIdea2 ... MyProjectIdeaN And each idea has a few variations, mostly are for answering what-if questions by varying the parameters here and there ... For example: MyProjectIdea1_Variation1_WhatIfParam1ChangedTo1.2? ... ... etc. 8. Most experiments run tens of minutes to many hours... and some of them have to run on Linux, and some others can be run on Windows. Fortunately we have universal paths accessible on both Windows and Linux, so those won't be problem... 9. Because of the time-consuming nature of these experiments, I also save the images as rData whenever I can. However, it's necessary to keep track of the context where these data were generated. Otherwise even the records of these images won't help recall the scenario we have run... --- Keeping track of these changes and all kinds of what-ifs now becomes increasingly a problem for me. Some times in order to respond to a query, although I have done it before already, but because I didn't keep record and save the result, or even though I have saved the memory image yet I am not completely sure about the cleanness of the results/data,I have to redo it and wait for another few hours. Is there a way that I can manage these whole processes better and be more productive? I have been digging and thinking about this for while and I guess Sweave is the right way to go? The problem for Sweave is that it's hard to make Latex generated pdf appealing to business managers... so if I keep records in Sweave/Latex for my own record/benefit (that's already a big benefit)... I still need to somehow manually copy/paste the data from Sweave/Latex/pdf into Word/Excel/Powerpoint in order to make a nice presentation... I know there are some Open Office and Word version of Sweave... the problem is that I couldn't find many demonstrations on these topics and my question is: are they good and can they fulfill what we needed? Your thoughts are greatly appreciated! Thanks a lot! [[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] looking for R software resource persons
dear all, i am looking for R software resources persons from India. Please reply. Thanks Regards Sridhar _ Sridhar Gutam PhD, ARS, PG Dip Patent Laws (NALSAR), IP Biotechnology (WIPO) Senior Scientist (Plant Physiology) Joint Secretary, ARSSF Central Institute for Subtropical Horticulture (CISH) Rehmankhera, P.O.Kakori, Lucknow 227107, Uttar Pradesh, India Fax: +91-522-2841025, Phone: +91-522-2841022/23/24; Mobile:+91-9005760036 CISH http://www.cishlko.org ARSSF http://www.arssf.co.nr My site http://www.gutam.co.nr My Publications http://works.bepress.com/sridhar_gutam/ My Twitter: http://twitter.com/#!/gutam2000 My Facebook: https://www.facebook.com/gutamsridhar My LinkedIn: http://www.linkedin.com/in/sridhargutam [[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] bmp() shifts the image (Windows XP)
When using bmp() under Windows XP, I find that the saved image is a shifted version of the correct image. Try this: n-5 fn-01.bmp x-matrix(runif(n*n),nrow=n) image(x,col=gray(0:255/255),axes=F,frame.plot=F) bmp(filename = fn,width = n, height = n, units = px) par(mar=c(0,0,0,0),pty=s) image(x,col=gray(0:255/255),axes=F,frame.plot=F) dev.off() The image 01.bmp is like this: 22 23 24 25 w 32 33 34 35 w 42 43 44 45 w 52 53 54 55 w w w w w w w Where 22 represents x[2,2], etc; w represents a white pixel. For my application, the image has to be .bmp format. The same shifting behaviour is seen for large values of n. It is not just due to the small n value. For my application, this shifting is important and has to be eliminated. Please help. On an unrelated note, I found out that the bmp() code is smart enough to write my image as 8-bit using a palette instead of 24-bit with 0:255 grey levels if the image being saved does not use all 256 grey levels. I would love to hear it if somebody knows a good way to make bmp() stupid and always save as 24-bit. My kludge, using 256x256 pixel images, is to tack on an extra row with grey levels 0:255. Then when displaying, I have to crop the image to get rid of that bogus row. Thanks very much for any help! Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on Android
Hello,I am new to this list. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Federico -- Federico [[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] mtrace function
Thanks for passing that on, Uwe. There are two separate things here: - Uwe's problem is a bug: there is an experimental source-code-debugging feature in 'debug' that doesn't work properly yet (pending a change in the 'parser' package) and for some stupid reason I'd set the default to use experimental feature. I have changed that in the version I'm about to upload. sorry... - The debug window having blank bits: see 'package?debug' and the Display bugs section where this is dealt with. AFAICS it's a long-standing problem with the tcl/tk and R. I use Windows XP and have no problems-- having followed my own advice in the doco ;). bye Mark Mark Bravington CSIRO CMIS Marine Lab Hobart Australia From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: 30 December 2011 01:44 To: Enio Jelihovschi Cc: r-help@r-project.org; Bravington, Mark (CMIS, Hobart) Subject: Re: [R] mtrace function This is something you should report to the maintainer. I tried to reproduce (never using that package myself), and got when trying the examples from ?mtrace: library(debug) mtrace(glm) # turns tracing on Loading required package: parser Loading required package: Rcpp Error in numbered.id[n] - attr(src.expr[[i]], id) : replacement has length zero Mark, I think we need an update for CRAN. sessionInfo() R version 2.14.1 (2011-12-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=CLC_NUMERIC=C [5] LC_TIME=C attached base packages: [1] tcltk tools stats graphics grDevices utils datasets [8] methods base other attached packages: [1] parser_0.0-14Rcpp_0.9.9 debug_1.2.40 mvbutils_2.5.101 Best, Uwe Ligges On 22.12.2011 17:59, Enio Jelihovschi wrote: I use windows xp. When trying to use the function mtrace from package debug the window that should open with the function to be debugged do not show any text at all. It shows only a part of my desktop. Does anyone know why. Is there any imcompatibility between windows xp and debug package. Thanks in advance. Enio Jelihovschi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rep() inside of lm()?
HI all, I'm new to R. Say I have a multi-layered list called newlist. str(newlist) List of 2 $ :List of 5 ..$ : num [1:8088] NA 464 482 535 557 ... ..$ : num [1:8088, 1:2] NA 464 482 535 557 ... ..$ : num [1:8088, 1:3] NA 464 482 535 557 ... ..$ : num [1:8088, 1:4] NA 464 482 535 557 ... ..$ : num [1:8088, 1:5] NA 464 482 535 557 ... $ :List of 3 ..$ : num [1:8088] NA NA 1386 464 482 ... ..$ : num [1:8088] NA NA NA 1386 464 ... ..$ : num [1:8088] NA NA NA NA 1386 ... Let's say this list has 2 entries. i.e. length(newlist)=2. However, in my function this list can be any number of entries, 1 to N. I want to regress each newlist[[N]] in a multiple linear regression. The problem is I don't know how to make a non-character or a non-numeric repeat. So I'd want something like: #--- dumplist-list() for(a in 1:length(newlist[[1]])){ for(b in 1:length(newlist[[2]]){ for(terminal in 1:length(newlist[[length(newlist)]])){ dumlist[[..]]-lm(y~newlist[[1]][a] + newlist[[2]]][b] + ... + newlist[[N]][terminal]). }}} #--- and I want the above to adjust to whatever N is. I'm new to R so this kind of thing is very difficult. I'm experimenting with eval(), parse(), paste(), expression(), letters[] and other stuff but I'm not getting far and I would greatly appreciation any guidance. Thank you. - Isaac Research Assistant Quantitative Finance Faculty, UTS -- View this message in context: http://r.789695.n4.nabble.com/rep-inside-of-lm-tp4250712p4250712.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram omitting/collapsing groups
On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard pda...@gmail.com wrote: Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Thanks, everybody. I'll definitely switch to barplot. As for continuous, it's all relative. Even the most continuous dataset at a scale that looks pretty to humans may have gaps between the values when you zoom in a lot. Aren __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on Android
On Jan 1, 2012, at 10:05 AM, Federico J. Villatoro wrote: Hello,I am new to this list. So new that you have not yet read the posting guide it appears. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Quick answer: Not yet (as such). Longer answer. Do a search: RSiteSearch(Android) A search query has been submitted to http://search.r-project.org The results page should open in your browser shortly The results does not include the prior discussions in rhelp, but if you change the settings on that page and rerun, you should get them. Federico -- Federico [[alternative HTML version deleted]] David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on Android
On Jan 1, 2012, at 11:07 AM, David Winsemius wrote: On Jan 1, 2012, at 10:05 AM, Federico J. Villatoro wrote: Hello,I am new to this list. So new that you have not yet read the posting guide it appears. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Quick answer: Not yet (as such). Longer answer. Do a search: RSiteSearch(Android) A search query has been submitted to http://search.r-project.org The results page should open in your browser shortly The results does not include the prior discussions in rhelp, but if you change the settings on that page and rerun, you should get them. The Baron search site seems to record the fact that discussions on r- devel have occurred but fails to link to them properly, so this is an alternative strategy for the r-devel archive search: https://www.google.com/search?q=android+site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-devel%2Fhl=ennum=20 Unfortunately people are no using android in their domain names and the search includes headers, so about half of those hits are off-target. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram omitting/collapsing groups
Hi Aren, I was busy thinking about how to make what you wanted, and I missed that you were working with hours from a day. That being the case, you may think about a circular graph. The attached plots show two different ways of working with the same data. Cheers, Josh set.seed(10) x - sample(0:23, 1, TRUE, prob = sin(0:23)+1) require(ggplot2) # graphing package ## regular barplot p - ggplot(as.data.frame(table(x)), aes(x = x, y = Freq)) + geom_bar() ## using circular coordinates p2 - p + coord_polar() ## print them print(p) print(p2) ## just if you're interested, the code to ## put the two plots side by side require(grid) dev.new(height = 6, width = 12) grid.newpage() pushViewport(vpList( viewport(x = 0, width = .5, just = left, name = barplot), viewport(x = .5, width = .5, just = left, name=windrose))) seekViewport(barplot) grid.draw(ggplotGrob(p)) seekViewport(windrose) grid.draw(ggplotGrob(p2)) On Sun, Jan 1, 2012 at 7:59 AM, Aren Cambre a...@arencambre.com wrote: On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard pda...@gmail.com wrote: Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Thanks, everybody. I'll definitely switch to barplot. As for continuous, it's all relative. Even the most continuous dataset at a scale that looks pretty to humans may have gaps between the values when you zoom in a lot. Aren -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ plots.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rep() inside of lm()?
On Jan 1, 2012, at 9:13 AM, iliketurtles wrote: HI all, I'm new to R. Say I have a multi-layered list called newlist. Which you have not provided in a form that lends itself well to constructing worked examples. str(newlist) List of 2 $ :List of 5 ..$ : num [1:8088] NA 464 482 535 557 ... ..$ : num [1:8088, 1:2] NA 464 482 535 557 ... ..$ : num [1:8088, 1:3] NA 464 482 535 557 ... ..$ : num [1:8088, 1:4] NA 464 482 535 557 ... ..$ : num [1:8088, 1:5] NA 464 482 535 557 ... $ :List of 3 ..$ : num [1:8088] NA NA 1386 464 482 ... ..$ : num [1:8088] NA NA NA 1386 464 ... ..$ : num [1:8088] NA NA NA NA 1386 ... Let's say this list has 2 entries. i.e. length(newlist)=2. However, in my function this list can be any number of entries, 1 to N. I want to regress each newlist[[N]] in a multiple linear regression. The problem is I don't know how to make a non-character or a non-numeric repeat. So I'd want something like: #--- dumplist-list() for(a in 1:length(newlist[[1]])){ for(b in 1:length(newlist[[2]]){ for(terminal in 1:length(newlist[[length(newlist)]])){ Most problems if this sort arise from failing to understand that formulas are not built up like that. The lm function is not going to interpret your character values inside the expressions linked with +'s and ~. If you want to make a formula you will need to use paste() to construct the approriate string and then formula() or as.formula() to make it the appropriate mode ( and do this before passing to lm(). There are many, many worked examples in the rhelp archives. -- David dumlist[[..]]-lm(y~newlist[[1]][a] + newlist[[2]]][b] + ... + newlist[[N]][terminal]). }}} #--- and I want the above to adjust to whatever N is. I'm new to R so this kind of thing is very difficult. I'm experimenting with eval(), parse(), paste(), expression(), letters[] and other stuff but I'm not getting far and I would greatly appreciation any guidance. Isaac Research Assistant Quantitative Finance Faculty, UTS -- View this message in context: http://r.789695.n4.nabble.com/rep-inside-of-lm-tp4250712p4250712.html Sent from the R help mailing list archive at Nabble.com. You might consider subscribing rather than using Nabble which is neither r-help nor is it an archive. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 report generator (for Word)?
Have you seen r2wd? http://www.r-bloggers.com/exporting-r-output-to-ms-word-with-r2wd-an-example-session/ On Jan 1, 2012, at 10:50 AM, Michael comtech@gmail.com wrote: Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? My work is about analysing data... My current work-flow: 1. Everyday my bosses give me some small steps/tasks for analysing data - which are parts of one bigger/whole project. 2. Everyday I send tens of emails to bosses/colleagues to report my findings in each step. 3. Bosses/colleagues often respond to my findings in real-time and suggest new experiments/steps and ask what-if questions. 4. I often have to manually copy and paste the results from R console and put them into an Excel and decorate a bit and send out. 5. Every one week and 2 weeks, we need to present to more senior bosses with more nice-looking presentations which is a summary of our findings in those 1-2 weeks. It's this time that is most chaotic because my colleagues and I have to dig into all the hundreds of emails in the past 1-2 weeks and copy and paste and organize those data again and make a nice overall summary for presentation... 6. As I am a hard-working guy, I myself often run my own random/ad-hoc experiments using out-of-work time and whenever I have interesting findings, I will send to immediate bosses and colleagues to seek their comments. 7. All these experiments are in fact variations of different versions/ideas of one big/whole project. Lets say in one big project bosses/colleagues and I have come up with a few big ideas, then we have a few sub-projects: MyProjectIdea1 MyProjectIdea2 ... MyProjectIdeaN And each idea has a few variations, mostly are for answering what-if questions by varying the parameters here and there ... For example: MyProjectIdea1_Variation1_WhatIfParam1ChangedTo1.2? ... ... etc. 8. Most experiments run tens of minutes to many hours... and some of them have to run on Linux, and some others can be run on Windows. Fortunately we have universal paths accessible on both Windows and Linux, so those won't be problem... 9. Because of the time-consuming nature of these experiments, I also save the images as rData whenever I can. However, it's necessary to keep track of the context where these data were generated. Otherwise even the records of these images won't help recall the scenario we have run... --- Keeping track of these changes and all kinds of what-ifs now becomes increasingly a problem for me. Some times in order to respond to a query, although I have done it before already, but because I didn't keep record and save the result, or even though I have saved the memory image yet I am not completely sure about the cleanness of the results/data,I have to redo it and wait for another few hours. Is there a way that I can manage these whole processes better and be more productive? I have been digging and thinking about this for while and I guess Sweave is the right way to go? The problem for Sweave is that it's hard to make Latex generated pdf appealing to business managers... so if I keep records in Sweave/Latex for my own record/benefit (that's already a big benefit)... I still need to somehow manually copy/paste the data from Sweave/Latex/pdf into Word/Excel/Powerpoint in order to make a nice presentation... I know there are some Open Office and Word version of Sweave... the problem is that I couldn't find many demonstrations on these topics and my question is: are they good and can they fulfill what we needed? Your thoughts are greatly appreciated! Thanks a lot! [[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 report generator (for Word)?
I am not at my desk but you might search the CRAN web site for reproducible research. Respectfully, Frank Lawrence -Original Message- From: Michael comtech@gmail.com Sender: r-help-bounces@r-project.orgDate: Sun, 1 Jan 2012 09:50:24 To: r-helpr-h...@stat.math.ethz.ch Subject: [R] R report generator (for Word)? Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? My work is about analysing data... My current work-flow: 1. Everyday my bosses give me some small steps/tasks for analysing data - which are parts of one bigger/whole project. 2. Everyday I send tens of emails to bosses/colleagues to report my findings in each step. 3. Bosses/colleagues often respond to my findings in real-time and suggest new experiments/steps and ask what-if questions. 4. I often have to manually copy and paste the results from R console and put them into an Excel and decorate a bit and send out. 5. Every one week and 2 weeks, we need to present to more senior bosses with more nice-looking presentations which is a summary of our findings in those 1-2 weeks. It's this time that is most chaotic because my colleagues and I have to dig into all the hundreds of emails in the past 1-2 weeks and copy and paste and organize those data again and make a nice overall summary for presentation... 6. As I am a hard-working guy, I myself often run my own random/ad-hoc experiments using out-of-work time and whenever I have interesting findings, I will send to immediate bosses and colleagues to seek their comments. 7. All these experiments are in fact variations of different versions/ideas of one big/whole project. Lets say in one big project bosses/colleagues and I have come up with a few big ideas, then we have a few sub-projects: MyProjectIdea1 MyProjectIdea2 ... MyProjectIdeaN And each idea has a few variations, mostly are for answering what-if questions by varying the parameters here and there ... For example: MyProjectIdea1_Variation1_WhatIfParam1ChangedTo1.2? ... ... etc. 8. Most experiments run tens of minutes to many hours... and some of them have to run on Linux, and some others can be run on Windows. Fortunately we have universal paths accessible on both Windows and Linux, so those won't be problem... 9. Because of the time-consuming nature of these experiments, I also save the images as rData whenever I can. However, it's necessary to keep track of the context where these data were generated. Otherwise even the records of these images won't help recall the scenario we have run... --- Keeping track of these changes and all kinds of what-ifs now becomes increasingly a problem for me. Some times in order to respond to a query, although I have done it before already, but because I didn't keep record and save the result, or even though I have saved the memory image yet I am not completely sure about the cleanness of the results/data,I have to redo it and wait for another few hours. Is there a way that I can manage these whole processes better and be more productive? I have been digging and thinking about this for while and I guess Sweave is the right way to go? The problem for Sweave is that it's hard to make Latex generated pdf appealing to business managers... so if I keep records in Sweave/Latex for my own record/benefit (that's already a big benefit)... I still need to somehow manually copy/paste the data from Sweave/Latex/pdf into Word/Excel/Powerpoint in order to make a nice presentation... I know there are some Open Office and Word version of Sweave... the problem is that I couldn't find many demonstrations on these topics and my question is: are they good and can they fulfill what we needed? Your thoughts are greatly appreciated! Thanks a lot! [[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] rep() inside of lm()?
Hi Isaac, This is my best understanding of what you are after. A small worked example would have been helpful (even if you had to manually write the code, we would at least have a 'gold standard' for what we were trying to automate to take lists of arbitrary size). This is not necessarily an efficient solution, but it is relatively simple and efficiency can be dealt with later if this is in fact what you are trying to do. I tried to write it up in words, but that just ended up being confusing, so hopefully this code is comprehendable: ## sample data ## an outer list of arbitrary length, each element of which ## is itself a list of arbitrary length each element of which ## is a numeric vector set.seed(1) newlist - lapply(seq.int(sample(9, 1)), FUN = function(n) { lapply(seq.int(sample(5, 1)), function(k) rnorm(100)) }) str(newlist) ## you want all possible combinations choosing ## one element at a time from each element of newlist ## this is the index of which elements to extract from ## each sublist of newlist index - expand.grid(sapply(newlist, seq_along)) ## create a list (length 20) each element of which ## is a matrix of the predictors tmp - lapply(1:nrow(index), function(i) { do.call(cbind, sapply(seq_along(newlist), function(j) { newlist[[j]][index[i, j]]})) }) y - 1:100 ## calculate all the regressions results - lapply(tmp, function(x) lm(y ~ x)) ## summary of the first one summary(results[[1]]) Cheers, Josh On Sun, Jan 1, 2012 at 6:13 AM, iliketurtles isaacm...@gmail.com wrote: HI all, I'm new to R. Say I have a multi-layered list called newlist. str(newlist) List of 2 $ :List of 5 ..$ : num [1:8088] NA 464 482 535 557 ... ..$ : num [1:8088, 1:2] NA 464 482 535 557 ... ..$ : num [1:8088, 1:3] NA 464 482 535 557 ... ..$ : num [1:8088, 1:4] NA 464 482 535 557 ... ..$ : num [1:8088, 1:5] NA 464 482 535 557 ... $ :List of 3 ..$ : num [1:8088] NA NA 1386 464 482 ... ..$ : num [1:8088] NA NA NA 1386 464 ... ..$ : num [1:8088] NA NA NA NA 1386 ... Let's say this list has 2 entries. i.e. length(newlist)=2. However, in my function this list can be any number of entries, 1 to N. I want to regress each newlist[[N]] in a multiple linear regression. The problem is I don't know how to make a non-character or a non-numeric repeat. So I'd want something like: #--- dumplist-list() for(a in 1:length(newlist[[1]])){ for(b in 1:length(newlist[[2]]){ for(terminal in 1:length(newlist[[length(newlist)]])){ dumlist[[..]]-lm(y~newlist[[1]][a] + newlist[[2]]][b] + ... + newlist[[N]][terminal]). }}} #--- and I want the above to adjust to whatever N is. I'm new to R so this kind of thing is very difficult. I'm experimenting with eval(), parse(), paste(), expression(), letters[] and other stuff but I'm not getting far and I would greatly appreciation any guidance. Thank you. - Isaac Research Assistant Quantitative Finance Faculty, UTS -- View this message in context: http://r.789695.n4.nabble.com/rep-inside-of-lm-tp4250712p4250712.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. -- 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] what's the command in R to completely clear the state of the console(including clearing up libraries, etc?)
Are there commands that can do more complete clean-up than rm(list=ls(all=T))? My understanding is that one only clears the variables... not functions/packages, etc... Thanks a lot! [[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] what's the command in R to completely clear the state of the console(including clearing up libraries, etc?)
On Jan 1, 2012, at 12:43 PM, Michael wrote: Are there commands that can do more complete clean-up than rm(list=ls(all=T))? My understanding is that one only clears the variables... not functions/packages, etc... Not exactly true. rm should remove any function you defined in your current session. You need to look at ?unloadNamespace ?detach ... in order to remove loaded packages. Thanks a lot! [[alternative HTML version deleted]] #--- just in case you were having difficulty finding it# PLEASE do read the posting guide http://www.R-project.org/posting-guide.html -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bmp() shifts the image (Windows XP)
On 12-01-01 9:05 AM, William Simpson wrote: When using bmp() under Windows XP, I find that the saved image is a shifted version of the correct image. Try this: The image() function isn't designed to be able to do pixel-level addressing, so it's not too surprising that some rounding error somewhere leads to this. You could look through the Windows graphics device code to fix it. However, if you really need pixel level addressing, you should be using raster objects. I don't know if someone has written code to output a .bmp file, but it's a very simple format, so it shouldn't be too hard, especially if you only need a limited range of pixel formats (e.g. grayscale). Duncan Murdoch n-5 fn-01.bmp x-matrix(runif(n*n),nrow=n) image(x,col=gray(0:255/255),axes=F,frame.plot=F) bmp(filename = fn,width = n, height = n, units = px) par(mar=c(0,0,0,0),pty=s) image(x,col=gray(0:255/255),axes=F,frame.plot=F) dev.off() The image 01.bmp is like this: 22 23 24 25 w 32 33 34 35 w 42 43 44 45 w 52 53 54 55 w w w w w w w Where 22 represents x[2,2], etc; w represents a white pixel. For my application, the image has to be .bmp format. The same shifting behaviour is seen for large values of n. It is not just due to the small n value. For my application, this shifting is important and has to be eliminated. Please help. On an unrelated note, I found out that the bmp() code is smart enough to write my image as 8-bit using a palette instead of 24-bit with 0:255 grey levels if the image being saved does not use all 256 grey levels. I would love to hear it if somebody knows a good way to make bmp() stupid and always save as 24-bit. My kludge, using 256x256 pixel images, is to tack on an extra row with grey levels 0:255. Then when displaying, I have to crop the image to get rid of that bogus row. Thanks very much for any help! Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] what's the command in R to completely clear the state of the console(including clearing up libraries, etc?)
My understanding is that one only clears the variables... not functions/packages, etc... Not exactly true. rm should remove any function you defined in your current session. You need to look at ?unloadNamespace ?detach ... in order to remove loaded packages. And read the caveats there. It's basically not possible to reset your R session to a completely clean slate. You're best off just starting a new one. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on Android
If the phone is rooted one could hypothetically install from Debian repositories where R is represented very comprehensively. I surmise this is more trouble than it's worth in a major way. If stranded on a desert island and getting R fully functional on Droid would save you, I'd advise looking for food; else be prepared to name your phone Wilson. Ken Hutchison On Jan 1, 2012, at 11:28 AM, David Winsemius dwinsem...@comcast.net wrote: On Jan 1, 2012, at 11:07 AM, David Winsemius wrote: On Jan 1, 2012, at 10:05 AM, Federico J. Villatoro wrote: Hello,I am new to this list. So new that you have not yet read the posting guide it appears. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Quick answer: Not yet (as such). Longer answer. Do a search: RSiteSearch(Android) A search query has been submitted to http://search.r-project.org The results page should open in your browser shortly The results does not include the prior discussions in rhelp, but if you change the settings on that page and rerun, you should get them. The Baron search site seems to record the fact that discussions on r-devel have occurred but fails to link to them properly, so this is an alternative strategy for the r-devel archive search: https://www.google.com/search?q=android+site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-devel%2Fhl=ennum=20 Unfortunately people are no using android in their domain names and the search includes headers, so about half of those hits are off-target. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] what's the command in R to completely clear the state of the console(including clearing up libraries, etc?)
okay thanks is there a way to programatically restart a new Console session? On Sun, Jan 1, 2012 at 12:55 PM, Hadley Wickham had...@rice.edu wrote: My understanding is that one only clears the variables... not functions/packages, etc... Not exactly true. rm should remove any function you defined in your current session. You need to look at ?unloadNamespace ?detach ... in order to remove loaded packages. And read the caveats there. It's basically not possible to reset your R session to a completely clean slate. You're best off just starting a new one. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ [[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] Is it possible to right align text in R graphics?
I don't know any language other than English, much less one written right-to-left, but a quick search shows that the RGtk2 package includes some support for such things. My gut reaction is that right-to-left support would be highly device dependent, and since devices often interact closely with the OS, that support could well be affected by choice of and configuration of OS. I recommend that your keep your mind open, and when someone indicates that your example works for them and shows OS/R version information to go along with that result (as recommended in the posting guide), you probably should respond with similar information since it appears to be relevant. On Sun, 1 Jan 2012, Tal Galili wrote: Hi Duncan, Thank you for your reply. I am also using Win 7. And I would be surprised if this would be different in any OS. I guess the answer is that there is no way for making text in a graph in R be right-to-left. Thanks again, and happy new year, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sun, Jan 1, 2012 at 5:34 AM, Duncan Mackay mac...@northnet.com.auwrote: Hi Tal I think it might be an OS problem whether it is a graphics as well I do not know. I Just copied and pasted the line into R and it seems ok OS win 7 version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 14.1 year 2011 month 12 day22 svn rev57956 language R version.string R version 2.14.1 (2011-12-22) Regards Regards Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email: home mac...@northnet.com.au At 02:52 30/12/2011, you wrote: Content-Type: text/plain Content-Disposition: inline Content-length: 796 Hello all, The following line of code includes a right-to-left language text, yet the R graphics engine displays it from left to right. One problem this causes is when there are parenthesis in the test, here is a basic example? plot(1:10, main = ??? ()) Is there a way to make sure the text is displayed from right to left? Many thanks for any suggestions, Tal Contact Details:--**--**--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) --**--** --** [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-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. __** 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. [[alternative HTML version deleted]] --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on Android
Hi Frederico, This may not be what you're looking for, but we setup RStudio Server ( http://www.rstudio.org/ ) on a Linux box and access it from our tablets through a web browser. Best, Tim -- Timothy P. Jurka Ph.D. Student Department of Political Science University of California, Davis www.timjurka.com On Jan 1, 2012, at 10:05 AM, Federico J. Villatoro wrote: Hello, I am new to this list. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Federico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on Android
It should be noted that there is an Octave/Matlab clone for Android out there (addi). It is not far fetched that someone given enough time, determination, a rooted phone (LG phones are better for that, stay away from SE if you want a rooted device) and Wilson :) could deploy R in the droid! Christos Argyropoulos From: vicvoncas...@gmail.com Date: Sun, 1 Jan 2012 14:10:36 -0500 To: dwinsem...@comcast.net CC: r-help@r-project.org Subject: Re: [R] R on Android If the phone is rooted one could hypothetically install from Debian repositories where R is represented very comprehensively. I surmise this is more trouble than it's worth in a major way. If stranded on a desert island and getting R fully functional on Droid would save you, I'd advise looking for food; else be prepared to name your phone Wilson. Ken Hutchison On Jan 1, 2012, at 11:28 AM, David Winsemius dwinsem...@comcast.net wrote: On Jan 1, 2012, at 11:07 AM, David Winsemius wrote: On Jan 1, 2012, at 10:05 AM, Federico J. Villatoro wrote: Hello,I am new to this list. So new that you have not yet read the posting guide it appears. I have ben wondering if there is an app to run R on mobile devices? Specially android...Thanks in advance Quick answer: Not yet (as such). Longer answer. Do a search: RSiteSearch(Android) A search query has been submitted to http://search.r-project.org The results page should open in your browser shortly The results does not include the prior discussions in rhelp, but if you change the settings on that page and rerun, you should get them. The Baron search site seems to record the fact that discussions on r-devel have occurred but fails to link to them properly, so this is an alternative strategy for the r-devel archive search: https://www.google.com/search?q=android+site%3Ahttps%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-devel%2Fhl=ennum=20 Unfortunately people are no using android in their domain names and the search includes headers, so about half of those hits are off-target. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. [[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] Is it possible to right align text in R graphics?
Tal, Plese look at this thread https://stat.ethz.ch/pipermail/r-help/2011-October/292786.html right justify right-axis tick values in lattice and see if the function provided by David Winsemius will work for you. I included it in the HH package as HH:::panel.axis.right Rich On Sun, Jan 1, 2012 at 2:35 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: I don't know any language other than English, much less one written right-to-left, but a quick search shows that the RGtk2 package includes some support for such things. My gut reaction is that right-to-left support would be highly device dependent, and since devices often interact closely with the OS, that support could well be affected by choice of and configuration of OS. I recommend that your keep your mind open, and when someone indicates that your example works for them and shows OS/R version information to go along with that result (as recommended in the posting guide), you probably should respond with similar information since it appears to be relevant. On Sun, 1 Jan 2012, Tal Galili wrote: Hi Duncan, Thank you for your reply. I am also using Win 7. And I would be surprised if this would be different in any OS. I guess the answer is that there is no way for making text in a graph in R be right-to-left. Thanks again, and happy new year, Tal Contact Details:--**--**--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) --**--** --** On Sun, Jan 1, 2012 at 5:34 AM, Duncan Mackay mac...@northnet.com.au wrote: Hi Tal I think it might be an OS problem whether it is a graphics as well I do not know. I Just copied and pasted the line into R and it seems ok OS win 7 version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 14.1 year 2011 month 12 day22 svn rev57956 language R version.string R version 2.14.1 (2011-12-22) Regards Regards Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email: home mac...@northnet.com.au At 02:52 30/12/2011, you wrote: Content-Type: text/plain Content-Disposition: inline Content-length: 796 Hello all, The following line of code includes a right-to-left language text, yet the R graphics engine displays it from left to right. One problem this causes is when there are parenthesis in the test, here is a basic example? plot(1:10, main = ??? ()) Is there a way to make sure the text is displayed from right to left? Many thanks for any suggestions, Tal Contact Details:--**--**--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) --**--** -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help 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/**http://www.r-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://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-helphttps://stat.ethz.ch/mailman/**listinfo/r-help 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/**http://www.r-project.org/** posting-guide.html 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]] --**--** --- 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
Re: [R] R report generator (for Word)?
Hi Michael, I like Sweave and LaTeX, but I can appreciate the difficulty using it with collaborators. What about something similar using HTML? Certainly integrates to any webpages nicely. There are two packages I think do this nicely, one is the R2HTML package (on CRAN). Another one that is not on CRAN yet, but I think has a lot of potential is the knitr package. You can find it on github. I am not personally familiar with any good ways to integrate R with MS Office products. Cheers, Josh On Sun, Jan 1, 2012 at 7:50 AM, Michael comtech@gmail.com wrote: Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? My work is about analysing data... My current work-flow: 1. Everyday my bosses give me some small steps/tasks for analysing data - which are parts of one bigger/whole project. 2. Everyday I send tens of emails to bosses/colleagues to report my findings in each step. 3. Bosses/colleagues often respond to my findings in real-time and suggest new experiments/steps and ask what-if questions. 4. I often have to manually copy and paste the results from R console and put them into an Excel and decorate a bit and send out. 5. Every one week and 2 weeks, we need to present to more senior bosses with more nice-looking presentations which is a summary of our findings in those 1-2 weeks. It's this time that is most chaotic because my colleagues and I have to dig into all the hundreds of emails in the past 1-2 weeks and copy and paste and organize those data again and make a nice overall summary for presentation... 6. As I am a hard-working guy, I myself often run my own random/ad-hoc experiments using out-of-work time and whenever I have interesting findings, I will send to immediate bosses and colleagues to seek their comments. 7. All these experiments are in fact variations of different versions/ideas of one big/whole project. Lets say in one big project bosses/colleagues and I have come up with a few big ideas, then we have a few sub-projects: MyProjectIdea1 MyProjectIdea2 ... MyProjectIdeaN And each idea has a few variations, mostly are for answering what-if questions by varying the parameters here and there ... For example: MyProjectIdea1_Variation1_WhatIfParam1ChangedTo1.2? ... ... etc. 8. Most experiments run tens of minutes to many hours... and some of them have to run on Linux, and some others can be run on Windows. Fortunately we have universal paths accessible on both Windows and Linux, so those won't be problem... 9. Because of the time-consuming nature of these experiments, I also save the images as rData whenever I can. However, it's necessary to keep track of the context where these data were generated. Otherwise even the records of these images won't help recall the scenario we have run... --- Keeping track of these changes and all kinds of what-ifs now becomes increasingly a problem for me. Some times in order to respond to a query, although I have done it before already, but because I didn't keep record and save the result, or even though I have saved the memory image yet I am not completely sure about the cleanness of the results/data,I have to redo it and wait for another few hours. Is there a way that I can manage these whole processes better and be more productive? I have been digging and thinking about this for while and I guess Sweave is the right way to go? The problem for Sweave is that it's hard to make Latex generated pdf appealing to business managers... so if I keep records in Sweave/Latex for my own record/benefit (that's already a big benefit)... I still need to somehow manually copy/paste the data from Sweave/Latex/pdf into Word/Excel/Powerpoint in order to make a nice presentation... I know there are some Open Office and Word version of Sweave... the problem is that I couldn't find many demonstrations on these topics and my question is: are they good and can they fulfill what we needed? Your thoughts are greatly appreciated! Thanks a lot! [[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.
Re: [R] Contingency tables example
On 12/28/2011 1:17 PM, David Winsemius wrote: Along those lines, Thompson's R accompaniment to Agresti's text on Categorical Data Analysis is simply wonderful: https://home.comcast.net/~lthompson221/SplusDiscrete.PDF It's not surprising that Agresti recommends it on the book's homepage: http://www.stat.ufl.edu/~aa/cda/cda.html However, I suspect the OP might be better off with Agresti's An Introduction to Categorical Data Analysis (2nd ed. 2007). So perhaps following the link on Agresti's page to the linked and website could be a first visit for worked R code examples. But when I followed that link I didn't find much that seemed appropriate for a beginner in R. Maybe looking at Friendly's website which was in the links at Bilder's site: http://www.datavis.ca/courses/grcat/ Actually, a better link is to my short course on Visualizing Categorical Data with SAS and R http://www.datavis.ca/courses/VCD/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 report generator (for Word)?
Look at the SWord package. It is available from rcom.univie.ac.at. It is the integration of R and Word similar to RExcel at the same site. Rich On Sun, Jan 1, 2012 at 3:31 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Michael, I like Sweave and LaTeX, but I can appreciate the difficulty using it with collaborators. What about something similar using HTML? Certainly integrates to any webpages nicely. There are two packages I think do this nicely, one is the R2HTML package (on CRAN). Another one that is not on CRAN yet, but I think has a lot of potential is the knitr package. You can find it on github. I am not personally familiar with any good ways to integrate R with MS Office products. Cheers, Josh On Sun, Jan 1, 2012 at 7:50 AM, Michael comtech@gmail.com wrote: Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? My work is about analysing data... My current work-flow: 1. Everyday my bosses give me some small steps/tasks for analysing data - which are parts of one bigger/whole project. 2. Everyday I send tens of emails to bosses/colleagues to report my findings in each step. 3. Bosses/colleagues often respond to my findings in real-time and suggest new experiments/steps and ask what-if questions. 4. I often have to manually copy and paste the results from R console and put them into an Excel and decorate a bit and send out. 5. Every one week and 2 weeks, we need to present to more senior bosses with more nice-looking presentations which is a summary of our findings in those 1-2 weeks. It's this time that is most chaotic because my colleagues and I have to dig into all the hundreds of emails in the past 1-2 weeks and copy and paste and organize those data again and make a nice overall summary for presentation... 6. As I am a hard-working guy, I myself often run my own random/ad-hoc experiments using out-of-work time and whenever I have interesting findings, I will send to immediate bosses and colleagues to seek their comments. 7. All these experiments are in fact variations of different versions/ideas of one big/whole project. Lets say in one big project bosses/colleagues and I have come up with a few big ideas, then we have a few sub-projects: MyProjectIdea1 MyProjectIdea2 ... MyProjectIdeaN And each idea has a few variations, mostly are for answering what-if questions by varying the parameters here and there ... For example: MyProjectIdea1_Variation1_WhatIfParam1ChangedTo1.2? ... ... etc. 8. Most experiments run tens of minutes to many hours... and some of them have to run on Linux, and some others can be run on Windows. Fortunately we have universal paths accessible on both Windows and Linux, so those won't be problem... 9. Because of the time-consuming nature of these experiments, I also save the images as rData whenever I can. However, it's necessary to keep track of the context where these data were generated. Otherwise even the records of these images won't help recall the scenario we have run... --- Keeping track of these changes and all kinds of what-ifs now becomes increasingly a problem for me. Some times in order to respond to a query, although I have done it before already, but because I didn't keep record and save the result, or even though I have saved the memory image yet I am not completely sure about the cleanness of the results/data,I have to redo it and wait for another few hours. Is there a way that I can manage these whole processes better and be more productive? I have been digging and thinking about this for while and I guess Sweave is the right way to go? The problem for Sweave is that it's hard to make Latex generated pdf appealing to business managers... so if I keep records in Sweave/Latex for my own record/benefit (that's already a big benefit)... I still need to somehow manually copy/paste the data from Sweave/Latex/pdf into Word/Excel/Powerpoint in order to make a nice presentation... I know there are some Open Office and Word version of Sweave... the problem is that I couldn't find many demonstrations on these topics and my question is: are they good and can they fulfill what we needed? Your thoughts are greatly appreciated! Thanks a lot! [[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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles
[R] How to pass in a list of variables as an argument to a function?
Hello, I have some code that currently works fine and I am endeavoring to convert the major pieces of it into functions. This involves taking hard coded names of variables that are used in various places and figuring out how to abstract them out into functions where the arguments (i.e. a list of variables) can be passed to the parent function and used within that function for various purposes. Here is some code that comes close to replicating some of the cases I am trying to solve. Basically, the same list of variables comes up many times in the current code (where nothing is really a function). Now that I am converting everything to a function, I'd like to specify the list of variables once and use that list throughout the code in other places. The list of variables does not have to be of class = list. more generally, it could be any class that can be converted such that it is usable in paste(), aggregate() and reshape() as in the example below. I have tried various things to make it work.. using paste() and noquote() in combination to build a string that is identical to the arguments that these functions accept, however R interprets them as a string, not as individual arguments. Thanks in advance, Randall # # libraries used library(reshape) # create some data similar to use case myData = data.frame(expand.grid(varA=c(a, b, c), varB=c(d, e, f), varC=c(g, h, i), varD=c(old, new)), n=1000, fail=rbinom(2700,1000, 0.01)) # add in one more column myData$pass = myData$n-myData$fail # List of grouping vars. I would like to pass this object around and use it as arguments in functions myGroupVars = c(varA, varB, varC) # create a new column that is the combination of the grouping vars (used in plotting with lattice) # Question 1: Is there a way to replace varA, varB, varC in the function below with an object? myData = transform(myData, groupVar = paste(varA, varB, varC, sep = | )) # Sum the data by the same groupVars and two other variables # Question 2: Is there a way to replace varA + varB + varC in the function below and do the same aggregation? myDataSum - aggregate(cbind(pass, fail) ~ varA + varB + varC + groupVar + varD, data = myData, sum) # pivot the pass and fail quantity to one row per group, labelling them # Question 3: This one actually works. idvar happily accepted the vector of group vars. Better way? myDataSum - reshape(myDataSum, idvar = myGroupVars, v.names = c(pass, fail), timevar = varD, direction = wide) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] matrix position to list of coordinates
How can I extract a list of the positions in the matrix? A=matrix(1:8, nrow=2,ncol=4) A [,1] [,2] [,3] [,4] [1,]1357 [2,]2468 Something like this pos.A 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix position to list of coordinates
Here's one way: data.frame(rowID=as.vector(row(A)), colID=as.vector(col(A)), A=as.vector(A)) rowID colID A 1 1 1 1 2 2 1 2 3 1 2 3 4 2 2 4 5 1 3 5 6 2 3 6 7 1 4 7 8 2 4 8 You can sort that as desired. Sarah On Sun, Jan 1, 2012 at 5:21 PM, Ana rrast...@gmail.com wrote: How can I extract a list of the positions in the matrix? A=matrix(1:8, nrow=2,ncol=4) A [,1] [,2] [,3] [,4] [1,] 1 3 5 7 [2,] 2 4 6 8 Something like this pos.A 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] empty files created with trellis xyplot jpeg device
Thanks Michael. That did the trick. Despite googling most of the day yesterday, I didn't quite have the right search string to find that one. Almost feels like the answer was hiding in plain sight, now that you point me to it. I added some code to save the xyplots to a variable and then print it at the end of the function. before: xyplot(...) after: xyp-xyplot(...) print(xyp) Works great. Regards, -mike On Sun, Jan 1, 2012 at 1:40 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: I'm guessing R FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html The subtlety is that in an interactive session print is automatically called at the final evaluation of most everything, but you have to prompt it in interactive use (and depending on details, in some function calls) Michael Weylandt On Sat, Dec 31, 2011 at 6:50 PM, Mike Dahman mike.dah...@gmail.com wrote: New years greetings. I have been setting up a function to generate multiple jpeg charts. When the calls are issued at the interactive console, the jpeg files are generated without an issue. When I try to issue the same calls from a function, some chart files are empty. It appears to only be related to trellis charts. Any help to troubleshoot this is appreciated. Regards, -mike R version 2.14.0 (2011-10-31) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) # validate devices capabilities() jpeg png tifftcltk X11 aqua http/ftp sockets TRUEFALSEFALSEFALSE TRUEFALSE TRUE TRUE libxml fifo clediticonv NLS profmemcairo TRUE TRUE TRUE TRUE TRUEFALSEFALSE # Example functionality from the interactive console # I am going to use a zone variable to help duplicate the code in the function zone [1] isoranp-z1 # call a function to pull in data and assign it to a data frame testz-get_zonedata_url(2011,51,zone) # validate the data frame str(testz) 'data.frame': 2016 obs. of 14 variables: $ ts : Factor w/ 2016 levels 12/18/2011 00:00,..: 1 2 3 4 5 6 7 8 9 10 ... $ server : Factor w/ 1 level phx1npf4sn2: 1 1 1 1 1 1 1 1 1 1 ... $ zone : Factor w/ 1 level isoranp-z1: 1 1 1 1 1 1 1 1 1 1 ... $ pool : Factor w/ 1 level ORA-S1: 1 1 1 1 1 1 1 1 1 1 ... $ cpucap : num 4 4 4 4 4 4 4 4 4 4 ... $ memcap : int 26 26 26 26 26 26 26 26 26 26 ... $ swapcap: int 26 26 26 26 26 26 26 26 26 26 ... $ cpu: num 78.2 206.8 198.4 366.4 112.1 ... $ poolsz : int 42 42 42 42 42 42 42 42 42 42 ... $ mem: num 75.5 75.3 75.6 74.5 74.3 ... $ swp: num 80.2 80.1 79.6 79 78.9 ... $ dates : chr 12/18/2011 12/18/2011 12/18/2011 12/18/2011 ... $ times : chr 00:00:00 00:05:00 00:10:00 00:15:00 ... $ dt :Classes 'chron', 'dates', 'times' atomic [1:2016] 15326 15326 15326 15326 15326 ... .. ..- attr(*, format)= chr [1:2] m/d/y h:m:s .. ..- attr(*, origin)= Named num [1:3] 1 1 1970 .. .. ..- attr(*, names)= chr [1:3] month day year # set up a jpeg device trellis.device(jpeg,file=paste(charts/,zone,.zone_util.jpg,sep=)) # call a function to generate the chart # the plot_zone_util function uses xyplot plot_zone_util(testz) #close the device dev.off() The jpeg file is generated as expected: (User and group has been removed) ls -l isoranp-z1.zone_util.jpg -rw-rw-r-- 1 32123 Dec 31 16:13 isoranp-z1.zone_util.jpg # here is the plot_zone_util function for reference plot_zone_util - function(zone_df){ xyplot(cpu~dt|server,data=zone_df,ylim=c(0,100), main=paste(zone_df$zone[1], CPU (Blue) Memory (Red) Util\n,zone_df$ts[1],-,zone_df$ts[nrow(zone_df)],sep=), xlab=date, ylab=utilization (%), panel=function(x,y,subscripts){ panel.lines(x,y) panel.lines(zone_df$dt[subscripts],zone_df$mem[subscripts],col=red) }, as.Table=T, subscripts=T) } ## # Try and do the same thing within a function::: gen_zone_charts(zone,2011,51) # Note the zone_util.jpg file is zero length. It is a lattice chart. The other two charts generate ok. User and group has been removed. -rw-rw-r-- 1 22376 Dec 31 16:20 isoranp-z1.zone_cpu.jpg -rw-rw-r-- 1 18910 Dec 31 16:20 isoranp-z1.zone_mem.jpg -rw-rw-r-- 1 0 Dec 31 16:20 isoranp-z1.zone_util.jpg # here is the gen_zone_charts function: gen_zone_charts function(zone,year,wk){ data_frame-get_zonedata_url(year,wk,zone) # this results in a 0 length file # i have tried using jpeg(), and trellis.device() with the same results #jpeg(file=paste(charts/,zone,.zone_util.jpg,sep=)) trellis.device(jpeg,file=paste(charts/,zone,.zone_util.jpg,sep=)) #uses xyplot - works fine being
Re: [R] Histogram omitting/collapsing groups
This is helpful, although I can't seem to adapt it to my own data. If I run your sample as is, I do get the nice graphs. However, this doesn't work: (Assume you already have a data frame dallas with 2057980 rows. It has column offense_hour, and each row has a value between 0 and 23, inclusive.) p - ggplot(as.data.frame(table(dallas$offense_hour)), aes(x = dallas$offense_hour, y = Freq)) + geom_bar() print(p) Error in data.frame(x = c(9, 8, 10, 9, 10, 15, 11, 13, 0, 16, 13, 20, : arguments imply differing number of rows: 2057980, 24 Seems like dallas$offense_hour corresponds to x in your example. I'm confused why yours works even though your x has 10,000 values, yet mine fails complaining that the row count is way off. Either way, the length of x or dallas$offense_hour grossly exceeds 24. Aren On Sun, Jan 1, 2012 at 10:34 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Aren, I was busy thinking about how to make what you wanted, and I missed that you were working with hours from a day. That being the case, you may think about a circular graph. The attached plots show two different ways of working with the same data. Cheers, Josh set.seed(10) x - sample(0:23, 1, TRUE, prob = sin(0:23)+1) require(ggplot2) # graphing package ## regular barplot p - ggplot(as.data.frame(table(x)), aes(x = x, y = Freq)) + geom_bar() ## using circular coordinates p2 - p + coord_polar() ## print them print(p) print(p2) ## just if you're interested, the code to ## put the two plots side by side require(grid) dev.new(height = 6, width = 12) grid.newpage() pushViewport(vpList( viewport(x = 0, width = .5, just = left, name = barplot), viewport(x = .5, width = .5, just = left, name=windrose))) seekViewport(barplot) grid.draw(ggplotGrob(p)) seekViewport(windrose) grid.draw(ggplotGrob(p2)) On Sun, Jan 1, 2012 at 7:59 AM, Aren Cambre a...@arencambre.com wrote: On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard pda...@gmail.com wrote: Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Thanks, everybody. I'll definitely switch to barplot. As for continuous, it's all relative. Even the most continuous dataset at a scale that looks pretty to humans may have gaps between the values when you zoom in a lot. Aren -- 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.
Re: [R] How to pass in a list of variables as an argument to a function?
Hi Randall, This will do it. There may be more elegant ways. Formula methods are just handy front ends (e.g., stats:::aggregate.formula), that end up dispatching to other methods usually. It is easy to pass a character vector to extractor functions like `[`() so with a bit more typing, you can often skip the formula altogether. I think that will be the easiest approach if you are not actually typing the formula (there are ways to create them, but bleh). Cheers, Josh ### # libraries used library(reshape) # create some data similar to use case myData = data.frame(expand.grid(varA=c(a, b, c), varB=c(d, e, f), varC=c(g, h, i), varD=c(old, new)), n=1000, fail=rbinom(2700,1000, 0.01)) # add in one more column myData$pass = with(myData, n - fail) # List of grouping vars. I would like to pass this object around and use it as arguments in functions myGroupVars = c(varA, varB, varC) # create a new column that is the combination of the grouping vars (used in plotting with lattice) # Question 1: Is there a way to replace varA, varB, varC in the function below with an object? myData2 - transform(myData, groupVar = do.call(paste, c(myData[, myGroupVars], sep = | ))) myData = transform(myData, groupVar = paste(varA, varB, varC, sep = | )) all.equal(myData, myData2) # Sum the data by the same groupVars and two other variables # Question 2: Is there a way to replace varA + varB + varC in the function below and do the same aggregation? myDataSum = aggregate(cbind(pass, fail) ~ varA + varB + varC + groupVar + varD, data = myData, sum) myDataSum2 - aggregate(x = myData2[, c(pass, fail)], by = myData2[, c(myGroupVars, groupVar, varD)], FUN = sum) all.equal(myDataSum, myDataSum2) # pivot the pass and fail quantity to one row per group, labelling them # Question 3: This one actually works. idvar happily accepted the vector of group vars. Better way? myDataSum - reshape(myDataSum, idvar = myGroupVars, v.names = c(pass, fail), timevar = varD, direction = wide) # On Sun, Jan 1, 2012 at 11:58 AM, Randall Goodwin randall.good...@gmail.com wrote: Hello, I have some code that currently works fine and I am endeavoring to convert the major pieces of it into functions. This involves taking hard coded names of variables that are used in various places and figuring out how to abstract them out into functions where the arguments (i.e. a list of variables) can be passed to the parent function and used within that function for various purposes. Here is some code that comes close to replicating some of the cases I am trying to solve. Basically, the same list of variables comes up many times in the current code (where nothing is really a function). Now that I am converting everything to a function, I'd like to specify the list of variables once and use that list throughout the code in other places. The list of variables does not have to be of class = list. more generally, it could be any class that can be converted such that it is usable in paste(), aggregate() and reshape() as in the example below. I have tried various things to make it work.. using paste() and noquote() in combination to build a string that is identical to the arguments that these functions accept, however R interprets them as a string, not as individual arguments. Thanks in advance, Randall # # libraries used library(reshape) # create some data similar to use case myData = data.frame(expand.grid(varA=c(a, b, c), varB=c(d, e, f), varC=c(g, h, i), varD=c(old, new)), n=1000, fail=rbinom(2700,1000, 0.01)) # add in one more column myData$pass = myData$n-myData$fail # List of grouping vars. I would like to pass this object around and use it as arguments in functions myGroupVars = c(varA, varB, varC) # create a new column that is the combination of the grouping vars (used in plotting with lattice) # Question 1: Is there a way to replace varA, varB, varC in the function below with an object? myData = transform(myData, groupVar = paste(varA, varB, varC, sep = | )) # Sum the data by the same groupVars and two other variables # Question 2: Is there a way to replace varA + varB + varC in the function below and do the same aggregation? myDataSum - aggregate(cbind(pass, fail) ~ varA + varB + varC + groupVar + varD, data = myData, sum) # pivot the pass and fail quantity to one row per group, labelling them # Question 3: This one actually works. idvar happily accepted the vector of group vars. Better way? myDataSum - reshape(myDataSum, idvar = myGroupVars, v.names = c(pass, fail), timevar = varD, direction = wide) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,
Re: [R] matrix position to list of coordinates
Hi Ana, most probably this is one of the more ugly solutions: d=dim(A) d [1] 2 4 cbind(rep(1:d[1], each=d[2]), rep(1:d[2], d[1])) [,1] [,2] [1,]11 [2,]12 [3,]13 [4,]14 [5,]21 [6,]22 [7,]23 [8,]24 Thanks, wr * Ana rrast...@gmail.com [2012-01-01 23:21:12 +0100]: How can I extract a list of the positions in the matrix? A=matrix(1:8, nrow=2,ncol=4) A [,1] [,2] [,3] [,4] [1,]1357 [2,]2468 Something like this pos.A 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram omitting/collapsing groups
Sorry, that was probably a really confusing example...too many xs floating around. set.seed(10) rawdata - sample(0:23, 1, TRUE, prob = sin(0:23)+1) ## do theis step first for your data tableddata - as.data.frame(table(rawdata)) ## use these names in ggplot colnames(tableddata) require(ggplot2) p - ggplot(tableddata, aes(x = rawdata, y = Freq)) + geom_bar() Cheers, Josh On Sun, Jan 1, 2012 at 2:36 PM, Aren Cambre a...@arencambre.com wrote: This is helpful, although I can't seem to adapt it to my own data. If I run your sample as is, I do get the nice graphs. However, this doesn't work: (Assume you already have a data frame dallas with 2057980 rows. It has column offense_hour, and each row has a value between 0 and 23, inclusive.) p - ggplot(as.data.frame(table(dallas$offense_hour)), aes(x = dallas$offense_hour, y = Freq)) + geom_bar() print(p) Error in data.frame(x = c(9, 8, 10, 9, 10, 15, 11, 13, 0, 16, 13, 20, : arguments imply differing number of rows: 2057980, 24 Seems like dallas$offense_hour corresponds to x in your example. I'm confused why yours works even though your x has 10,000 values, yet mine fails complaining that the row count is way off. Either way, the length of x or dallas$offense_hour grossly exceeds 24. Aren On Sun, Jan 1, 2012 at 10:34 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Aren, I was busy thinking about how to make what you wanted, and I missed that you were working with hours from a day. That being the case, you may think about a circular graph. The attached plots show two different ways of working with the same data. Cheers, Josh set.seed(10) x - sample(0:23, 1, TRUE, prob = sin(0:23)+1) require(ggplot2) # graphing package ## regular barplot p - ggplot(as.data.frame(table(x)), aes(x = x, y = Freq)) + geom_bar() ## using circular coordinates p2 - p + coord_polar() ## print them print(p) print(p2) ## just if you're interested, the code to ## put the two plots side by side require(grid) dev.new(height = 6, width = 12) grid.newpage() pushViewport(vpList( viewport(x = 0, width = .5, just = left, name = barplot), viewport(x = .5, width = .5, just = left, name=windrose))) seekViewport(barplot) grid.draw(ggplotGrob(p)) seekViewport(windrose) grid.draw(ggplotGrob(p2)) On Sun, Jan 1, 2012 at 7:59 AM, Aren Cambre a...@arencambre.com wrote: On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard pda...@gmail.com wrote: Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Thanks, everybody. I'll definitely switch to barplot. As for continuous, it's all relative. Even the most continuous dataset at a scale that looks pretty to humans may have gaps between the values when you zoom in a lot. Aren -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ -- 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] Lattice: Understanding How Points Connected by Lines
A data frame has one factor, one date, and one numeric column. When I plot these using the default pch of the open circle (first attachment), xyplot(TDS ~ sampdate | she.s, data = sheep.cast, main = 'TDS in Sheep Creek', ylab = 'Concentration (mg/L)', xlab = 'Time') I see the higher concentration points toward the right on several panels. But, when I change to using a line type (second attachment), xyplot(TDS ~ sampdate | she.s, data = sheep.cast, type = 'l', main = 'TDS in Sheep Creek', ylab = 'Concentration (mg/L)', xlab = 'Time') the higher concentrations are connected to points far to the left (earlier years). I expected to see a line with a few spikes toward the right sides of the panels. Where do I start to look for the reason for this behavior? TIA, Rich sheep-TDS-year-dot.pdf Description: Adobe PDF document sheep-TDS-year-line.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice: Understanding How Points Connected by Lines
On Sun, 1 Jan 2012, Rich Shepard wrote: Where do I start to look for the reason for this behavior? Perhaps the dates are not in sequence? So I need to use zoo to order the dates sequentially? Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice: Understanding How Points Connected by Lines
On Jan 1, 2012, at 5:50 PM, Rich Shepard wrote: A data frame has one factor, one date, and one numeric column. When I plot these using the default pch of the open circle (first attachment), xyplot(TDS ~ sampdate | she.s, data = sheep.cast, main = 'TDS in Sheep Creek', ylab = 'Concentration (mg/L)', xlab = 'Time') I see the higher concentration points toward the right on several panels. But, when I change to using a line type (second attachment), xyplot(TDS ~ sampdate | she.s, data = sheep.cast, type = 'l', main = 'TDS in Sheep Creek', ylab = 'Concentration (mg/L)', xlab = 'Time') the higher concentrations are connected to points far to the left (earlier years). I expected to see a line with a few spikes toward the right sides of the panels. Where do I start to look for the reason for this behavior? You should look at the structure of your dataset variables and the order in which they occur ... none of which is visible in what you have offered. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rep() inside of lm()?
Josh, you've solved the problem, fantastic. Thanks for as.formula() David, that will be of great use in my work. Next time I'll provide better examples. Thanks for your help all. - Isaac Research Assistant Quantitative Finance Faculty, UTS -- View this message in context: http://r.789695.n4.nabble.com/rep-inside-of-lm-tp4250712p4251789.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram omitting/collapsing groups
Thanks. That did it! And I get it now--in your original example, aes(x = x, y = Freq), x refers to the column name in as.data.frame(table(x)), not the x vector(?) you created. Aren On Sun, Jan 1, 2012 at 4:44 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Sorry, that was probably a really confusing example...too many xs floating around. set.seed(10) rawdata - sample(0:23, 1, TRUE, prob = sin(0:23)+1) ## do theis step first for your data tableddata - as.data.frame(table(rawdata)) ## use these names in ggplot colnames(tableddata) require(ggplot2) p - ggplot(tableddata, aes(x = rawdata, y = Freq)) + geom_bar() Cheers, Josh On Sun, Jan 1, 2012 at 2:36 PM, Aren Cambre a...@arencambre.com wrote: This is helpful, although I can't seem to adapt it to my own data. If I run your sample as is, I do get the nice graphs. However, this doesn't work: (Assume you already have a data frame dallas with 2057980 rows. It has column offense_hour, and each row has a value between 0 and 23, inclusive.) p - ggplot(as.data.frame(table(dallas$offense_hour)), aes(x = dallas$offense_hour, y = Freq)) + geom_bar() print(p) Error in data.frame(x = c(9, 8, 10, 9, 10, 15, 11, 13, 0, 16, 13, 20, : arguments imply differing number of rows: 2057980, 24 Seems like dallas$offense_hour corresponds to x in your example. I'm confused why yours works even though your x has 10,000 values, yet mine fails complaining that the row count is way off. Either way, the length of x or dallas$offense_hour grossly exceeds 24. Aren On Sun, Jan 1, 2012 at 10:34 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Aren, I was busy thinking about how to make what you wanted, and I missed that you were working with hours from a day. That being the case, you may think about a circular graph. The attached plots show two different ways of working with the same data. Cheers, Josh set.seed(10) x - sample(0:23, 1, TRUE, prob = sin(0:23)+1) require(ggplot2) # graphing package ## regular barplot p - ggplot(as.data.frame(table(x)), aes(x = x, y = Freq)) + geom_bar() ## using circular coordinates p2 - p + coord_polar() ## print them print(p) print(p2) ## just if you're interested, the code to ## put the two plots side by side require(grid) dev.new(height = 6, width = 12) grid.newpage() pushViewport(vpList( viewport(x = 0, width = .5, just = left, name = barplot), viewport(x = .5, width = .5, just = left, name=windrose))) seekViewport(barplot) grid.draw(ggplotGrob(p)) seekViewport(windrose) grid.draw(ggplotGrob(p2)) On Sun, Jan 1, 2012 at 7:59 AM, Aren Cambre a...@arencambre.com wrote: On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard pda...@gmail.com wrote: Exactly. If what you want is a barplot, make a barplot; histograms are for continuous data. Just remember that you may need to set the levels explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). (This is irrelevant with 100K data samples, but not with 100 of them). That being said, the fact that hist() tends to create breakpoints which coincide with data points due to discretization is arguably a bit of a design error, but it is age-old and hard to change now. One way out is to use truehist() from MASS, another is to explicitly set the breaks to intermediate values, as in hist(x, breaks=seq(-.5, 23.5, 1)) Thanks, everybody. I'll definitely switch to barplot. As for continuous, it's all relative. Even the most continuous dataset at a scale that looks pretty to humans may have gaps between the values when you zoom in a lot. Aren -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ -- 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.
Re: [R] R report generator (for Word)?
Dear Michael, On Sun, Jan 1, 2012 at 10:50 AM, Michael comtech@gmail.com wrote: Happy New Year all! [snip] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Nobody's yet mentioned that the latest version of Emacs Org mode (http://orgmode.org/) ships with an ODT (OpenDocument Text) exporter. This means that a person can now use the same single plain text file to integrate R code (and/or 30+ other languages) to process: - HTML: C-c C-e h- LaTeX: C-c C-e l- PDF: C-c C-e p (via pdflatex)- ODT: C-c C-e o- ...etc. You get syntax highlighting, integrated math formulae, code tangling,... there's even an elementary table editor for simple spreadsheet operations. And again, all exported formats originate from the same plain text file. MS-Word can definitely read HTML, and when I last checked (long ago) there existed plugins for MS_Word to read .odt. Of course, LibreOffice can convert ODT (and HTML) to MS-Word if necessary. GoogleDocs does an OK job converting back and forth, too, and if this option is available to you there are some pretty cool Google collaborative tools. On the flipside, Emacs in general is a tough pill to swallow, and that's an understatement. Two parting thoughts:1) Org mode is similar to, but not identical with, Sweave.2) Org mode originated as an organization/outlining tool, so it has all sorts of tricks for Getting Things Done, such as TODO lists, agendas, capturing-archiving, calendar integration, time tracking,... These could possibly address some of the other issues you mentioned. Good luck, and Happy New Year.Jay * G. Jay Kerns, Ph.D. Mathematics and Statistics Youngstown State University http://people.ysu.edu/~gkerns/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Reading mcmc/coda into a big.matrix efficiently
I'm trying to read CODA/mcmc files (see the coda package), as generated by jags/WinBUGS/OpenBUGS, into a big.matrix.I can't load the whole mcmc object produced by read.coda() into memory since I'm using a laptop for this analysis (currently I'm unfunded). Right now I'm doing it by creating the filebacked.big.matrix, reading a chunk of data at a time from the chain file using read.table() with skip and nrows set, and storing it into the big.matrix. While this is memory efficient, the processing overhead seems be related to the size of the skip value, so that the time required is proportionate to the number of variables. Any tips on how to do this faster / more efficiently? I'm using a unix system, so a solution that uses grep/sed Here's some sample code of how I do it now: index = read.table(Big.CODAindex.txt, col.names = c(var,start,end)) n = index[1,3] - index[1,2] + 1 k = dim(index)[1] X = filebacked.big.matrix( nrow = n, ncol = k, backingfile = Big.CODA.backing) for(i in 1:k) { X[,i] = read.table(Big.CODAchain1.txt, skip = (i-1)*n, nrows = n)[,2] print(i) print(Sys.time()) } Also, here are the first few rows of the index and chain files, so you can see the formatting. The index file tells you each variable's name and the range or rows in the chain file containing the variable's values. The chain file contains the iteration number the value was taken from, and CODAindex.txt egu[1] 1 1 egu[2] 10001 2 egt[1] 20001 3 egt[2] 30001 4 ept[1] 40001 5 ept[2] 50001 6 ... CODAchain1.txt 10001 -0.289963 10011 -0.310657 10021 -0.290596 10031 -0.286273 10041 -0.319877 10051 -0.299019 Thanks in advance for any tips! --Guy W. Cole R version 2.14.0 (2011-10-31) x86_64-apple-darwin9.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gam() (in mgcv) with multiple interactions
Dear Simon, I have the same problem. I understand te(a), te(b) are nested in te(a,b) according to your paper on tensor product. I have no enough data to perform te(a,b,d) and only care the interactions a*b and a*d, so I did y=te(a,b)+te(a,d). The resutl is good. I am wondering if this is the correct way to do in mgcv? How does mgcv handle the a in both /te/ terms? Thanks. Best regards, Chuan Yan -- View this message in context: http://r.789695.n4.nabble.com/gam-in-mgcv-with-multiple-interactions-tp3580036p4252197.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] How to get cov matrix of regression parameters in GEE using 'geese' or 'geeglm''
Dear R users, I fitted a GEE model using the function 'geese' (or 'geeglm') with user defined correlation matrix. I want to get the var-cov matrix of the regression coefficients. But the output provides only limited information. I would be very much thankful if you could kindly let me know how to get it..since I am struggling lot getting this. Thanks -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-cov-matrix-of-regression-parameters-in-GEE-using-geese-or-geeglm-tp4252319p4252319.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading large sparse arff files into R
Hi folks, Any ideas on this? This does sound like a fairly common situation - reading in large data file into R? Thanks. Andy -- View this message in context: http://r.789695.n4.nabble.com/Reading-large-sparse-arff-files-into-R-tp4249409p4252393.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R report generator (for Word)?
On Sun, 1 Jan 2012 09:50:24 -0600 Michael comtech@gmail.com wrote: Happy New Year all! I am looking for a good solution for keeping record of my experiments - could you please help me? If you are working from scripts, which is a very good way to standardize procedures as a work flow and analysis develop, I would suggest checking sink() and cat(). Used properly these commands can be used to capture screen output to text files. These can then be opened and formatted in Word or Office or Emacs or ... I use this method to capture results of analyses of archaeological data. Use the device() command to capture graphics to jpeg files, pdfs or other graphic formats. If you develop a script of your analysis, you will have a file that will load data, carry out sequenced procedures, shoot the results to a text file designated in sink() or cat(), and the results can then be integrated into a word document. Curiously, there are not many books about R that explicitly address questions like capturing intermediate or final output from an analysis to usable text. The volumes I've found most useful are Modern Applied Statistics with S, R Cookbook, and R in Action (these are not ordered in order of usefulness). None go into anything like detail about the process of actually producing report-quality output (except figures), perhaps because the assumption is that the commands above will be used to capture the statistical output for a report, which will then dealt with externally to R. JWD __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rainbow function
hello: I am trying to use R to draw a 3D picture, then color the picture according to the value of z , how could I do this job? this is my exalple x-y-seq(-50,50,2) m-function(x,y) x^3+y^3-x^2*y-x*y^2 z-outer(x,y,m) persp(x,y,z,theta=-60,phi=30) I want to draw the Zmax in red and Zmin in blue, the value between Zmax and Zmin is colored gradually 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.
Re: [R] rainbow function
On Jan 2, 2012, at 1:31 AM, 王琦 wrote: hello: I am trying to use R to draw a 3D picture, then color the picture according to the value of z , how could I do this job? this is my exalple x-y-seq(-50,50,2) m-function(x,y) x^3+y^3-x^2*y-x*y^2 z-outer(x,y,m) persp(x,y,z,theta=-60,phi=30) I want to draw the Zmax in red and Zmin in blue, the value between Zmax and Zmin is colored gradually Have you looked at the help(persp) example # 4? thank you very much [[alternative HTML version deleted]] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.