r

Unfilled area in ggplot geom_area

我是研究僧i 提交于 2021-02-11 04:58:24
问题 I'm trying to do a plot with ggplot2 and geom_area . The fill is set by a variable. For some reason, only the 'outer' groups are filled. I can't figure out how to get the inner regions filled as well. The same problem seems to occur here but no answer is given on how to solve it. Below is an minimal example of the code i'm using and the resulting plot: I'm using R 3.3 and ggplot2_2.1.0 Any help would be appreciated. df <- data.frame(month = seq(from = as.Date("2016-01-01"), to = as.Date("2016

Labeling: Facet grid with multiple lines of text on y label

≡放荡痞女 提交于 2021-02-11 04:56:14
问题 I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible? majors.sub.HS<- majors.sub[, c(8:10, 66)] majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" ) majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5 majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

R ggplot stacked geom_rect

落爺英雄遲暮 提交于 2021-02-11 04:54:56
问题 I would like to draw a bar chart with ggplot where I adjust the width of the bars. I have found an example here which works perfectly fine. But instead of one bar per row in the data frame I would like to make a stacked bar of 2 to 4 columns. Here is the code of the original: library(ggplot2) # make data data=data.frame(group=c("A ","B ","C ","D ") , value=c(33,62,56,67) , number_of_obs=c(100,500,459,342)) # Calculate the future positions on the x axis of each bar (left border, central

R ggplot stacked geom_rect

ぃ、小莉子 提交于 2021-02-11 04:54:30
问题 I would like to draw a bar chart with ggplot where I adjust the width of the bars. I have found an example here which works perfectly fine. But instead of one bar per row in the data frame I would like to make a stacked bar of 2 to 4 columns. Here is the code of the original: library(ggplot2) # make data data=data.frame(group=c("A ","B ","C ","D ") , value=c(33,62,56,67) , number_of_obs=c(100,500,459,342)) # Calculate the future positions on the x axis of each bar (left border, central

Loop through (subsets) using jags

老子叫甜甜 提交于 2021-02-11 04:54:13
问题 I have a big dataframe with 10000 rows and 12 columns (discountdataset). The columns contain different variables. The first 210 rows represents subject 1 (there is also a column with "subject1"), the next 210 rows represent subject 2, and so on. I want to use jags and a loop function to loop through all 52 subjects in the dataframe, and assign a function to each of them. My code looks like this: #subsetting the dataframe by the variable subjectid subsetdiscount <- split(discountdataset, as

Interpolate data for irregular time series

此生再无相见时 提交于 2021-02-11 04:53:13
问题 I try to interpolate this meterValue, full csv here: https://drive.google.com/open?id=18cwtw-chAB-FqqCesXZJ-6NB6eHFJlgQ localminute,dataid,meter_value 2015-10-03 09:51:53,6578,157806 2015-10-13 13:41:49,6578,158086 : : 2016-01-17 16:00:33,6578,164544 #end of meter_value data for ID=6578 Based on what @G. Grothendieck, suggested, and I got error at z.interpolate (merging data) D6578z <- read.csv.zoo("test_6578.csv")[,2] D6578zd <- to.daily(D6578z)[,4] #Warning messages: #1: In zoo(xx, order.by

A way to not hardcode items in css with R Shiny app?

帅比萌擦擦* 提交于 2021-02-11 04:51:33
问题 I have the below code example (taken from here) . Is there a way for the below to work without hardcoding the values "a" and "b" in the html css? If I have hundreds of items I don't want to have to hardcode each one in the call to .option[data-value=a] etc. shinyApp( ui = shinyUI(fluidPage( tags$head( tags$style(HTML(" .option[data-value=a], .item[data-value=a]{ background: red !important; color: white !important; } .option[data-value=b], .item[data-value=b]{ background: green !important;

How can I make a counter for every country using a loop? R

可紊 提交于 2021-02-11 04:35:10
问题 I think this is very easy but I have no idea how to do it (or how to search it). Okay so I got 378 observations for a lot of countries. It goes like this ISO3C Date Country Vaccines Tests Confirmed Recovered Death Hospitalized Ventilation ICU 1 AFG 2020-01-01 Afghanistan 0 0 0 0 0 0 0 0 2 AFG 2020-01-02 Afghanistan 0 0 0 0 0 0 0 0 3 AFG 2020-01-03 Afghanistan 0 0 0 0 0 0 0 0 4 AFG 2020-01-04 Afghanistan 0 0 0 0 0 0 0 0 5 AFG 2020-01-05 Afghanistan 0 0 0 0 0 0 0 0 So How do I set a counter

How can I make a counter for every country using a loop? R

守給你的承諾、 提交于 2021-02-11 04:31:48
问题 I think this is very easy but I have no idea how to do it (or how to search it). Okay so I got 378 observations for a lot of countries. It goes like this ISO3C Date Country Vaccines Tests Confirmed Recovered Death Hospitalized Ventilation ICU 1 AFG 2020-01-01 Afghanistan 0 0 0 0 0 0 0 0 2 AFG 2020-01-02 Afghanistan 0 0 0 0 0 0 0 0 3 AFG 2020-01-03 Afghanistan 0 0 0 0 0 0 0 0 4 AFG 2020-01-04 Afghanistan 0 0 0 0 0 0 0 0 5 AFG 2020-01-05 Afghanistan 0 0 0 0 0 0 0 0 So How do I set a counter

R: Is there a way to count the number of consecutive numbers in each row?

☆樱花仙子☆ 提交于 2021-02-11 04:30:30
问题 I'm wondering if there's a way to count the number of consecutive numbers in each row. Ideally, the output will be in column V6 and count the number of consecutive numbers in columns V1-V5. For example, Row 1 - 1, 2, 3, 4, 5 since there are 5 consecutive numbers, the output will be 5. I've attached the dataset that I have below for your reference. Thanks. enter image description here 回答1: Here is an option where we get the difference between alternate columns by removing the first column,