ggplot2

How to change a plot when hovering over elements in Shiny?

杀马特。学长 韩版系。学妹 提交于 2021-02-18 08:11:12
问题 I am searching for a solution to change a plot in a Shiny app when the user is hovering over a hyperlink in the same panel. Here is a simple example: library(shiny) words <- sort(sapply(1:50, USE.NAMES = F, FUN = function (x) paste(sample(letters, 15), collapse = "")), decreasing = T) dat <- data.frame(words, f = sort(rgamma(50, shape = 5, scale = 1))) ui <- pageWithSidebar( headerPanel("Playground"), sidebarPanel(), mainPanel( uiOutput("links"), plotOutput("out.plot") ) ) server <- function

How to change a plot when hovering over elements in Shiny?

你。 提交于 2021-02-18 08:11:07
问题 I am searching for a solution to change a plot in a Shiny app when the user is hovering over a hyperlink in the same panel. Here is a simple example: library(shiny) words <- sort(sapply(1:50, USE.NAMES = F, FUN = function (x) paste(sample(letters, 15), collapse = "")), decreasing = T) dat <- data.frame(words, f = sort(rgamma(50, shape = 5, scale = 1))) ui <- pageWithSidebar( headerPanel("Playground"), sidebarPanel(), mainPanel( uiOutput("links"), plotOutput("out.plot") ) ) server <- function

Order multiple variables in ggplot2

夙愿已清 提交于 2021-02-18 06:27:36
问题 I'm attempting to group variables within variables and sort in descending order. mydf region airport value MIA FLL 0.244587909 MIA PBI 0.824144687 MIA MIA 0.484907626 NYC EWR 0.731075565 NYC LGA 0.708648915 NYC HPN 0.523991258 LAX LGB 0.651847818 LAX LAX 0.423607479 LAX SNA 0.433837044 LAX ONT 0.723144957 Other MCO 0.657586674 Other SJC 0.084138321 Other OAK 0.698794154 Other BOS 0.85765002 Other BNA 0.018953126 Other WAS 0.234897245 https://i.stack.imgur.com/G1E2k.jpg I'm trying to reproduce

How to add label to geom_segment at the start of the segment?

浪尽此生 提交于 2021-02-18 06:25:31
问题 I'm sure this is simple but I can't figure it out. I have the following chart: library(data.table) library(magrittr) library(ggplot2) cambodia <- data.table(Period = c("Funan", "Chenla/Zhenla","Khmer Empire","Dark Ages of Cambodia"), StartDate = c(-500,550,802,1431), EndDate = c(550,802,1431,1863), Color = c("lightblue","lightgreen","lightyellow","pink")) %>% extract(order(-StartDate)) %>% extract(, Period := factor(Period,levels = Period)) ggplot() + geom_segment(data=cambodia, aes(x

ggsave losing unicode characters from ggplot+gridExtra

血红的双手。 提交于 2021-02-18 05:16:48
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

ggsave losing unicode characters from ggplot+gridExtra

£可爱£侵袭症+ 提交于 2021-02-18 05:09:00
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

ggsave losing unicode characters from ggplot+gridExtra

爷,独闯天下 提交于 2021-02-18 05:08:42
问题 More code than you really need, but to set the mood: #Make some data and load packages data<-data.frame(pchange=runif(80,0,1),group=factor(sample(c(1,2,3),80,replace=T))) library(dplyr) library(magrittr) library(gridExtra) library(ggplot2) data%<>%arrange(group,pchange) %>% mutate(num=1:80) #Make plot that includes unicode characters g1<-ggplot(data, aes(factor(num),pchange, fill = group,width=.4)) + geom_bar(stat="identity", position = "dodge") + theme_classic()+ theme(axis.ticks = element

ggplot2 mapping county boundries in one color and state boundries in another on the same map

喜夏-厌秋 提交于 2021-02-17 16:42:35
问题 I am creating a choropleth county map with grey borders, and I also want to include the state boundries in black. Does anyone know how I go about adding a second layer of state mapping to an existing county map? Here's the data set and code I ended up using: #load libraries library(ggplot2) library(ggmap) library(maps) library(plyr) #get wif file wip <- read.csv("wip.csv") #get map data for US counties and states county_map <- map_data("county") state_map <- map_data("state") #merge wip and

ggplot2 mapping county boundries in one color and state boundries in another on the same map

淺唱寂寞╮ 提交于 2021-02-17 16:39:36
问题 I am creating a choropleth county map with grey borders, and I also want to include the state boundries in black. Does anyone know how I go about adding a second layer of state mapping to an existing county map? Here's the data set and code I ended up using: #load libraries library(ggplot2) library(ggmap) library(maps) library(plyr) #get wif file wip <- read.csv("wip.csv") #get map data for US counties and states county_map <- map_data("county") state_map <- map_data("state") #merge wip and

Removing one level/group from Facet_wrap ggplot2 in R

你说的曾经没有我的故事 提交于 2021-02-17 07:15:06
问题 My tbl_df: > str(p2p_dt_SKILL_A) Classes ‘tbl_dt’, ‘tbl’, ‘data.table’ and 'data.frame': 693 obs. of 35 variables: $ Patch : Factor w/ 7 levels "BVG1","BVG11",..: 1 2 3 4 5 6 7 1 2 3 ... $ Skill : Factor w/ 15 levels "A","BROADBAND",..: 1 1 1 1 1 1 1 1 1 1 ... $ Date : Date, format: "2015-12-04" "2015-12-04" "2015-12-04" "2015-12-04" ... $ SOD_FWIH_A : num 1.09 1.14 1.09 1.1 1.09 1.07 1.09 1.07 1.12 1.07 ... $ Prod_MWF : num 5.06 5.06 5.44 5.34 4.22 4.72 4.89 4.68 4.68 5.22 ... $ Prod_MA :