r

How to properly project and plot raster in R

旧街凉风 提交于 2021-02-20 20:00:02
问题 I have a raster in an equal area Behrmann projection and I would like to project it to the Mollweide projection and plot. When I do this with the following code, however, the plotting doesn't seem right, as the map extends to the sides, and there are outlines of various landmasses where I wouldn't expect them.Also, the map extends beyond the plot window. Can anyone please help me get this to plot nicely? Thanks! The data file used can be downloaded from this link. Here is the code I have so

How to properly project and plot raster in R

一笑奈何 提交于 2021-02-20 19:59:26
问题 I have a raster in an equal area Behrmann projection and I would like to project it to the Mollweide projection and plot. When I do this with the following code, however, the plotting doesn't seem right, as the map extends to the sides, and there are outlines of various landmasses where I wouldn't expect them.Also, the map extends beyond the plot window. Can anyone please help me get this to plot nicely? Thanks! The data file used can be downloaded from this link. Here is the code I have so

Disconnected from the (shiny) server: cause of large Plotly R heatmaps

*爱你&永不变心* 提交于 2021-02-20 19:11:47
问题 I'm developing quite a complex shiny app that runs on a private shinyserver. Only the pages that contains large plotly heatmaps (50-70Mb) are not working online (but the pages are working perfectly on my local machine). What I get is the usual message "Disconnected from the server Reload" . When this error message is shown no log file is produced in /var/log . What I tried to do is: check if it's a missing packages problem, it's not; check if it's a wrong paths problem, it's not; modify the

Navigating and scraping with R (rvest)

旧时模样 提交于 2021-02-20 19:09:10
问题 I am trying to log in in stackoverflow and navigating on the search bar, searching by tidyverse package. The main problem is when I set the url, which is not giving me the form to fill with my email and my password: So url<-"https://stackoverflow.com" doesnt work. I tried the url: url<-"https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f" which is the url that I have when I click on the the Log in bottom, but I also can't find the form to fill with my

How to shift data by a factor of two months in R?

拈花ヽ惹草 提交于 2021-02-20 19:08:17
问题 I would like to move down my entire data by a factor of two months. For example, if my data starts on Jan 01, i want to move the data in such a way that the data corresponds to March 01. Likewise, November data would become January data for the next year. Here is my sample code DF <- data.frame(seq(as.Date("2001-01-01"), to= as.Date("2003-12-31"), by="day"), A = runif(1095, 0,10), D = runif(1095,5,15)) colnames(DF) <- c("Date", "A", "B") I tried DF$Date <- DF$Date + 61 but this moved the

How to shift data by a factor of two months in R?

那年仲夏 提交于 2021-02-20 19:08:00
问题 I would like to move down my entire data by a factor of two months. For example, if my data starts on Jan 01, i want to move the data in such a way that the data corresponds to March 01. Likewise, November data would become January data for the next year. Here is my sample code DF <- data.frame(seq(as.Date("2001-01-01"), to= as.Date("2003-12-31"), by="day"), A = runif(1095, 0,10), D = runif(1095,5,15)) colnames(DF) <- c("Date", "A", "B") I tried DF$Date <- DF$Date + 61 but this moved the

plot polynomial regression line with ggplot stat_smooth

懵懂的女人 提交于 2021-02-20 19:05:21
问题 I'm trying to create a scatter plot with second degree polynomial regression line using ggplot:stat_smooth. Here are the codes: df.car_spec_data <- read.csv(url("http://www.sharpsightlabs.com/ wp- content/uploads/2015/01/auto-snout_car-specifications_COMBINED.txt")) df.car_spec_data$year <- as.character(df.car_spec_data$year) df.car_spec_data %>% group_by(year) %>% summarise(maxspeed=max(top_speed_mph, na.rm=T)) %>% ggplot(aes(x=year, y=maxspeed, group=1))+geom_point(color='red', alpha=0.3,

How do I fix the unrecognized object error in Stargazer with a dynlm model?

假如想象 提交于 2021-02-20 19:01:47
问题 I calculated a dynlm model and now want to get stargazer to export that. However, stargazer does not return any output, instead gives me the Unrecognized object type Error. I already checkd if dynlm objects were supported by stargazer and according to the package page it is. Anyone have any idea what I'm getting wrong here? I know how to export the output with stargazer, but in this case it doesn't even show me the results inside of R. This is the model I used and the stargazer command, which

dplyr Update a cell in a data.frame

我怕爱的太早我们不能终老 提交于 2021-02-20 18:52:44
问题 df <-data.frame(x=c(1:5),y=c(letters[1:5])) Let's say I want to modify the last row, update.row<-filter(df,x==5) %>% mutate(y="R") How do I update this row into the data.frame ? The only way, I found albeit a strange way is to do an anti-join and append the results. df <-anti_join(df,update.row,by="x") %>% bind_rows(update.row) However, it seems like a very inelegant way to achieve a simple task. Any ideas are much appreciated... 回答1: If you are insistant on dplyr , perhaps df <-data.frame(x

Use of ifelse to assign values to a new dataframe column in R

做~自己de王妃 提交于 2021-02-20 18:52:08
问题 I have a time series dataframe and would like to create a new numeric column with values which are a function of an existing numeric column and which are assigned according to the day of the week column. For example, I would require something like the following code: Day <- c("Mo", "Mo", "Mo", "Tu", "Tu", "We", "We", "We", "We", "Th") Val <- c(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000) df <- data.frame(cbind(Day,Val)) df$Adj <- ifelse(df$Day == "Mo" || df$Day == "Tu", as