Re: [R] plotting over a raster image with control over location and orientation
Hi,I havetried to find a simple way for my overlay plot. A simple summary of myapproach would to first plot the raster image and then overlay the second pot with : par(new=TRUE,plt=c(x1,x2,y1,y2)) # not sure if the plt or usr argument should be used# have some difficulty in knowing the units for x1,x2,y1 and y2 plot(1:10,1:10)#justan example plot But my problem is that I do not understand the unit conversions for graphics. What exactly are npc and native?Let me explain by starting with the code again:#Setting up the initial example raster image library(grid) x - y - c(-15,seq(-4*pi, 4*pi, len=27),15) r - sqrt(outer(x^2, y^2, +)) z - cos(r^2)*exp(-r/6) image - (z - min(z))/diff(range(z)) plot(x, y, ann=FALSE,xaxs=i, yaxs=i) rasterImage(image,xrange[1], yrange[1],xrange[2], yrange[2],interpolate=FALSE)# let's say that I want to draw an overlay plot with the follwing line as x-axis lines(c(-10,10),c(-12,-12),col=red,lwd=2) lim-par(usr) lim limplt-par(plt) limplt #convertX(unit(0:1,npc),native) convertX(unit(-10,native),npc) convertX(unit(10,native),npc) convertY(unit(-12,native),npc) lim-par(usr) lim [1] -15 15 -15 15 limplt-par(plt) limplt [1] 0.09132251 0.95322506 0.1800 0.85529412 #convertX(unit(0:1,npc),native) convertX(unit(-10,native),npc) [1] -0.0116009280742459npc convertX(unit(10,native),npc) [1] 0.0116009280742459npc convertY(unit(-12,native),npc) [1] 1.02205882352941npc These converted values and the values for the limplt variable do not seem to be in agreement. How do I convert, for example, the point (10,-12) to npc units? I hope that I have explained my problem sufficiently well. If I can get help with an approach involving viewports also, I would be grateful for any help that I can get. Thanks, Ravi From: ravi rv...@yahoo.se To: R-help r-help@r-project.org Sent: Friday, 21 August 2015, 16:30 Subject: plotting over a raster image with control over location and orientation Hi,I would like to get some help in plotting over an image. I have a png image over which I would like to have a plot. I would like to be able to control the location, area and orientation of the plot on the image. I have taken help from the following references :http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Murrell.pdfhttp://stackoverflow.com/questions/12918367/in-r-how-to-plot-with-a-png-as-background In order to give a reproducible example, I set up my image with the help of some code from the the first reference above. #Setting up the initial example raster image x - y - seq(-4*pi, 4*pi, len=27) r - sqrt(outer(x^2, y^2, +)) z - cos(r^2)*exp(-r/6) image - (z - min(z))/diff(range(z)) step - diff(x)[1] xrange - range(x) + c(-step/2, step/2) yrange - range(y) + c(-step/2, step/2) plot(x, y, ann=FALSE,xlim=xrange, ylim=yrange,xaxs=i, yaxs=i) rasterImage(image,xrange[1], yrange[1],xrange[2], yrange[2],interpolate=FALSE) # the explanation of my problem starts here # First, I want to mark out a particular line lines(c(10,10.5),c(-10.5,10),col=red,lwd=2) #In my problem, I have to locate these points graphically from the image calpoints - locator(n=2,type='p',pch=4,col='blue',lwd=2) # this gives the line corresponding to the x-axis for my overlay plot # I don't want the red line on my plot #the red line plotted earlier is just to show the example location newOrigin-calpoints[1] xLimit-calpoints[2]#xlimit marks the limit of the x-axis on the image# on this new line as the x-axis, I want to make a new plot# the y-axis should be perpendicular to the x-axis. I would like to be able to specify the width of coverage over the image#example xx-1:10 yy-xx^2 plot(xx,yy,xlim=range(xx),ylim=range(yy),col=blue,type=b,xlab=x,ylab=square of x) # I would prefer to have the image more transparent just under the x and y labels and axis labelsThanks, Ravi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting over a raster image with control over location and orientation
Hi,I am sorry for not having control checked the code before posting (in my earlier mail). I have done this now. I just have a simple question now. Why is the overlay plot (the final plot ) not falling into the intended position (as defined by the viewport vp2)?#Setting up the initial example raster image library(grid) x - y - c(-15,seq(-4*pi, 4*pi, len=27),15) r - sqrt(outer(x^2, y^2, +)) z - cos(r^2)*exp(-r/6) image - (z - min(z))/diff(range(z)) xrange - range(x) yrange - range(y) vp1-viewport(x = unit(0.5, npc), y = unit(0.5, npc), width = unit(1, npc), height = unit(1, npc), default.units = npc, just = c(left,bottom),name=vp1) pushViewport(vp1) plot(x, y, ann=FALSE,xlim=xrange, ylim=yrange,xaxs=i, yaxs=i) rasterImage(image,xrange[1], yrange[1],xrange[2], yrange[2],interpolate=FALSE) lines(c(-10,4),c(-12,-12),col=red,lwd=2) lim-par(usr) lim limplt-par(plt) limplt #par(new=TRUE,plt=c(limplt[1],limplt[2],limplt[3])) #convertX(unit(0:1,npc),native) x1-convertX(unit(-10,native),npc) x2-convertX(unit(5,native),npc) y1-convertY(unit(-12,native),npc) y2-convertY(unit(3,native),npc) wx-(5-(-10))/(15-(-15)) wy-(3-(-12))/(15-(-15)) xw-convertWidth(unit(wx,native),npc) yw-convertHeight(unit(wy,native),npc) vp2-viewport(x = unit(x1, npc), y = unit(y1, npc), width = unit(xw, npc), height = unit(yw, npc), default.units = npc, name=vp2) pushViewport(vp2) #data with a different scale xs-seq(0.01,0.1,0.01)ys-xs^2 #points(xs,ys,type='b',col='red',newpage=FALSE) plot(xs,ys,type='b',col='red') #fills the whole screen instead of just the intended viewport Thanks,Ravi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Date as Integer
Hi All, I am using dplyr package and need to find total bills booked grouped on a date level however my date is integer. In the code below i was trying to change date format from integer. However it is throwing an error: no applicable method for 'group_by_' applied to an object of class c('integer', 'numeric') ak%% group_by(as.Date(pickdate),%y%m%d)%% summarise(Total=count(waybill)) Do i need to create a new var first changing the date and then group it or as.Date will work as i added in dplyr. -- View this message in context: http://r.789695.n4.nabble.com/Date-as-Integer-tp4711377.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Multrix-vector multiplication
I had trouble with matrix multiplication when a matrix reduces to a vector. In the following, lines 1 and 2 work when matrices u and a are both of order 2. Lines 3 and 5 do not work (message is matrix not conformable) when u is (T x 1) and a is (1 x 2) and This causes a problem for users of other matrix languages such as Gauss and MATLAB. Inserting line 4 makes it work, which is annoying. But, is it proper/safe to make it work by inserting line 4? Other approaches? Thank you! 1 a-solve(s22)%*%s21 # (2 x 2) - (2 x 2) %*% (2 x 2) 2 uc-u%*%v$a # (T x 2) - (T x 2) %*% (2 x 2) 3 a-solve(s22)%*%s21 # (1 x 2) - (1 x 1) %*% (1 x 2) 4 a-as.matrix(a) # This line makes it work. OK? Other approaches? 5 uc-u%*%v$a # (T x 1) %*% (1 x 2) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Output In R
On Aug 22, 2015, at 8:49 AM, John Kane jrkrid...@inbox.com wrote: We are talking at cross-purposes here because SAS and R are radically different beasts. Just about everything you did in SAS does not work / is wrong / is illegal / is immoral / and possibly fattening. Fortune candidate! :-) Regards, Marc Schwartz If you have not seen it, you may find Bob Muenchen's pdf and/or the expanded book R FOR SAS AND SPSS USERS ( https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf ) useful. It is very easy to create the data set you want. You just need to think in R's somewhat twisted way. Well if twisted my mind for the first 6 weeks that I used it. Let's say you are doing some analysis. Don't send the data to the console. Instead save it in a R object (not sure if this is the correct term--I am sure the purists will correct me.) I am going to create a data.frame called dat1 (pretend it is your data). #create make-believe data dat1 - data.frame(matrix( rnorm(100), ncol = 5)) #Save dat1 as an R file. Handy for your work not great as a way #to pass around data unless the client knows R and has R installed save( dat1, file = ~/Rjunk/ mydata.RData) #Save as a .csv file. Fast easy and can be opened in any #text editor, spreadsheet or even a word processor. write.csv(dat1, file = ~/Rjunk/ mydata.csv) To produce a Latex file and get a pdf. One starts with a .Rnw (i.e. plain text with a .Rnw suffix) file and then compiles it. I used the command Rscript -e library(knitr); knit('./Shiv1.Rnw') where Shiv.Rnw was my LaTeX / knitr file. It is easier and faster to use RStudio for this. You will probably need to install the xtable package and depending in your LaTeX version you may need to install booktabs. Start Latex file### \documentclass[12pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{booktabs} \title{Magnum Opus Meum} \author{jrkrideau } \begin{document} \maketitle atable, echo=FALSE, results=asis= library(xtable) dat1 - data.frame(matrix( rnorm(100), ncol = 5)) dat1.table - xtable(dat1) print(dat1.table, include.rownames=FALSE, booktabs = TRUE) @ \end{document} End Latex file John Kane Kingston ON Canada -Original Message- From: shivibha...@ymail.com Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT) To: r-help@r-project.org Subject: Re: [R] Output In R Thanks Jeff, this is helpful. The reason i am curious to know this is because I have worked for a long duration in SAS where in it gives us the flexibility to create a data set of our analysis and then we can easily detail out the same to the end user. In R seems like View or Sweave or Shiny are the alternative. -- View this message in context: http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Output In R
Hi Shivi, A correction to my latex/knitr code. I stupidly forgot the initial problem was the length of the data set. To get it to print correctly we need to use the LaTeX package 'longtable'. Clearly too many trees for me to see the forest. Add \usepackage{longtable} to the Preamble. #==Revised code for knitr/R atable, echo=FALSE, results=asis= library(xtable) dat1 - data.frame(matrix( rnorm(2000), ncol = 5)) dat1.table - xtable(dat1) print(dat1.table,tabular.environment='longtable', floating = FALSE, include.rownames=FALSE, booktabs = TRUE) @ #==end=== John Kane Kingston ON Canada -Original Message- From: jrkrid...@inbox.com Sent: Sat, 22 Aug 2015 05:49:32 -0800 To: shivibha...@ymail.com, r-help@r-project.org Subject: Re: [R] Output In R We are talking at cross-purposes here because SAS and R are radically different beasts. Just about everything you did in SAS does not work / is wrong /i s illegal/ is immoral / and possibly fattening. If you have not seen it, you may find Bob Muenchen's pdf and/or the expanded book R FOR SAS AND SPSS USERS ( https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf ) useful. It is very easy to create the data set you want. You just need to think in R's somewhat twisted way. Well if twisted my mind for the first 6 weeks that I used it. Let's say you are doing some analysis. Don't send the data to the console. Instead save it in a R object (not sure if this is the correct term--I am sure the purists will correct me.) I am going to create a data.frame called dat1 (pretend it is your data). #create make-believe data dat1 - data.frame(matrix( rnorm(100), ncol = 5)) #Save dat1 as an R file. Handy for your work not great as a way #to pass around data unless the client knows R and has R installed save( dat1, file = ~/Rjunk/ mydata.RData) #Save as a .csv file. Fast easy and can be opened in any #text editor, spreadsheet or even a word processor. write.csv(dat1, file = ~/Rjunk/ mydata.csv) To produce a Latex file and get a pdf. One starts with a .Rnw (i.e. plain text with a .Rnw suffix) file and then compiles it. I used the command Rscript -e library(knitr); knit('./Shiv1.Rnw') where Shiv.Rnw was my LaTeX / knitr file. It is easier and faster to use RStudio for this. You will probably need to install the xtable package and depending in your LaTeX version you may need to install booktabs. Start Latex file### \documentclass[12pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{booktabs} \title{Magnum Opus Meum} \author{jrkrideau } \begin{document} \maketitle atable, echo=FALSE, results=asis= library(xtable) dat1 - data.frame(matrix( rnorm(100), ncol = 5)) dat1.table - xtable(dat1) print(dat1.table, include.rownames=FALSE, booktabs = TRUE) @ \end{document} End Latex file John Kane Kingston ON Canada -Original Message- From: shivibha...@ymail.com Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT) To: r-help@r-project.org Subject: Re: [R] Output In R Thanks Jeff, this is helpful. The reason i am curious to know this is because I have worked for a long duration in SAS where in it gives us the flexibility to create a data set of our analysis and then we can easily detail out the same to the end user. In R seems like View or Sweave or Shiny are the alternative. -- View this message in context: http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Date as Integer
Use mutate to change the date before you use group_by. Posting incomplete fragments in your questions is usually not enough to get useful help with R on the internet. Please add the extra few lines of code that would make it reproducible [1] from now on. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On August 22, 2015 12:43:05 AM PDT, Shivi82 shivibha...@ymail.com wrote: Hi All, I am using dplyr package and need to find total bills booked grouped on a date level however my date is integer. In the code below i was trying to change date format from integer. However it is throwing an error: no applicable method for 'group_by_' applied to an object of class c('integer', 'numeric') ak%% group_by(as.Date(pickdate),%y%m%d)%% summarise(Total=count(waybill)) Do i need to create a new var first changing the date and then group it or as.Date will work as i added in dplyr. -- View this message in context: http://r.789695.n4.nabble.com/Date-as-Integer-tp4711377.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Output In R
We are talking at cross-purposes here because SAS and R are radically different beasts. Just about everything you did in SAS does not work / is wrong /i s illegal/ is immoral / and possibly fattening. If you have not seen it, you may find Bob Muenchen's pdf and/or the expanded book R FOR SAS AND SPSS USERS ( https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf ) useful. It is very easy to create the data set you want. You just need to think in R's somewhat twisted way. Well if twisted my mind for the first 6 weeks that I used it. Let's say you are doing some analysis. Don't send the data to the console. Instead save it in a R object (not sure if this is the correct term--I am sure the purists will correct me.) I am going to create a data.frame called dat1 (pretend it is your data). #create make-believe data dat1 - data.frame(matrix( rnorm(100), ncol = 5)) #Save dat1 as an R file. Handy for your work not great as a way #to pass around data unless the client knows R and has R installed save( dat1, file = ~/Rjunk/ mydata.RData) #Save as a .csv file. Fast easy and can be opened in any #text editor, spreadsheet or even a word processor. write.csv(dat1, file = ~/Rjunk/ mydata.csv) To produce a Latex file and get a pdf. One starts with a .Rnw (i.e. plain text with a .Rnw suffix) file and then compiles it. I used the command Rscript -e library(knitr); knit('./Shiv1.Rnw') where Shiv.Rnw was my LaTeX / knitr file. It is easier and faster to use RStudio for this. You will probably need to install the xtable package and depending in your LaTeX version you may need to install booktabs. Start Latex file### \documentclass[12pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{booktabs} \title{Magnum Opus Meum} \author{jrkrideau } \begin{document} \maketitle atable, echo=FALSE, results=asis= library(xtable) dat1 - data.frame(matrix( rnorm(100), ncol = 5)) dat1.table - xtable(dat1) print(dat1.table, include.rownames=FALSE, booktabs = TRUE) @ \end{document} End Latex file John Kane Kingston ON Canada -Original Message- From: shivibha...@ymail.com Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT) To: r-help@r-project.org Subject: Re: [R] Output In R Thanks Jeff, this is helpful. The reason i am curious to know this is because I have worked for a long duration in SAS where in it gives us the flexibility to create a data set of our analysis and then we can easily detail out the same to the end user. In R seems like View or Sweave or Shiny are the alternative. -- View this message in context: http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Multrix-vector multiplication
The actual types of data you have are critical to understanding your problem, and you have not provided that information. [1] What looks like a matrix isn't always, and in R vectors do not have a column or row nature, so matrix multiplication is not necessarily well-defined. To get consistent results, make sure you actually are working with matrices rather than vectors, data frames or other data types. The str function is your friend. Please clarify what data you are actually working with using the dput as described in the link [1]. Also use plain text, as the HTML formatting in your email usually corrupts what you think you see by the time we see it. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On August 22, 2015 6:43:54 AM PDT, Steven Yen sye...@gmail.com wrote: I had trouble with matrix multiplication when a matrix reduces to a vector. In the following, lines 1 and 2 work when matrices u and a are both of order 2. Lines 3 and 5 do not work (message is matrix not conformable) when u is (T x 1) and a is (1 x 2) and This causes a problem for users of other matrix languages such as Gauss and MATLAB. Inserting line 4 makes it work, which is annoying. But, is it proper/safe to make it work by inserting line 4? Other approaches? Thank you! 1 a-solve(s22)%*%s21 # (2 x 2) - (2 x 2) %*% (2 x 2) 2 uc-u%*%v$a # (T x 2) - (T x 2) %*% (2 x 2) 3 a-solve(s22)%*%s21 # (1 x 2) - (1 x 1) %*% (1 x 2) 4 a-as.matrix(a) # This line makes it work. OK? Other approaches? 5 uc-u%*%v$a # (T x 1) %*% (1 x 2) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] fill color in boxplot and change number in scale
Data? Please use dput() John Kane Kingston ON Canada -Original Message- From: eladlaza...@gmail.com Sent: Fri, 21 Aug 2015 11:52:52 -0700 (PDT) To: r-help@r-project.org Subject: Re: [R] fill color in boxplot and change number in scale I want to change the numbers in scale Y to c(0,-2.5) from (0,-10) only. and I want to change the color green to yellow and blue to green in the boxplot. Thank you On Fri, Aug 21, 2015 at 6:28 PM, John Kane [via R] ml-node+s789695n471135...@n4.nabble.com wrote: Would this help on colour? http://stackoverflow.com/questions/8320462/ggplot2-how-to-adjust-fill-colour-in-a-boxplot-and-change-legend-text You don't say what you want to with the numbers in scale (what scale?) You might want to try something like ?scale_manual and then do some googling. Note almost all the code you provided is redundent for the problem. We probably should have the data however . See ?dput or read ttp:// stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and/or http://adv-r.had.co.nz/Reproducibility.html for some hints on how to frame the question and supply data. John Kane Kingston ON Canada -Original Message- From: [hidden email] http:///user/SendEmail.jtp?type=nodenode=4711353i=0 Sent: Fri, 21 Aug 2015 14:10:23 +0300 To: [hidden email] http:///user/SendEmail.jtp?type=nodenode=4711353i=1 Subject: [R] fill color in boxplot and change number in scale hello, I want to change the line color and/or fill of each boxplot and change number in scale what I need to do? ylim-c(-3,0.5) data.for.plot-data.frame(accelaration=data_2$lag1min_accelaration, lag=1, alert='red') data.for.plot-rbind(data.for.plot, data.frame(accelaration=data_2$min_accelaration, lag=0, alert='red')) data.for.plot-rbind(data.for.plot, data.frame(accelaration=data_1$lag1min_accelaration, lag=1, alert='yellow')) data.for.plot-rbind(data.for.plot, data.frame(accelaration=data_1$min_accelaration, lag=0, alert='yellow')) data.for.plot-rbind(data.for.plot, data.frame(accelaration=data_0$lag1min_accelaration, lag=1, alert='no alert')) data.for.plot-rbind(data.for.plot, data.frame(accelaration=data_0$min_accelaration, lag=0, alert='no alert')) library('ggplot2') ggplot(data.for.plot,aes(fill=factor(alert), y=accelaration,x=factor(lag)))+ geom_boxplot() __ [hidden email] http:///user/SendEmail.jtp?type=nodenode=4711353i=2 mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ [hidden email] http:///user/SendEmail.jtp?type=nodenode=4711353i=3 mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/fill-color-in-boxplot-and-change-number-in-scale-tp4711348p4711353.html To start a new topic under R help, email ml-node+s789695n789696...@n4.nabble.com To unsubscribe from R help, click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=789696code=ZWxhZGxhemFyMjJAZ21haWwuY29tfDc4OTY5NnwtMTc0ODMyNzg0MQ== . NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/fill-color-in-boxplot-and-change-number-in-scale-tp4711348p4711364.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __
Re: [R] Date as Integer
Do an str() on the data. It looks like your variable is an integer where you probably need a date or a factor. Would you please include some sample data if possible. See ?dput which is the preferred way for sending sample data. It ensures that the reader is looking at the exact same data that you have on your machine. If the data set is large a small, representative sample is find. Something like dput(head(dat1, 100)) is probably fine. Fake data is okay if it is in the same format as the real. Check with str() before sending. John Kane Kingston ON Canada -Original Message- From: shivibha...@ymail.com Sent: Sat, 22 Aug 2015 00:43:05 -0700 (PDT) To: r-help@r-project.org Subject: [R] Date as Integer Hi All, I am using dplyr package and need to find total bills booked grouped on a date level however my date is integer. In the code below i was trying to change date format from integer. However it is throwing an error: no applicable method for 'group_by_' applied to an object of class c('integer', 'numeric') ak%% group_by(as.Date(pickdate),%y%m%d)%% summarise(Total=count(waybill)) Do i need to create a new var first changing the date and then group it or as.Date will work as i added in dplyr. -- View this message in context: http://r.789695.n4.nabble.com/Date-as-Integer-tp4711377.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords protects your account. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Build R with optimized BLAS library
I want to build R with an optimized BLAS library. My OS: Fedora 22 Hardware: CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 Thread(s) per core: 2 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz I am a little confused when it comes to choose a method and would like to hear your experiences. If I am right, I have 3 possibilities: - OpenBLAS: opensource and free, but I came across some posts describing seg faults issues and bugs. These posts are 2 years old and I wonder if it is still the case. - ATLAS: can't see any reason to not use it - Intel MKL: this is part of Intel Parallel Studio and is a paid software. Now, there is the MKL package distributed by Revolutionanalytics, but I am not certain how this can be distributed for free. Is there any kind of difference? In case of use of this package, do I need to install RRO or can I just build R from GNU against these libraries? Thank you for advices. -- google.com/+arnaudgabourygabx __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Generalised poisson regression
Dare I say... On Sat, Aug 22, 2015 at 1:17 PM, David Winsemius dwinsem...@comcast.net wrote: I'm not attacking your manhood when I say that your attachments are a problem. Fortune Nomination! Cheers, Bert __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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-es] Consulta ingreso de datos ponderados y ojiva
Hola estoy dando mis primeros pasos en R, y he ingresado vectores pero ahora quisiera ingresar datos ponderados, es decir como ingreso la siguiente tabla en R. (no tengo los datos uno a uno, solo cuento con esta informaci�n) LONGITUD (intervalos) N�mero de Piezas (Frecuencia) 67.5 � 72.5 5 72.5 � 77.5 95 77.5 � 82.5 790 82.5 � 87.5 100 87.5 � 92.5 10 Y al tener estos datos agrupados como realizar�a el calculo de la frecuencia relativa para dibujar la ojiva. Gracias. [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] Generalised poisson regression
On Aug 22, 2015, at 8:40 AM, Babatunde Yakub wrote: Using object$deviance for generalised poisson regression model gives NULL as response. Code attached. please checkthanks I'm not attacking your manhood when I say that your attachments are a problem. The only person who can see that attachment besides yourself is me because you did not copy the list and used an extension of `.r`. The mailing list requires that attachments be MIME-text and most mailers will not construct an email that lists them as such unless you use an extension of .txt. So your attachment with an .r extension was scrubbed. I'm not a user of the VGAM package, but I do read help pages. First your code which will let the rest of the audience correct my errors: #EQUI-DISPERSION POISSON COUNT library(MASS) library(GPseq) library(VGAM) library(COMPoissonReg) x=rnorm(50) link=0.2+0.4*x rpois.od-function (n,lambda,d) { if (d==1) rpois(n, lambda) else rnbinom(n, size=(lambda/(d-1)), mu=lambda) } y=rpois.od(50,lambda=exp(link),d=1) # GENERALIZED POISSON genp= vglm(y~x, genpoisson,trace = TRUE) gen=summary(genp) The need for 4 different packages was no at all clear. I installed pkg:VGAM and looked at `?genpoisson` after loading only that package. Since it was there then only pkg:COMPoissonReg might be modifying the behavior of htat code, so I left it uninstalled (and unloaded initially). The ?vglm page tells us that there is no deviance component to objects returned from it and states that the recommended method for doing LR-tests is to use `lrtest` and so my w The 'gen' object was examined with `str`: str(gen) #output truncated at beginning and end ..@ family :Formal class 'vglmff' [package VGAM] with 18 slots .. .. ..@ blurb : chr [1:8] Generalized Poisson distribution\n\n Links: rhobit(lambda) , ... .. .. ..@ constraints : expression({ M1 - 2 dotzero - -1 eval(negzero.expression.VGAM) }) .. .. ..@ deviance :function () .. .. ..@ fini : expression({ }) .. .. ..@ first : expression({ }) .. .. ..@ infos :function (...) #--- So that didn't look very promising, . seeing that empty `deviance` function. So I continued with my hacking efforts at following the manual and built a NULL model and ran an LRT: ?lrtest genpnull= vglm(y~1, genpoisson,trace = TRUE) VGLMlinear loop 1 : loglikelihood = -64.750744 VGLMlinear loop 2 : loglikelihood = -64.696782 VGLMlinear loop 3 : loglikelihood = -64.696568 VGLMlinear loop 4 : loglikelihood = -64.696567 VGLMlinear loop 5 : loglikelihood = -64.696567 gen0=summary(genpnull) lrtest(genp,genpnull) Likelihood ratio test Model 1: y ~ x Model 2: y ~ 1 #Df LogLik Df Chisq Pr(Chisq) 1 97 -59.045 2 98 -64.697 1 11.304 0.0007735 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 The LogLik values would allow you to construct a deviance-value for each model although the `lrtest` function has already calculated the difference in 2*LL between the 2 models and labeled it 'Chisq'. The deviance is not of much meaning as a number applied to a single model because it can vary drastically for different data arrangements. Only differences in nested models is meaningful. Turned out that the actions I just performed are already done automatically if a single model is given to lrtest. Exactly the same output results. You can look at the code: lrtest_vglm # and see where it does that snippet if (nmodels 2) { objects - c(objects, . ~ 1) nmodels - 2 } #-and then see that it is using a function named LogLik-- logLlist - lapply(objects, logLik) #--- logLik(genp) [1] -59.04466 So if I had really known what I was doing, I might have just typed ?logLik, except when I do that it appears the package author doesn't really intend for us to do this, since that pulls up a page for Undocumented and Internally Used Functions and Classes. Thus endeth today's meanderings among the help pages for pkg:VGAM. Please read the Posting Guide and also go back and read the general information webpages. You seem to have missed some important details. -- David. On Friday, August 21, 2015 7:40 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 21, 2015, at 5:22 AM, Babatunde Yakub via R-help wrote: I want to know how to extract or obtain the deviance for a fitted generalised poisson regression model. Thanks in advance If you post the code and some sample data, for building such a model, I'm sure someone can help you extract the deviance. If you simply mean what is returned by an ordinary glm-call with family=poisson then deviance should be one of the elements of the glm-object. object$deviance [[alternative HTML version deleted]] When you do reply (if needed) please send in plain text
[R-es] ayuda datos ponderados
Hola estoy dando mis primeros pasos en R, y he ingresado vectores pero ahora quisiera ingresar datos ponderados, es decir como ingreso la siguiente tabla en R. (no tengo los datos uno a uno, solo cuento con esta informacion) Longitud = intervalos Numero de Piezas = Frecuencia Favor indicarme como hacer el calculo de frecuencia relativa para dibujar la ojiva. Gracias ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] [R-pkgs] pls 2.5-0 released
Version 2.5-0 of the pls package has been released. The pls package implements Partial Least Squares Regression, Principal Component Regression and Canonical Powered PLS. The major changes are: - Cross-validation can now make sure that replicates are kept in the same segment, by the use of a new argument `nrep'. See ?cvsegments for details. - It now has a vignette. - It now has a NEWS file that can be accessed by news(). -- Regards, Bjørn-Helge Mevik ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Build R with optimized BLAS library
On Sat, Aug 22, 2015, 5:12 PM Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Questions about compiling generally belong on R-devel. Ok. Sorrx fpr the noise --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On August 22, 2015 7:51:39 AM PDT, arnaud gaboury arnaud.gabo...@gmail.com wrote: I want to build R with an optimized BLAS library. My OS: Fedora 22 Hardware: CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 Thread(s) per core: 2 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz I am a little confused when it comes to choose a method and would like to hear your experiences. If I am right, I have 3 possibilities: - OpenBLAS: opensource and free, but I came across some posts describing seg faults issues and bugs. These posts are 2 years old and I wonder if it is still the case. - ATLAS: can't see any reason to not use it - Intel MKL: this is part of Intel Parallel Studio and is a paid software. Now, there is the MKL package distributed by Revolutionanalytics, but I am not certain how this can be distributed for free. Is there any kind of difference? In case of use of this package, do I need to install RRO or can I just build R from GNU against these libraries? Thank you for advices. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Build R with optimized BLAS library
Questions about compiling generally belong on R-devel. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On August 22, 2015 7:51:39 AM PDT, arnaud gaboury arnaud.gabo...@gmail.com wrote: I want to build R with an optimized BLAS library. My OS: Fedora 22 Hardware: CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 Thread(s) per core: 2 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz I am a little confused when it comes to choose a method and would like to hear your experiences. If I am right, I have 3 possibilities: - OpenBLAS: opensource and free, but I came across some posts describing seg faults issues and bugs. These posts are 2 years old and I wonder if it is still the case. - ATLAS: can't see any reason to not use it - Intel MKL: this is part of Intel Parallel Studio and is a paid software. Now, there is the MKL package distributed by Revolutionanalytics, but I am not certain how this can be distributed for free. Is there any kind of difference? In case of use of this package, do I need to install RRO or can I just build R from GNU against these libraries? Thank you for advices. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Date as Integer
It would help if you supplied a small dataset so we could reproduce your problem problem. Here is one that gives the same error. (I also moved some parentheses around so %y-%m-%d is an argument to as.Date() instead of to group_by().) data.frame(pickdate=paste(sep=-,15,08,c(21,22,21,22,22)), waybill=2^(0:4)) %% group_by(as.Date(pickdate,%y-%m-%d)) %% summarize(Total=count(waybill)) #Error: no applicable method for 'group_by_' applied to an object of class c('double', 'numeric') I think count() is a wrapper for summarize() (or summarise() outside the US), not something to call from within summarize(), but I may be wrong (the help file is terse). Try using n() instead: data.frame(pickdate=paste(sep=-,15,08,c(21,22,21,22,22)), waybill=2^(0:4)) %% group_by(as.Date(pickdate,%y-%m-%d)) %% summarize(N=n(), Sum=sum(waybill), Mean=mean(waybill)) #Source: local data frame [2 x 4] # # as.Date(pickdate, %y-%m-%d) N Sum Mean #12015-08-21 2 5 2.50 #22015-08-22 3 26 8.67 Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, Aug 22, 2015 at 12:43 AM, Shivi82 shivibha...@ymail.com wrote: Hi All, I am using dplyr package and need to find total bills booked grouped on a date level however my date is integer. In the code below i was trying to change date format from integer. However it is throwing an error: no applicable method for 'group_by_' applied to an object of class c('integer', 'numeric') ak%% group_by(as.Date(pickdate),%y%m%d)%% summarise(Total=count(waybill)) Do i need to create a new var first changing the date and then group it or as.Date will work as i added in dplyr. -- View this message in context: http://r.789695.n4.nabble.com/Date-as-Integer-tp4711377.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.