[R] Quartering a plot() ?
Sorry if my terminology is all out of sorts here, but I'm curious about a simple matter: I have a plot, and within it a box defined by lines, like so: plot(c(), xlim=c(-1.5,1.5), ylim=c(0,5)) lines(c(1,1,-1,-1,1),c(1.5,3.5,3.5,1.5,1.5), col=c(red)) I'd like to easily chop the box drawn by lines into an even 3x3 grid- is this possible easily? Thanks! -- Wells Oliver we...@submute.net [[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] Drawing an axis with a subset of the data
I have a vector of dates: data$date [1] 2009-04-06 CDT 2009-04-07 CDT 2009-04-08 CDT 2009-04-09 CDT 2009-04-10 CDT 2009-04-11 CDT 2009-04-12 CDT 2009-04-14 CDT [9] 2009-04-15 CDT 2009-04-16 CDT 2009-04-17 CDT 2009-04-18 CDT 2009-04-19 CDT 2009-04-21 CDT 2009-04-22 CDT 2009-04-23 CDT [17] 2009-04-24 CDT 2009-04-25 CDT 2009-04-26 CDT 2009-04-27 CDT 2009-04-28 CDT 2009-04-29 CDT 2009-05-01 CDT 2009-05-02 CDT [25] 2009-05-03 CDT 2009-05-04 CDT 2009-05-05 CDT 2009-05-06 CDT 2009-05-07 CDT 2009-05-08 CDT 2009-05-09 CDT 2009-05-10 CDT [33] 2009-05-12 CDT 2009-05-13 CDT 2009-05-14 CDT 2009-05-15 CDT 2009-05-16 CDT 2009-05-17 CDT 2009-05-18 CDT 2009-05-19 CDT [41] 2009-05-20 CDT 2009-05-21 CDT 2009-05-22 CDT 2009-05-23 CDT 2009-05-24 CDT 2009-05-25 CDT 2009-05-26 CDT 2009-05-27 CDT [49] 2009-05-29 CDT 2009-05-30 CDT 2009-05-31 CDT 2009-06-01 CDT 2009-06-02 CDT 2009-06-03 CDT 2009-06-05 CDT 2009-06-06 CDT [57] 2009-06-07 CDT 2009-06-09 CDT 2009-06-10 CDT 2009-06-11 CDT 2009-06-12 CDT 2009-06-13 CDT 2009-06-14 CDT I'd like to make a subset of this data as the x axis for a graph, using 10, so the first would be the first date, the final would be the final date, and the 8 in between would be spread equally through the set. Currently I have this: plot(data$date, data$DIFF, xaxt='n', xlab='', type='l', yaxt='n', ylab='', bg='white', tck=-0.025, main='', col='blue') axis(1, at=unique(data$date), labels=unique(data$date), lwd=.25, tck=-0.025) Which renders all 63 dates, which of course is far too cluttered. Any idea how I can easily reduce this to a subset of 10? -- Wells Oliver we...@submute.net [[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] Formatting the length one vector to match another?
I have xrange which is a range of values from 1 to a max of 162. I have a yrange of values which really could be any values, but there's a min and a max. I'd like to create N number of steps between the min and the max so the length matches the xrange, so that I can plot them together. Any tips? Thank you! -- Wells Oliver we...@submute.net [[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] Formatting of numbers on y axis
Hello all. I have the following: plot(salaries$yearID, salaries$salary, type='n', xaxt='n', xlab='', yaxt='n', ylab='') axis(1, at=unique(salaries$yearID), labels=unique(salaries$yearID), lwd=.25, tck=-0.05) axis(2, axTicks(2), format(axTicks(2), scientific = F)) Which nicely creates the Y axis with the raw numbers, which are in the range of .5 - 7 million. However, it displays them as 100, and so on- I'd like it to show just whole numbers 1, 2, 3, through 7, so I can label the Y axis in millions. Any tips? Thanks! -- Wells Oliver we...@submute.net [[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] par() background issue
I have the following: par(bg='#CC', family='Lucida Grande') plot(salaries$yearID, salaries$salary/100) Which creates a graph with the correct offwhite/yellow background. However, I want the actual plot box to have a white background. par(bg='#CC', family='Lucida Grande') plot(salaries$yearID, salaries$salary/100, bg='#FF') But that does nothing. How can I accomplish this? Thanks! -- Wells Oliver we...@submute.net [[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] Stacked bar chart help.
Can't figure this out. I have the following list of salary averages per year, per position. The dput output is: dput(salaries) structure(list(yearID = c(2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008), AVG = c(8956855.61, 7886684.166126, 7534048.43102, 7406439.339471, 7219148.437934, 6697734.908336, 6400379.88398, 3765720.093796, 3630731.367928, 9022895.226432, 8441165.305623, 8102876.628756, 7797941.00885, 7407822.844814, 7293419.165284, 6429637.71541, 4946563.641848, 4233392.0256), POS = c(RF, 3B, LF, DH, 1B, SS, CF, 2B, C, DH, RF, 3B, 1B, SS, CF, LF, C, 2B)), .Names = c(yearID, AVG, POS), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), class = data.frame) I am trying to render a stacked bar chart, on the X axis the list of unique positions, on the Y axis the range of min to max salary. The stacked charts would show the averages per year, with a color unique to each year.' Trying something like: barplot(t(salaries), main='Position', ylab='Y', col=heat.colors(2), space=0.1, cex.axis=0.8, las=1, names.arg=salaries$POS, cex=0.8 ) Corollary: what's the easiest way to format currency in R? e..g make the Y axis read $55,008.00 instead of 55008.00. Any tips? Thanks! -- Wells Oliver we...@submute.net [[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] Beginner Q- dates in the xrange?
Hi all- terribly beginner question here, but I can't figure out how to put dates as the values for my x range in a plot. Example: xrange - results$current yrange - results$DIFF plot(xrange, yrange, type=n, xlab=Date, ylab=Differential) lines(results$DIFF, type=l, lwd=1.5, col=red) Where xrange is: xrange [1] 2010-04-12 2010-04-14 2010-04-15 2010-04-16 2010-04-17 2010-04-18 2010-04-19 2010-04-20 2010-04-21 2010-04-23 2010-04-24 2010-04-25 [13] 2010-04-27 2010-04-28 2010-04-29 2010-04-30 2010-05-01 2010-05-02 2010-05-03 2010-05-04 2010-05-05 2010-05-06 2010-05-07 2010-05-08 [25] 2010-05-09 2010-05-10 2010-05-11 2010-05-12 2010-05-13 2010-05-14 2010-05-15 2010-05-16 2010-05-18 2010-05-19 2010-05-20 2010-05-21 [37] 2010-05-22 2010-05-23 2010-05-25 2010-05-26 2010-05-27 2010-05-28 2010-05-29 2010-05-30 2010-05-31 2010-06-01 2010-06-02 2010-06-04 [49] 2010-06-05 2010-06-06 2010-06-08 2010-06-09 2010-06-10 2010-06-11 2010-06-12 2010-06-13 2010-06-14 2010-06-15 2010-06-16 2010-06-17 [61] 2010-06-18 2010-06-19 The error being: plot(xrange, yrange, type=n, xlab=Date, ylab=Differential) Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Any tips on how to generate a nicely-formatted plot w/ dates in the x axis? Thanks. -- Wells Oliver we...@submute.net [[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] Beginner Q- dates in the xrange?
Follow up with actual data and what I'm trying to do. Current R code/script: plot(results$DIFF, xaxt=n, ylab=Differential, xlab=2009) daterange=c(as.POSIXlt(min(results$date)),as.POSIXlt(max(results$date))) axis.POSIXct(1, at=seq(daterange[1], daterange[2], by=month), format=%b) lines(results$DIFF, type=l, lwd=1.5, col=red, pch=15) dput(results): structure(list(date = c(2010-04-12, 2010-04-14, 2010-04-15, 2010-04-16, 2010-04-17, 2010-04-18, 2010-04-19, 2010-04-20, 2010-04-21, 2010-04-23, 2010-04-24, 2010-04-25, 2010-04-27, 2010-04-28, 2010-04-29, 2010-04-30, 2010-05-01, 2010-05-02, 2010-05-03, 2010-05-04, 2010-05-05, 2010-05-06, 2010-05-07, 2010-05-08, 2010-05-09, 2010-05-10, 2010-05-11, 2010-05-12, 2010-05-13, 2010-05-14, 2010-05-15, 2010-05-16, 2010-05-18, 2010-05-19, 2010-05-20, 2010-05-21, 2010-05-22, 2010-05-23, 2010-05-25, 2010-05-26, 2010-05-27, 2010-05-28, 2010-05-29, 2010-05-30, 2010-05-31, 2010-06-01, 2010-06-02, 2010-06-04, 2010-06-05, 2010-06-06, 2010-06-08, 2010-06-09, 2010-06-10, 2010-06-11, 2010-06-12, 2010-06-13, 2010-06-14, 2010-06-15, 2010-06-16, 2010-06-17, 2010-06-18, 2010-06-19), DIFF = c(0, 7, 3, 8, 2, -3, 0, -5, -6, -12, -10, -5, -11, -7, -5, -3, 5, 6, 7, 3, 6, 9, 7, 5, 12, 10, 12, 13, 1, 5, 6, 4, 3, -1, 0, -6, -5, 2, -2, 2, -3, 0, 4, 2, 4, 9, 12, 16, 13, 14, 16, 18, 15, 14, 21, 23, 24, 26, 27, 26, 27, 22)), .Names = c(date, DIFF ), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62), class = data.frame) However, on the plot, there are no values for the dates; it seems as though the axis.POSIXct call is failing. Thanks for any tips. On Wed, Sep 16, 2009 at 7:15 PM, Wells Oliver we...@submute.net wrote: Hi all- terribly beginner question here, but I can't figure out how to put dates as the values for my x range in a plot. Example: xrange - results$current yrange - results$DIFF plot(xrange, yrange, type=n, xlab=Date, ylab=Differential) lines(results$DIFF, type=l, lwd=1.5, col=red) Where xrange is: xrange [1] 2010-04-12 2010-04-14 2010-04-15 2010-04-16 2010-04-17 2010-04-18 2010-04-19 2010-04-20 2010-04-21 2010-04-23 2010-04-24 2010-04-25 [13] 2010-04-27 2010-04-28 2010-04-29 2010-04-30 2010-05-01 2010-05-02 2010-05-03 2010-05-04 2010-05-05 2010-05-06 2010-05-07 2010-05-08 [25] 2010-05-09 2010-05-10 2010-05-11 2010-05-12 2010-05-13 2010-05-14 2010-05-15 2010-05-16 2010-05-18 2010-05-19 2010-05-20 2010-05-21 [37] 2010-05-22 2010-05-23 2010-05-25 2010-05-26 2010-05-27 2010-05-28 2010-05-29 2010-05-30 2010-05-31 2010-06-01 2010-06-02 2010-06-04 [49] 2010-06-05 2010-06-06 2010-06-08 2010-06-09 2010-06-10 2010-06-11 2010-06-12 2010-06-13 2010-06-14 2010-06-15 2010-06-16 2010-06-17 [61] 2010-06-18 2010-06-19 The error being: plot(xrange, yrange, type=n, xlab=Date, ylab=Differential) Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Any tips on how to generate a nicely-formatted plot w/ dates in the x axis? Thanks. -- Wells Oliver we...@submute.net -- Wells Oliver we...@submute.net [[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.