r

R shiny dashboard tabItems not apparing

大兔子大兔子 提交于 2021-02-19 11:33:26
问题 Here's my ui.R and server.R. I'm not sure why the headers in dashboardBody don't show up. server.R shinyServer(function(input, output){ }) ui.R dashboardPage( dashboardHeader(title = "Analysis"), dashboardSidebar( sidebarMenu( menuItem("Data Pull", tabName = "dataPull", icon = icon("database"), dateInput("startDateInput", "What is the starting date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"), dateInput("endDateInput",

rbind data.frames in a list in R

风格不统一 提交于 2021-02-19 09:30:30
问题 Suppose we have 3 list s of data.frame s. In BASE R, I was wondering how I could automatically (ex. in a looping structure) rbind the data.frame s within these 3 lists? Please note I want the looping structure so it can rbind any more number of similar lists (ex. g4 g5 ...) g1 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) g2 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) g3 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) 回答1: Here is an option with base R do.call(rbind, lapply(mget(ls

rbind data.frames in a list in R

孤人 提交于 2021-02-19 09:25:12
问题 Suppose we have 3 list s of data.frame s. In BASE R, I was wondering how I could automatically (ex. in a looping structure) rbind the data.frame s within these 3 lists? Please note I want the looping structure so it can rbind any more number of similar lists (ex. g4 g5 ...) g1 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) g2 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) g3 <- list(b1 = list(data.frame(a = 1:3, b = 3:5))) 回答1: Here is an option with base R do.call(rbind, lapply(mget(ls

Using dplyr to create new dataframe depending on thresholds

两盒软妹~` 提交于 2021-02-19 08:57:20
问题 Groups Names COL1 COL2 COL3 COL4 1 G1 SP1 1 0.400 0.500 Sequence1 2 G1 SP1 1 0.004 0.005 Sequence2 3 G1 SP1 0 0.004 0.005 Sequence3 4 G1 SP2 0 0.400 0.005 Sequence123 5 G1 SP2 0 0.004 0.500 Sequence14 6 G1 SP3 0 0.005 0.006 Sequence15 7 G1 SP5 1 0.400 0.006 Sequence16 8 G1 SP6 1 0.008 0.002 Sequence20 10 G2 Sp1 0 0.004 0.005 Sequence17 11 G2 SP1 0 0.050 0.600 Sequence18 12 G2 SP1 0 0.400 0.600 Sequence3 13 G2 SP2 0 0.004 0.005 Sequence22 14 G2 SP2 0 0.004 0.005 Sequence23 15 G2 SP5 0 0.004 0

Using dplyr to create new dataframe depending on thresholds

六月ゝ 毕业季﹏ 提交于 2021-02-19 08:57:11
问题 Groups Names COL1 COL2 COL3 COL4 1 G1 SP1 1 0.400 0.500 Sequence1 2 G1 SP1 1 0.004 0.005 Sequence2 3 G1 SP1 0 0.004 0.005 Sequence3 4 G1 SP2 0 0.400 0.005 Sequence123 5 G1 SP2 0 0.004 0.500 Sequence14 6 G1 SP3 0 0.005 0.006 Sequence15 7 G1 SP5 1 0.400 0.006 Sequence16 8 G1 SP6 1 0.008 0.002 Sequence20 10 G2 Sp1 0 0.004 0.005 Sequence17 11 G2 SP1 0 0.050 0.600 Sequence18 12 G2 SP1 0 0.400 0.600 Sequence3 13 G2 SP2 0 0.004 0.005 Sequence22 14 G2 SP2 0 0.004 0.005 Sequence23 15 G2 SP5 0 0.004 0

filter one dataframe via conditions in another

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-19 08:55:24
问题 I want to recursively filter a dataframe, d by an arbitrary number of conditions (represented as rows in another dataframe z ). I begin with a dataframe d : d <- data.frame(x = 1:10, y = letters[1:10]) The second dataframe z , has columns x1 and x2 , which are lower and upper limits to filter d$x . This dataframe z may grow to be an arbitrary number of rows long. z <- data.frame(x1 = c(1,3,8), x2 = c(1,4,10)) I want to return all rows of d for which d$x <= z$x1[i] and d$x >= z$x2[i] for all i

Convert English numbers to Persian for ggplot

99封情书 提交于 2021-02-19 08:32:30
问题 I am working on a data visualization project using ggplot . I have my original data in English: world_ecommerce <- data.frame( year = factor(c(2014, 2015, 2016, 2017, 2018)), score = c(1336, 1548, 1845, 2304, 2842) ) I want to visualize it as a bar chart and show all numbers in persian. My original Bar chart is: ggplot( world_ecommerce, aes(x = year, y = score, label = score), fill = "#56c7da" ) + geom_bar( stat = "identity", fill = "#56c7da", position = position_dodge(), width = 0.5, size =

R: how to add rows based on the value in a column

这一生的挚爱 提交于 2021-02-19 08:09:10
问题 I have a data frame that looks like this: line = c(1, 2, NA, 4 ,5, NA, 7) group = c("1.0 Group A", "2.0 Group B", "3.0 Group C", "4.0 Group D", "5.0 Group E", "6.0 Group F", "7.0 Group G") df <- data.frame(line, group) view(df) line group 1 1 1.0 Group A 2 2 2.0 Group B 3 NA 3.0 Group C 4 4 4.0 Group D 5 5 5.0 Group E 6 NA 6.0 Group F 7 7 7.0 Group G What I want to do is to find all the NA value in the "line" column and place a row underneath that row in "group" column saying "Not Applicable"

“empty data message” in renderTable

会有一股神秘感。 提交于 2021-02-19 08:01:55
问题 I user renderTable to show some data. However, sometimes the data table is empty, in which case I'd like to print "No data to show" or something similar. the default by renderTable is to show nothing for empty data. can this be changed? how? 回答1: You can use a condition into a renderUi to render either a message or a "tableOutput" (you can't render directly the table) datas <- data.frame() shiny::runApp(list( ui = pageWithSidebar( headerPanel("Example"), sidebarPanel( selectInput("dataset",

Recursive function in R with ending point varying by group

核能气质少年 提交于 2021-02-19 08:01:41
问题 I wish to use a recursive structure in my dplyr change that iterates on the number of lags used on certain operations. The thing is that I am not sure how to set its ending point since it resembles more a while than a for loop, which makes me a bit insecure. Here is some sample data. Groups are not necessarily the same size and are indexed by id df <- data.frame(id = c(1, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5), p201 = c(NA, NA, "001", NA, NA, NA, "001", "001", "001", NA, NA), V2009 = c(25, 11, 63, 75,