r

Embed column with mixed numericInput and selectInput in DT

冷暖自知 提交于 2021-02-11 12:29:27
问题 I would like to add a column to a DT that accepts either selectInput or numericInput, depending on the variable. For example, given the following DF: df1 <- tibble( var1 = sample(letters[1:3],10,replace = T), var2 = runif(10, 0, 2), id=paste0("id",seq(1,10,1)) ) DF=gather(df1, "var", "value", -id) I would like to create an extra col in the DF (using DT ), with selectInput for var1 (choices= letters[1:3]) and numericInput for var2 . I have found here a great example for implementing

Plotly: manual fillcolor for boxplot

白昼怎懂夜的黑 提交于 2021-02-11 12:29:06
问题 I've a boxplot, but I want to use manual colors for the fill of eachone. code: p <- plot_ly(tvs, x = ~ecommerce, y = ~precio_actual, color = ~ecommerce, type = "box") %>% layout(boxmode = "group") p colors I need to use: ecommerce_colors <- c("lacuracao" = "#ffda33","ripley" = "#802D69","falabella" = "#BED800", 'wong' = "red", "tottus" = "#fa3e14") 来源: https://stackoverflow.com/questions/56879211/plotly-manual-fillcolor-for-boxplot

R: Using aggregate within a function, not working

你。 提交于 2021-02-11 12:28:17
问题 I am fairly new to R so apologies if an answer to this already exists that I am unable to find. I cannot replicate the exact error I have with my own dataset, but since an error is produced nonetheless here we go. What I am trying to do is to create a function to calculate the average of several columns conditionnal on the values of other ones. Let's say that d1 <- c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4) d2 <- c(1:12) d3 <- c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2) df <- cbind(d1, d2, d3)

Shapiro Wilks test is not working in R markdown

落爺英雄遲暮 提交于 2021-02-11 12:23:39
问题 I am working on a piece of r markdown code. I am simply applying a shapiro.wilks test on a data. When I try to run the code in R studio in usual way, I dont get any issue. But when I try to run the code in r markdown, I am getting error provided below: Error in shapiro.test(Metric) : sample size must be between 3 and 5000 Calls: ,Anonymius> ... summarise -> summarise.tbl_df -> summarise_impl _> shapiro.test In addition: There were 32 warnings (use warnings() to see them) Warnings are: Code is

Understanding why action buttons in Shiny don't work, when using several of them

邮差的信 提交于 2021-02-11 12:23:32
问题 Why when I put together several action button codes from Shiny manual (https://shiny.rstudio.com/articles/action-buttons.html), it DOES NOT run (i.e. no button reacts) ? Each code separately runs fine. How to fix it? (This is relates to this post: Convert Shiny App R code to Rmarkdown Shiny App code: with observeEvent and eventReactive) # Code from https://shiny.rstudio.com/articles/action-buttons.html library(shiny) ui <- fluidPage( # Pattern 1 - Command tags$head(tags$script(src = "message

Including an image in R Markdown PDF table

会有一股神秘感。 提交于 2021-02-11 12:23:32
问题 I am working in R Markdown, knitting to PDF. I thought the following code should create a table with a local image, but it is not working. Any help would be greatly appreciated! column1 <- c("1", "2", "3") column2 <- c("a", "b", "c") column3 <- c("x", "y", "z") dat <- data.frame(column1, column2, column3) dat$column1[1] <- "![image1](green.png){ width=25px }" print(kable(dat)) 回答1: --- title: "pic in column" author: "test" date: "2014/08/03" output: html_document --- ```{r results='asis'}

R devtools::install_github(“jzsbioinfo/APRD”) Error in utils::download.file(url, path, method = method, quiet = quiet,

元气小坏坏 提交于 2021-02-11 12:22:01
问题 R devtools::install_github("jzsbioinfo/APRD") Error in utils::download.file(url, path, method = method, quiet = quiet, : Can not open URL'https://api.github.com/repos/jzsbioinfo/APRD/tarball/master' My session info: ─ Session info ──────────────────────────────────────────────────────────────────────────── setting value version R version 3.6.2 (2019-12-12) os Windows 10 x64 system x86_64, mingw32 ui RStudio language (EN) Methods I have tried but doesn't work: options(download.file.method =

Plot conditional color with NA data

蹲街弑〆低调 提交于 2021-02-11 12:21:59
问题 I have a data frame in R that has 2 numeric fields, 1 of these fields can contain NA values. I want to plot the first field and base the col off if the second field is NA or not. CurrentBackLog = as.data.frame(list(DaysSinceCreted=c(34,50,22,6),DaysSinceReady=c(NA,10,22,NA))) This only shows the items where DaysSinceReady is NOT NA... plot(CurrentBackLog$DaysSinceCreated, main = 'Days Since Created by Ticket', ylab = 'Days Since Created', pch = 15, col = ifelse(CurrentBackLog$DaysSinceReady>1

Unable to load tidycensus and map view packages on Macbook

此生再无相见时 提交于 2021-02-11 12:19:21
问题 I installed the packages tidycensus and mapview in RStudio but I get the following error when I try load either one: library(tidycensus) Error: package or namespace load failed for ‘tidycensus’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so': dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so, 6): Library not loaded: /usr/lib/libpq.5.dylib Referenced from:

How to divide specific column with rest of columns

泄露秘密 提交于 2021-02-11 12:18:24
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide