Re: [R] How to average values from grid cells with coordinates

2018-05-21 Thread lily li
Hi Jim, Thanks. It works. I now have more complex problems. If at each blackcell, there are two variables such as pop and mood. For each variable, there are daily records in one year, so 365 records for pop and 365 records for mood. The averaged values for the redcells should be daily records too.

[R] legend order in ggplot2

2018-05-21 Thread John
Hi, I'd like to graph three lines on ggplot2 and I intend the lines to be "solid", "dashed", and "dotted". The legend names are "name_b", "name_a", "name_c". I'd like to legend to present in the order: the "name_b" at the top, and "name_c" at the bottom. As a consequence, the legend is indeed i

[R] Bootstrap and average median squared error

2018-05-21 Thread varin sacha via R-help
Dear R-experts, I am trying to bootstrap (and average) the median squared error evaluation metric for a robust regression. I can't get it. What is going wrong ? Here is the reproducible example. # install.packages( "quantreg" ) library(quantreg) crp <-c(12,14,13,24

Re: [R] mapping groups of states without interior borders

2018-05-21 Thread Bert Gunter
Presumably this is in the package maps?? -- you need to specify such details when referring to non-base R functionality. In any case, you are more likely to get a helpful response if you post to the r-sig-geo list, which specialized in such spatial statistics/graphics questions. Cheers, Bert

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread MacQueen, Don
Here is a simplified example: dat <- data.frame(x=1:4, y1=runif(4), y2=runif(4), y3=4:1) for (icol in 2:4) plot(dat[,1] , dat[,icol] ) (not tested, so hopefully all my parentheses are balanced, no typos, etc.) This shows the basic principle. An alternative is to construct each column name as a

[R] mapping groups of states without interior borders

2018-05-21 Thread Simon, Heather
I have been using the "map" function in R and I was wondering if there is a way to map multi-state regions just showing the outline of the region without interior state borders. For instance, I am calculating aggregated statistics using 10 multi-state regions. I would like to color-code indivi

Re: [R] Can't open R files

2018-05-21 Thread Boris Steipe
Just for completeness: there are several ways to open files for editing in RStudio - * Configure your computer to be able to double-click on a file and open it in RStudio: this is OS dependent. Google for "change file associations" to get advice. * Drag and drop a file icon onto the RStu

Re: [R] draw borders of bars inside of the rectangles in a barplot

2018-05-21 Thread Richard M. Heiberger
I recommend instead of no border, that you use a border with the same color as the fill. I do this in the likert functions in the HH package. Rich On Mon, May 21, 2018 at 10:59 AM, Martin Batholdy via R-help wrote: > Dear R-users, > > I want to draw a barplot with beside=TRUE. > One halve of th

Re: [R] Plot qualitative y axis

2018-05-21 Thread John Kane via R-help
What I think is the ggplot2 version of what you want. Note that I am using the reshape2 package which is a bit old fashioned.  =library(reshape2) library(ggplot2) dat1  <- structure(list(N = c("I", "II", "III", "IV", "V", "VI", "VII",

Re: [R] draw borders of bars inside of the rectangles in a barplot

2018-05-21 Thread Bert Gunter
As I read ?barplot, the answer is no. I suspect the same is true in ggplot and lattice, but you would have to check. If correct, this means you would explicitly have to use the "width" argument to narrow or widen the bars appropriately. Or maybe try something like: barplot(x, beside=T, border= "bl

[R] draw borders of bars inside of the rectangles in a barplot

2018-05-21 Thread Martin Batholdy via R-help
Dear R-users, I want to draw a barplot with beside=TRUE. One halve of the bars are drawn with a border, while the other halve are drawn without a border (i.e. filled bars vs. non-filled bars next to each other). Because borders are drawn around the bars, doing this leads to one halve of the bar

Re: [R] S4 class slot type S4 class

2018-05-21 Thread Martin Morgan
On 05/21/2018 12:06 AM, Glenn Schultz wrote: All, I am considering creating an S4 class whose slots (2) are both S4 classes.  Since an S4 slot can be an S3 class I figure this can be done.  However, the correct syntax of which I am unsure.  Reviewing the docs I have come to the following c

Re: [R] strange behavior of plotmath

2018-05-21 Thread S Ellison
> plot(1:10, xlab = expression(NO[3]^-~(mg/L))) It's unexpected but not inexplicable. The difficulty is that the superscript begins with a unary minus operator. It _must_ have something (number or variable) after it to negate. Since the thing following the '-' is not a number, plotmath has just t

Re: [R] Plot qualitative y axis

2018-05-21 Thread Bert Gunter
See ?barplot and set the horiz argument to TRUE. (This is in the base R plotting version. The ggplot2 and lattice systems have other ways of doing this) Note: if you search on e.g. "barplots in R" or similar, you should find numerous examples with code. Cheers, Bert Bert Gunter "The trouble

[R] Plot qualitative y axis

2018-05-21 Thread Pedro páramo
Hi all, I´m trying to plot this data N M W I 10 106 II 124 484 III 321 874 IV 777 1140 V 896 996 VI 1706 1250 VII 635 433 VIII 1437 654 IX 693 333 X 1343 624 XI 1221 611 XII 25 15 XIII 3 XIV 7 8 So that in de Y axis will be the level (qualitative data) and in the X axis will be M and W variables.

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
Hello, Ulrik's way is simpler therefore better. I would use it, not mine. As for an explanation of mine, here it goes. 1) Parenthesis are meta-characters and must be escaped if you want to match them: \\( and \\) 2) You want to keep them so I used groups, i.e., put what you want between

Re: [R] removing part of a string

2018-05-21 Thread Ulrik Stervbo
I would use sub("\\(.*\\)", "()", s) It is essentially the same as Rui's suggestion, but I find the purpose to be more clear. It might also be a little more efficient. HTH Ulrik On Mon, 21 May 2018, 15:38 Rui Barradas, wrote: > Hello, > > Try this. > > > ss1 <- "z:f(5, a=3, b=4, c='1:4', d=2)

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
Hello, Try this. ss1 <- "z:f(5, a=3, b=4, c='1:4', d=2)" ss2 <- "f(5, a=3, b=4, c=\"1:4\", d=2)*z" fun <- function(s) sub("(\\().*(\\))", "\\1\\2", s) fun(ss1) #[1] "z:f()" fun(ss2) #[1] "f()*z" Hope this helps, Rui Barradas On 5/21/2018 2:33 PM, Vito M. R. Muggeo wrote: dear all, I am

[R] removing part of a string

2018-05-21 Thread Vito M. R. Muggeo
dear all, I am stuck on the following problem. Give a string like ss1<- "z:f(5, a=3, b=4, c='1:4', d=2)" or ss2<- "f(5, a=3, b=4, c=\"1:4\", d=2)*z" I would like to remove all entries within parentheses.. Namely, I aim to obtain respectively "z:f()" or "f()*z" I played with sub() and gsub(

Re: [R] strange behavior of plotmath

2018-05-21 Thread Rui Barradas
Try plot(1:10, xlab = expression(NO[3]^{'-'}~(mg/L))) Hope this helps, Rui Barradas On 5/21/2018 1:09 PM, Jinsong Zhao wrote: hi there, I find the following codes produce strange output. plot(1:10, xlab = expression(NO[3]^-~(mg/L))) you will notice that the unit, mg/L is in superscript for

Re: [R] strange behavior of plotmath

2018-05-21 Thread Eric Berger
FYI I see everything after the '^' as a superscript. The '~' does act as a space. (When I omit it there is less space between the '-' and the '('. On Mon, May 21, 2018 at 3:09 PM, Jinsong Zhao wrote: > hi there, > > I find the following codes produce strange output. > > plot(1:10, xlab = expre

[R] strange behavior of plotmath

2018-05-21 Thread Jinsong Zhao
hi there, I find the following codes produce strange output. plot(1:10, xlab = expression(NO[3]^-~(mg/L))) you will notice that the unit, mg/L is in superscript format. That means that "~" is not for space. However, the help page of plotmath does not mention this behavior. Best, Jinsong

Re: [R] Can't open R files

2018-05-21 Thread Nick Wray via R-help
Oh fab it works! thanks v much i'd never used open file like that before Nick > On 21 May 2018 at 12:24 Duncan Murdoch wrote: > > > On 21/05/2018 7:20 AM, Nick Wray via R-help wrote: > > Hello. I'm not sure whether this is strictly the right forum but here > > goes... I have got a new (well reco

Re: [R] Can't open R files

2018-05-21 Thread Duncan Murdoch
On 21/05/2018 7:20 AM, Nick Wray via R-help wrote: Hello. I'm not sure whether this is strictly the right forum but here goes... I have got a new (well reconditioned) laptop and have installed R studio on it. That works fine if I say write a little prog directly into it or paste R script f

[R] Can't open R files

2018-05-21 Thread Nick Wray via R-help
Hello. I'm not sure whether this is strictly the right forum but here goes... I have got a new (well reconditioned) laptop and have installed R studio on it. That works fine if I say write a little prog directly into it or paste R script from a word doc. But if I try to open an R prog (whic

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread John Kane via R-help
As Jim says, "No data". R-help is very fussy about what files it will accept.  You might try changing the extention to txt.  However the preferred way here is to use the dput() command and paste the results into the post.  See ?dput for details. On Monday, May 21, 2018, 1:40:59 a.m. EDT

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread Jim Lemon
Hi Steven, Sad to say that your CSV file didn't make it to the list and I can't access the data via your Dropbox account. Therefore we don't know the structure of "mydata". If you are able to plot the data as in your example, this might help: genexp<-matrix(runif(360,1,2),ncol=18) colnames(genexp)