小编NBE*_*NBE的帖子

根据r中的多列查找数据框中的重复行

我有一个数据集,其中有一些实例,对于同一日期和时间的给定位置,该值不同。我正在尝试创建一个显示这些实例的子集数据框。这是我的意思的一个例子: 在此处输入图片说明

我在 SO 上看过类似的问题,但我似乎无法得到我想要的。我不断找回情况并非如此。

这是我正在使用的代码:

dat1<-data_concern_join2%>%
 group_by(locid,stdate,sttime,charnam,valunit)%>%
  filter(n()>1) 
Run Code Online (Sandbox Code Playgroud)

样本数据:

structure(list(orgid = c("USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ", 
"USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ", 
"USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ", "USGS-NJ"), locid = c("USGS-01396030", 
"USGS-01396030", "USGS-01389850", "USGS-01389850", "USGS-01391500", 
"USGS-01391500", "USGS-01391500", "USGS-01391500", "USGS-01393960", 
"USGS-01390610", "USGS-01391500", "USGS-01390610", "USGS-01391500", 
"USGS-01378760", "USGS-01378760"), stdate = structure(c(11359, 
11359, 11359, 11359, 16504, 16504, 16112, 16112, 11367, 13860, 
12401, 13860, 16325, 13006, 13006), class = "Date"), sttime = structure(c(34200, 
34200, 36000, 36000, 40500, 40500, 39600, 39600, 36000, 39600, 
32400, 39600, 38400, 36900, 36900), …
Run Code Online (Sandbox Code Playgroud)

r duplicates dataframe dplyr

6
推荐指数
1
解决办法
7572
查看次数

R:使用north2()创建带有指北针的地图后,使用ggsave保存图表

我对 R 非常陌生,因此我们将不胜感激!我想在创建地图后使用 ggsave 函数保存带有指北针的地图。然而,在我的地图中,我使用 ggsn 包中的函数north2(),它只保存地图而不是指北针。我知道我可能错过了一些非常简单的东西,但我似乎无法弄清楚。我究竟做错了什么??提前致谢。

graph1<-ggplot()+
  geom_polygon(data=df,colour="black",aes(x=long,y=lat,group=group,fill=ALG))+
  ggtitle("Figure 2.2A: Assessment Results for\nGeneral Aquatic Life Use, Spatial Extent")+
  xlab("")+
  ylab("")+
  coord_equal()+
  coord_fixed(ratio = 1)+
  ggsn::scalebar(df,location="bottomleft",dist = 50,st.dist=0.02,st.size=3, height=0.01)+
  scale_fill_manual("Aquatic Life Designated\nUse 2014 Assessment",values=c((values=c(colors))))+
  cowplot::background_grid(major= "none",minor = "none") +
  theme(axis.text.x = element_blank(), axis.ticks.x = element_blank(),
        axis.text.y = element_blank(), axis.ticks.y = element_blank(),
        axis.line = element_blank(),
        panel.background = element_blank(),
        legend.position=c(0.8,0.1),
        panel.border = element_rect(fill=NA),
        legend.background = element_blank(),
        legend.text = element_text(size=7),
        legend.title = element_text(colour="black", size=8, face="bold"),
        plot.title=element_text(size=15, face="bold",vjust=1.0,hjust = .3))

ggsave(file="Figure 2.2A.pdf",width=11.5,height=8)
north2(graph1, x …
Run Code Online (Sandbox Code Playgroud)

maps r ggplot2

5
推荐指数
1
解决办法
744
查看次数

如何在带有ggplotly()的闪亮应用程序中使用plotlyProxy()以使绘图更快地渲染

我一直在寻找一个与此相关的问题,但是我还没有看到任何问题ggplotly()。该图基于用户selectInput()下拉菜单是反应式的。一切正常,但是当我单击下拉菜单中的新参数时,绘制图形需要很长时间。通过调查,我发现了这篇文章,“ 改进ggplotly转换”,这解释了为什么绘图需要很长时间才能呈现(我有很多数据)。在网站上说使用plotlyProxy()。但是,我很难将其实现到我的代码中。更具体地说,我不了解如何使用plotlyProxyInvoke()必须与之配合使用的功能。我将不胜感激任何指导!

样本数据:

  df<-structure(list(stdate = structure(c(17694, 14581, 14162, 14222, 
    17368, 16134, 17414, 13572, 17613, 15903, 14019, 12457, 15424, 
    13802, 12655, 14019, 16143, 17191, 13903, 12362, 12929, 13557, 
    16758, 13025, 15493, 16674, 15959, 15190, 16386, 11515, 12640, 
    15295, 15664, 15145, 17077, 14914, 14395, 14992, 13271, 12730
    ), class = "Date"), sttime = structure(c(35460, 42360, 32880, 
    30600, 26760, 45000, 36000, 32700, 39000, 35460, 34200, 28800, 
    26400, 33900, 39600, 29280, 34500, 28920, 31320, 34800, …
Run Code Online (Sandbox Code Playgroud)

r plotly ggplotly r-plotly

5
推荐指数
1
解决办法
312
查看次数

在 ShinydashboardPlus 中单击 menuItem 时自动弹出 rightSidebar

我有一个闪亮的应用程序,我是用 ShinydashboardPlus 和 Shinydashboard 制作的,我希望当用户单击带有我的图的 menuItem 时自动打开 rightSidebar。

几个小时以来,我一直试图找到这个问题的答案,但我什么也没找到。我不确定这是否可行,但我想我会在这里询问是否有人对如何做到这一点有任何见解(如果可能)。

示例应用程序:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

header<-dashboardHeaderPlus(enable_rightsidebar = TRUE,
rightSidebarIcon = "bars")

sidebar<- dashboardSidebar(
sidebarMenu(
menuItem("Data",
tabName = "data"),
menuItem("Plots",
tabName = "plots",
icon = icon("bar-chart-o"))))

body<-dashboardBody(
tabItems(
tabItem(tabName = "data","DATA"),
tabItem(tabName = "plots",
box(plotOutput("plot1")))))

rightsidebar<-rightSidebar(
background = "dark",
rightSidebarTabContent(
id=1,
title = "Customize Plots",
icon = "desktop",
active = T,
sliderInput("slider", "Number of observations:", 1, 100, 50)))

ui<- dashboardPagePlus(header = header,
sidebar = sidebar,
body = body,
rightsidebar = rightsidebar,

)

server<- …
Run Code Online (Sandbox Code Playgroud)

r shiny shinydashboard

1
推荐指数
1
解决办法
737
查看次数

标签 统计

r ×4

dataframe ×1

dplyr ×1

duplicates ×1

ggplot2 ×1

ggplotly ×1

maps ×1

plotly ×1

r-plotly ×1

shiny ×1

shinydashboard ×1