r

Can't get geom_sf line width to function properly when I provide its value through an aesthetic

旧时模样 提交于 2021-02-11 09:45:19
问题 I have a shapefile, my_sf . If I write: ggplot() + geom_sf( data = my_sf, size = 0.5 # this is the default value actually ) then it works just fine. However, if I add a my_line_width attribute to my_sf , and set each value in that column to 0.5, and then write: ggplot() + geom_sf( data = my_sf, aes(size = my_line_width) ) then I get a bunch of massive lines that overlap hideously. If the normal lines are width 0.5, then these are perhaps width 4. I don't understand why those don't produce the

Can't get geom_sf line width to function properly when I provide its value through an aesthetic

半腔热情 提交于 2021-02-11 09:44:15
问题 I have a shapefile, my_sf . If I write: ggplot() + geom_sf( data = my_sf, size = 0.5 # this is the default value actually ) then it works just fine. However, if I add a my_line_width attribute to my_sf , and set each value in that column to 0.5, and then write: ggplot() + geom_sf( data = my_sf, aes(size = my_line_width) ) then I get a bunch of massive lines that overlap hideously. If the normal lines are width 0.5, then these are perhaps width 4. I don't understand why those don't produce the

compare two integer column values in R and fill a new column

此生再无相见时 提交于 2021-02-11 09:40:57
问题 I am trying to fill new column values in R data frame based on a condition that compares values from two columns. Using for loop and if-else control statement. Here's my sample dataset Year1 | Year2 ----- | ----- 1990 | 1990 1992 | 1992 1995 | 1998 1997 | 2000 I would like to do something like this: for (i in 1:length(year1) { if (year1[i] == year2[i]) flag = 1 next else flag = 2 } This doesn't seem to be working. For some reason, all the conditions are evaluated as TRUE and flag is always 1.

R-Project: How to limit axes in SPI plot? ylim & xlim don't work

二次信任 提交于 2021-02-11 08:59:28
问题 Dear stackoverflow community, I'm quite new in R and this is my first stackoverflow entry so please show mercy with me if it's not the perfect questioning. I'm calculating standardized precipitation index (SPI) with the package "SPEI" for a time series of a climate station with 20 years of monthly precipitation data. I have done this for the timescale of 1 and 12 month like this: spi1 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 1) spi12 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 12) The output of SPI is

httr POST authentication error

一笑奈何 提交于 2021-02-11 08:58:25
问题 I am trying to structure a POST json request using httr. The API documentation proposes the following the CURL request: curl -X POST -H "Authorization:Token XXXXXXXXX" -H "Content-Type: application/json" --data "{\"texts\":[\"A simple string\"]}" https://api.uclassify.com/v1/uclassify/topics/classify My R httr implementation is the following: POST("https://api.uclassify.com/v1/uClassify/Topics/classify", encode="json", add_headers('Authorization:Token'="XXXXXXXXX"), body=("A simple string"))

use makeActiveBinding inside a package

夙愿已清 提交于 2021-02-11 08:50:41
问题 I simply need a R function like: > la. <- function (envir = globalenv()) {ls(all = T, envir = envir) }` with an active binding so I do need to type brackets > makeActiveBinding('la', la., globalenv()) So that > la [1] "la" "la." I now want to implement function la() and it bind la inside a package So that when I load the package, la is ready available. How can I bind function la.() to the symbol la within the package environment? What value shall I pass to the envir argument of function

Setting index in a tsibble

落花浮王杯 提交于 2021-02-11 08:47:13
问题 Do you ever look back a your old questions and feel a bit embarrassed? I just did, and now I do. And I'll probably feel the same about this one at some point. I'm trying to move my forecasting work to fable . In the process I'm trying to use a tsibble . Previously with a ts object I just set the start year and frequency. Now the tsibble is looking for a date object. However I have data which is biannual (fall and spring semester). And the variable is irregular (which I would like to keep).

train,validation, test split model in CARET in R

南笙酒味 提交于 2021-02-11 08:35:59
问题 I would like to ask for help please. I use this code to run the XGboost model in the Caret package. However, I want to use the validation split based on time. I want 60% training, 20% validation ,20% testing. I already split the data, but I do know how to deal with the validation data if it is not cross-validation. Thank you, xgb_trainControl = trainControl( method = "cv", number = 5, returnData = FALSE ) xgb_grid <- expand.grid(nrounds = 1000, eta = 0.01, max_depth = 8, gamma = 1, colsample

train,validation, test split model in CARET in R

霸气de小男生 提交于 2021-02-11 08:35:28
问题 I would like to ask for help please. I use this code to run the XGboost model in the Caret package. However, I want to use the validation split based on time. I want 60% training, 20% validation ,20% testing. I already split the data, but I do know how to deal with the validation data if it is not cross-validation. Thank you, xgb_trainControl = trainControl( method = "cv", number = 5, returnData = FALSE ) xgb_grid <- expand.grid(nrounds = 1000, eta = 0.01, max_depth = 8, gamma = 1, colsample

Different color for different cluster in a tree using adegenet R package

我的未来我决定 提交于 2021-02-11 08:35:10
问题 I am using the R package adegenet to plot the neighbor-joining tree. In my file I have 20,000 columns and 500 rows. Rows correspond to individuals. My first column is Population ID and second column is Individual ID. Columns contain values 0,1 & 2. I am able to plot a tree in one color, but depending upon the population I want every cluster to be a different color. This is what I did, If "dat" is my data file,then D<-dist(as.matrix(dat)) tre<-nj(D) plot(tre, type = "unr", show.tip.lab = TRUE,