[R] Replacing dates with consecutive observations
I am working with a list of dates and I would like to replace each date with the one that comes after, ie. 1/1/07 will become 1/5/07, 1/5/07 will become 1/7/07, etc. The number of days between my dates always varies, so I can't just increase each one by 5 days or so. Does anyone know of a way I can do this in R? thank you [[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 matches
My question is probably pretty basic, but since I'm really new to R, here it goes I have two separate data frames that include class names and various other information on classes. I'm trying to create a match based on class names and if a match exists to create a third data frame with the class name. I was hoping to accomplish this with sapply, but I can't figure out if I can embed an "if statement" with sapply. Does anyone know if that's a legit way to accomplish what I am trying to do or is there some better way? thank you, Alina Sheyman [[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] (no subject)
I'm trying to establish the occurrence of a specific day of the week in a given month. Namely I want to know if a specific Tuesday was the 2nd,3rd Tuesday in a month. Is there a good way to this in R? thank you, Alina Sheyman [[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] occurrence of a weekday in a month
I'm trying to establish the occurrence of a specific day of the week in a given month. Namely I want to know if a specific Tuesday was the 2nd,3rd Tuesday in a month. Is there a good way to this in R? thank you, Alina Sheyman [[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] creating a map
I'm trying to create a fairly basic map using R. What i want to get is the map of the country with circles representing a count of students in each state. What I've done so far is as following - map("state") symbols(data1$count,circles=log(data1$count)*3,fg=col,bg=col,add=T,inches=F) this gives me the map of the country, but one that's not populated by my counts. Does anyone know what I'm doing wrong? Also, if anyone can recommend a good reference for creating maps in R, I'd really appreciate that. thank you [[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] creating a map
Thanks Greg, do you know where i can find the sate.center dataset that you mention? On Tue, Feb 17, 2009 at 12:28 PM, Greg Snow wrote: > You need to give the symbols function the locations where you want the > centers of the circles to be. Some datesets with map information also have > centers of the states that you can use, for the USA, there is the > state.center dataset that may work for you, or the maptools package function > get.Pcent will compute a center for polygons (there are probably other > similar functions in other packages). > > For adding circles to a map of the USA, you may want to look at the > state.vbm data in the TeachingDemos package (works with maptools package), > but you will need to computer the centers of the polygons, they don't match > state.center or others. > > Hope this helps, > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > > project.org] On Behalf Of Alina Sheyman > > Sent: Tuesday, February 17, 2009 9:53 AM > > To: r-help@r-project.org > > Subject: [R] creating a map > > > > I'm trying to create a fairly basic map using R. What i want to get is > > the > > map of the country with circles representing a count of students in > > each > > state. > > What I've done so far is as following - > > map("state") > > > > symbols(data1$count,circles=log(data1$count)*3,fg=col,bg=col,add=T,inch > > es=F) > > > > this gives me the map of the country, but one that's not populated by > > my > > counts. > > Does anyone know what I'm doing wrong? > > > > Also, if anyone can recommend a good reference for creating maps in R, > > I'd > > really appreciate that. > > > > thank you > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting- > > guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RcolorBrewer
I've downloaded the RcolorBrewer package, but when I try to run mypalette<-brewer.pal(7,"Greens") (or any other command with brewer.pal) I get the following error message - Error: could not find function "brewer.pal" Does anyone know why that's happening? Is there smth else I need to download? thank you [[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] RcolorBrewer
I figured it out thanks On Wed, Feb 18, 2009 at 3:50 PM, Domenico Vistocco wrote: > Alina Sheyman wrote: > >> I've downloaded the RcolorBrewer package, but when I try to run >> mypalette<-brewer.pal(7,"Greens") >> >> (or any other command with brewer.pal) >> >> I get the following error message - Error: could not find function >> "brewer.pal" >> >> Does anyone know why that's happening? Is there smth else I need to >> download? >> >> > Do you have loaded the package? > library(RcolorBrewer) > > thank you >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> >> > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] color maps with counts
I have yet another question concerning maps. This time I want to create a colored map of number of students by state. Can this be done using palettes in Rcolor brewer, is there some other way? I've been looking through R archives, but am still really at a loss here, so all help will be much appreciated. Thank you! [[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] colored maps again
I'm trying to create a colored map that would show the number of students per state. My data frame consists of two columns - state and count. I'm using the following code library(maps) map("usa") library(plotrix) state.col<-color.scale(gre$count,0,0,c(0,1)) map("state",fill=TRUE,col=state.col) I'm getting a map, but the values are not being mapped to correct states. What do I need to do to fix that? [[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] mapping lat and long with maps package
I am trying to overlay a data frame with lat and longitude(which refer to zip codes) on the map of US that I get by using map ("states"). Is there anyway to do this or do I have to resort to using maptools? thank you [[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] mapping lat and long with maps package
When I run this code i get the following error messages Error in mapgetg(database, gon, as.polygon, xlim, ylim) : NA/NaN/Inf in foreign function call (arg 6) In addition: Warning messages: 1: In min(x, na.rm = na.rm) : no non-missing arguments to min; returning Inf 2: In max(x, na.rm = na.rm) : no non-missing arguments to max; returning -Inf On Wed, Mar 4, 2009 at 5:27 PM, David Winsemius wrote: > The example on the help page would seem to be completely on point if I > understand your desire to be plotting text at particular long,lat > coordinates: > > ?map > > text(long, lat, "text") > > # > data(ozone) > map("state", xlim = range(ozone$x), ylim = range(ozone$y)) > text(ozone$x, ozone$y, ozone$median) > box() > > -- > David Winsemius > > > On Mar 4, 2009, at 5:04 PM, Alina Sheyman wrote: > > I am trying to overlay a data frame with lat and longitude(which refer to >> zip codes) on the map of US that I get by using map ("states"). >> Is there anyway to do this or do I have to resort to using maptools? >> >> thank you >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] target of assignment expands to non-language object
I'm running the following code numbers <- 1:50 for (i in 1:50) assign(paste("model",numbers[i]),i)<-(lm(temp$Overall.Scaled.Score~temp$raw.score)) where I want R to create 50 different models-1:50, but get the following error message "target of assignment expands to non-language object". I've tried it with paste("model",numbers[i]))<-(lm(temp$Overall.Scaled.Score~temp$raw.score) and get the same error. Does anyone know what the problem is or whether there's a better way to get at what I'm trying to do? [[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] model selection using ANOVA
I've created a number of models using lm and now want to pick one with the smallest standard error or the smallest RSS, I can get a list of RSS using anova function, but is the any way I can then select one with the smallest RSS from the list? [[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] Europe zip code shapefiles
Hi all, I'm looking for zip code shapefiles for Italy and France.Does anyone know where I might be able to find these? thank you! [[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.