Browse Source

Cambiar etiquetas y corregir tabla con espacios en blanco y NA.

master
marcelcosta 3 years ago
parent
commit
031177217a
1 changed files with 34 additions and 31 deletions
  1. +34
    -31
      app.R

+ 34
- 31
app.R

@ -2,7 +2,7 @@ library(shiny)
library(rhandsontable) library(rhandsontable)
DF<-as.data.frame(matrix(nrow=1, ncol=5)) DF<-as.data.frame(matrix(nrow=1, ncol=5))
colnames(DF)<-c("name","conc.vector","bp.vector","conc.insert","bp.insert")
colnames(DF)<-c("ID","Concentració Vector (ng)","Longitud Vector (bp)","Concentració Insert (ng)","Longitud Insert (bp)")
DF[1,]<-rep("",5) DF[1,]<-rep("",5)
ui <- fluidPage( ui <- fluidPage(
@ -24,7 +24,7 @@ ui <- fluidPage(
max = 1.25, max = 1.25,
value = 0.5, step = 0.1), value = 0.5, step = 0.1),
sliderInput("voltotal", sliderInput("voltotal",
"Volum Total:",
"Volum Total (V vector+V insert):",
min = 1.5, min = 1.5,
max = 2.5, max = 2.5,
value = 2, step = 0.5), value = 2, step = 0.5),
@ -59,7 +59,6 @@ server <- function(input, output) {
}) })
output$hot <- renderRHandsontable({ output$hot <- renderRHandsontable({
print(DF)
if (!is.null(DF)){ if (!is.null(DF)){
rhandsontable(DF, stretchH = "all", readOnly = F, useTypes = T) rhandsontable(DF, stretchH = "all", readOnly = F, useTypes = T)
} }
@ -68,37 +67,41 @@ server <- function(input, output) {
output$results <- renderTable({ output$results <- renderTable({
observe({values}) observe({values})
t<-values[["DF"]] t<-values[["DF"]]
print(t)
if (nrow(t) > 1){
t[2:5]<-as.data.frame(apply(t[2:5],2,as.numeric))
t<-t[apply(t,1, function(x) any(is.na(x)|x=="") == F),]
if (nrow(t) < 1){
t
}else{ }else{
if (nrow(t) > 1){
t[2:5]<-as.data.frame(apply(t[2:5],2,as.numeric))
}else{
t[2:5]<-as.data.frame(t(apply(t[2:5],2,as.numeric))) t[2:5]<-as.data.frame(t(apply(t[2:5],2,as.numeric)))
}
Vv<-( (input$voltotal*t$`Concentració Insert (ng)`*t$`Longitud Vector (bp)`)/(t$`Concentració Vector (ng)`*t$`Longitud Insert (bp)`*input$ratio) ) / (1+(t$`Concentració Insert (ng)`*t$`Longitud Vector (bp)`)/(t$`Concentració Vector (ng)`*t$`Longitud Insert (bp)`*input$ratio))
Vi<-input$voltotal-Vv
t[,"Volum vector (ul)"]<-Vv
t[,"Volum insert (ul)"]<-Vi
t[,"Dilució vector"]<-1
t[,"Dilució insert"]<-1
Vv.log<-Vv < input$minim
if (TRUE %in% Vv.log){
alt.conc.vect<-( (input$voltotal-input$minim)*t$`Concentració Insert (ng)`*t$`Longitud Vector (bp)`)/ (input$minim*t$`Longitud Insert (bp)`*input$ratio)
t$`Dilució vector`[Vv.log]<-(t$`Concentració Vector (ng)`/alt.conc.vect)[Vv.log]
t$`Volum vector (ul)`[Vv.log]<-input$minim
t$`Volum insert (ul)`[Vv.log]<-(input$voltotal-input$minim)
}
Vi.log<-Vi < input$minim
if (TRUE %in% Vi.log){
alt.conc.insert<-( (input$voltotal-input$minim)*t$`Concentració Vector (ng)`*t$`Longitud Insert (bp)`*input$ratio)/ (input$minim*t$`Longitud Vector (bp)`)
t$`Dilució insert`[Vi.log]<-(t$`Concentració Insert (ng)`/alt.conc.insert)[Vi.log]
t$`Volum insert (ul)`[Vi.log]<-input$minim
t$`Volum vector (ul)`[Vi.log]<-(input$voltotal-input$minim)
}
t
} }
Vv<-( (input$voltotal*t$conc.insert*t$bp.vector)/(t$conc.vector*t$bp.insert*input$ratio) ) / (1+(t$conc.insert*t$bp.vector)/(t$conc.vector*t$bp.insert*input$ratio))
Vi<-input$voltotal-Vv
t[,"vol.v"]<-Vv
t[,"vol.i"]<-Vi
t[,"dil.v"]<-1
t[,"dil.i"]<-1
Vv.log<-Vv < input$minim
if (TRUE %in% Vv.log){
alt.conc.vector<-( (input$voltotal-input$minim)*t$conc.insert*t$bp.vector)/ (input$minim*t$bp.insert*input$ratio)
t$dil.v[Vv.log]<-(t$conc.vector/alt.conc.vector)[Vv.log]
t$vol.v[Vv.log]<-input$minim
t$vol.i[Vv.log]<-(input$voltotal-input$minim)
}
Vi.log<-Vi < input$minim
if (TRUE %in% Vi.log){
alt.conc.insert<-( (input$voltotal-input$minim)*t$conc.vector*t$bp.insert*input$ratio)/ (input$minim*t$bp.vector)
t$dil.i[Vi.log]<-(t$conc.insert/alt.conc.insert)[Vi.log]
t$vol.i[Vi.log]<-input$minim
t$vol.v[Vi.log]<-(input$voltotal-input$minim)
}
t
}) })
} }

Loading…
Cancel
Save