小编Moh*_*hil的帖子

如何将数据从 PostgreSQL 数据库导入 R?

我正在考虑使用 package.json 将数据库中的数据直接导入到 r 中RPostgresQL。到目前为止,我曾经在Postico(PostgreSQL 客户端)软件中编写查询并导出为 csv,然后将 csv 文件导入 R。
这是我到目前为止所写的内容,不知道下一步如何进行。

library('RPostgreSQL')
pg=dbDriver("PostgreSQL")
con = dbConnect(pg, user="msahil515", password="",
            host="localhost", port=5432, dbname="msahil515")
Run Code Online (Sandbox Code Playgroud)

在此之后如何将数据库中的表加载到 R 中,或者如何在 R 中编写查询以仅从数据库中提取必要的数据?

postgresql r rpostgresql postico

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

如何在闪亮模块的数据表中添加复选框?

我有一个闪亮的模块,它显示一个带有评论列的表格,用户可以在客户端输入文本,然后评论将存储在数据库中。现在,我想添加另一列带有复选框并将其相应的值(TRUE/FALSE)存储在数据库中。不确定如何从表中检索复选框值。以下是我对示例数据的尝试。

library(tidyverse)
library(shinyWidgets)
library(shiny)
library(htmlwidgets)


mtcars_df <- mtcars %>% 
  rownames_to_column(var="car")


writeback_UI <- function (id) {
  ns <- NS(id)

  DT::dataTableOutput(ns('records_tbl'))
  
}
shinyInput = function(FUN, len, id, ...) {
  inputs = character(len)
  for (i in seq_len(len)) {
    inputs[i] = as.character(FUN(paste0(id, i), label = NULL, ...))
  }
  inputs
}

# obtain the values of inputs
shinyValue = function(id, len) {
  unlist(lapply(seq_len(len), function(i) {
    value = input[[paste0(id, i)]]
    if (is.null(value)) NA else value
  }))
}




writeback_server <- function (id,records_data) {
  #stopifnot(is.reactive(records_data))
  shiny::moduleServer(id, function (input,output,session) …
Run Code Online (Sandbox Code Playgroud)

checkbox r shiny dt shinymodules

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

标签 统计

r ×2

checkbox ×1

dt ×1

postgresql ×1

postico ×1

rpostgresql ×1

shiny ×1

shinymodules ×1