group_byコマンドを使用して、光沢のある動的データフレームを作成します。R shiny dplyr GROUP_BYコマンドのエントリがありません
所望のテーブルの行数は、RVの$ VARの値に依存します。行の数はCL ==「1」 とCLの間で異なっているように、いくつかの地区は(010102、010103,160101) が空いているハウジングを持っていないので
==「2」、それは動作しません。
に住宅の種類ごとに同じ数の行を得るために、これらの区域を0で表に表示するにはどうすればよいですか?
これが私のテーブルの一部である:
PC;COUN;DISTRICT;HOUSING;CL
01:0101; 010101; 01; 1
01:0101; 010101; 02; 1
01:0101; 010101; 03; 1
01:0101; 010101; 04; 2
01:0101; 010101; 05; 1
01:0102; 010102; 01; 1
01:0102; 010102; 02; 1
01:0102; 010102; 03; 1
01:0102; 010102; 04; 1
01:0102; 010102; 05; 1
01:0103; 010103; 01; 1
01:0103; 010103; 02; 1
01:0103; 010103; 03; 1
01:0103; 010103; 04; 1
01:0103; 010103; 05; 1
15:1501; 150101; 01; 1
15:1501; 150101; 02; 2
15:1501; 150101; 03; 1
15:1501; 150101; 04; 1
15:1501; 150101; 05; 1
16:1601; 160101; 01; 1
16:1601; 160101; 02; 1
16:1601; 160101; 03; 1
16:1601; 160101; 04; 1
21:2101; 210101; 01; 1
21:2101; 210101; 02; 1
21:2101; 210101; 03; 2
21:2101; 210101; 04; 1
21:2101; 210101; 05; 2
25:2501; 250101; 01; 1
25:2501; 250101; 02; 1
25:2501; 250101; 03; 1
これは私が書いたコードの一部です:
selectionAcc_View <- reactive({
if (rv$CHAMP == "DISTRICT") {
selectionAccomodations <- reactive({
return(filter(myTable, DISTRICT %in% rv$VAR))})
tmp <- selectionAccomodations()
dfACC <- tmp %>%
group_by(DISTRICT) %>%
summarize(Accomodations=n())
dfMA <- filter(tmp, CL == "1" %>%
group_by(DISTRICT) %>%
summarize(MA=n())
dfVH <- filter(tmp, CL == "2" %>%
group_by(DISTRICT) %>%
summarize(VH=n())
# Create table
df <- data.frame(
Total_Accomodations = c(dfACC$Accomodations), # Number of Accomodations
Main_Accomodations = c(dfMA$MA), # Number of Main Accomodations
Vacant_Housings = c(dfVH$VH) # Number of Vacant Housings
) # end of data.frame
} # end of if
df
}) # End of selectionAcc_View <- reactive({
# Output the table
output$df <- renderDataTable(selectionAcc_View(),options = list(paging =
FALSE, ordering = FALSE,searching = FALSE,info = FALSE))
}) # End of shinyServer(function(input, output, session) {
、あなたのアイデアを持っているでしょうしてください?
ありがとうございました。私はとにかく、いくつかのdply
練習を必要に応じて
をとても素晴らしいです!私は感心しています、それはまさに私がやりたいことです。自分のコードを自分のプログラムに適応させます。マイクありがとうございました。 –
upvoteにも感謝します。 –
申し訳ありませんが、解決マークの上にある上向きの矢印をクリックするようにお願いしますか?はいの場合は、もう一度、ありがとうございます。 –