r

How to fuzzy join 2 dataframes on 2 variables with differing “fuzzy logic”?

元气小坏坏 提交于 2021-02-11 13:31:44
问题 # example a <- data.frame(name=c("A","B","C"), KW=c(201902,201904,201905),price=c(1.99,3.02,5.00)) b <- data.frame(KW=c(201903,201904,201904),price=c(1.98,3.00,5.00),name=c("a","b","c")) I want to match a and b with fuzzy logic, using the variables KW and price. I want to allow a tolerance of +/- 1 for KW and a tolerance for +/- 0.02 in price. The desired outcome should look like this: name.x KW.x price.x KW.y price.y name.y 1 A 201902 1.99 201903 1.98 a 2 B 201904 3.02 201904 3.00 b 3 C

Weibull distribution with weighted data

半世苍凉 提交于 2021-02-11 13:31:08
问题 I have some time to event data that I need to generate around 200 shape/scale parameters for subgroups for a simulation model. I have analysed the data, and it best follows a weibull distribution. Normally, I would use the fitdistrplus package and fitdist(x, "weibull") to do so, however this data has been matched using kernel matching and I have a variable of weighting values called km and so needs to incorporate a weight, which isn't something fitdist can do as far as I can tell. With my

AddLegend Display Value range instead of percentage when using colorQuantile

一个人想着一个人 提交于 2021-02-11 13:31:07
问题 I am using R shiny-dashboard to display a weather raster file. I used colorQuantile as the method to display the color. In the legend, it shows the percentage. As you can see in the following image. I want the labels in the legend show the range of the value instead for each bin. I am not sure how to do that. Here is my server.R output$weather_map <- renderLeaflet({ rw = weatherband() if (!is.null(rw)) { pal_w = colorQuantile('RdYlGn', values(rw), na.color = 'transparent', n = 7) leaflet() %>

Weibull distribution with weighted data

前提是你 提交于 2021-02-11 13:31:04
问题 I have some time to event data that I need to generate around 200 shape/scale parameters for subgroups for a simulation model. I have analysed the data, and it best follows a weibull distribution. Normally, I would use the fitdistrplus package and fitdist(x, "weibull") to do so, however this data has been matched using kernel matching and I have a variable of weighting values called km and so needs to incorporate a weight, which isn't something fitdist can do as far as I can tell. With my

AddLegend Display Value range instead of percentage when using colorQuantile

倖福魔咒の 提交于 2021-02-11 13:31:01
问题 I am using R shiny-dashboard to display a weather raster file. I used colorQuantile as the method to display the color. In the legend, it shows the percentage. As you can see in the following image. I want the labels in the legend show the range of the value instead for each bin. I am not sure how to do that. Here is my server.R output$weather_map <- renderLeaflet({ rw = weatherband() if (!is.null(rw)) { pal_w = colorQuantile('RdYlGn', values(rw), na.color = 'transparent', n = 7) leaflet() %>

How to fuzzy join 2 dataframes on 2 variables with differing “fuzzy logic”?

允我心安 提交于 2021-02-11 13:30:49
问题 # example a <- data.frame(name=c("A","B","C"), KW=c(201902,201904,201905),price=c(1.99,3.02,5.00)) b <- data.frame(KW=c(201903,201904,201904),price=c(1.98,3.00,5.00),name=c("a","b","c")) I want to match a and b with fuzzy logic, using the variables KW and price. I want to allow a tolerance of +/- 1 for KW and a tolerance for +/- 0.02 in price. The desired outcome should look like this: name.x KW.x price.x KW.y price.y name.y 1 A 201902 1.99 201903 1.98 a 2 B 201904 3.02 201904 3.00 b 3 C

AddLegend Display Value range instead of percentage when using colorQuantile

蹲街弑〆低调 提交于 2021-02-11 13:30:28
问题 I am using R shiny-dashboard to display a weather raster file. I used colorQuantile as the method to display the color. In the legend, it shows the percentage. As you can see in the following image. I want the labels in the legend show the range of the value instead for each bin. I am not sure how to do that. Here is my server.R output$weather_map <- renderLeaflet({ rw = weatherband() if (!is.null(rw)) { pal_w = colorQuantile('RdYlGn', values(rw), na.color = 'transparent', n = 7) leaflet() %>

Create bar plot with logarithmic scale in R

孤街醉人 提交于 2021-02-11 13:14:55
问题 I am trying to create a bar plot with a logarithmic scale as my data varies from 3.92 to 65700. This is the code i have used so far: beach <- c(PlasticsBlue=3.92, PlasticsGrey=65700, FoamsOrange=17.9, FoamsWhite=51300, RopesGreen=9.71, RopesGreen=3140) beach par(mar = c(10, 5, 10, 5)) barplot(beach, names.arg=c("Plastics/Blue", "Plastics/Grey", "Foams/Orange", "Foams/White", "Ropes/Green", "Ropes/Green"), col=c("red2", "slateblue4", "red2", "slateblue4", "red2", "slateblue4", "red2"), legend

Create bar plot with logarithmic scale in R

情到浓时终转凉″ 提交于 2021-02-11 13:14:30
问题 I am trying to create a bar plot with a logarithmic scale as my data varies from 3.92 to 65700. This is the code i have used so far: beach <- c(PlasticsBlue=3.92, PlasticsGrey=65700, FoamsOrange=17.9, FoamsWhite=51300, RopesGreen=9.71, RopesGreen=3140) beach par(mar = c(10, 5, 10, 5)) barplot(beach, names.arg=c("Plastics/Blue", "Plastics/Grey", "Foams/Orange", "Foams/White", "Ropes/Green", "Ropes/Green"), col=c("red2", "slateblue4", "red2", "slateblue4", "red2", "slateblue4", "red2"), legend

R: converting tidyverse to dplyr/reshape2 for plots

China☆狼群 提交于 2021-02-11 13:13:25
问题 In a previous post, a user showed me how to to plot longitudinal data in R. Here is the code: library(ggplot2) Data <- data.frame( "ID" = c("ABC111", "ABC111", "ABC111", "ABC111", "ABC112", "ABC112", "ABC112", "ABC113", "ABC113", "ABC114", "ABC115"), "color" = c("red", "red", "red", "red", "blue", "blue", "blue", "green", "green", "black", "yellow"), "start_date" = c("2005/01/01", "2006/01/01", "2007/01/01", "2008/01/01", "2009/01/01", "2010/01/01", "2011/01/01", "2012/01/01", "2013/01/01",