The difference in the CSV file after loading it into brilliant [R]

I made fileInput, which loads the .CSV file [dataset] immediately after the user selects it.

data <- data.frame(A=c(2.076,3.99,4.95,5.99,6.578,7.6.7),B=c(3.000,7.980,8.0001,9.001,2.000,1.056,2.789,3.546),C=c(1,1,1,2,2,1,1,1,1,2,2))

At ui.r

library(shiny)
library(ggplot2)
shinyUI(fluidPage(
    fileInput('file', 'Choose CSV file',
            accept=c('csv', 'comma-separated-values','.csv')),
    ))

Problem: I do not get the variance value

 In server.r
  library(shiny)
 library(ggplot2)

shinyServer(function(input, output,session) {

    d<-reactive({
            if (is.null(input$file))
                    return(NULL)                
            d<-read.csv(input$file$datapath)
            d <- transform(data, D= A+B, E= A-B) 
            d <- transform(data, var1 =var(D), var2= var(E))
             d
             # In table I am getting variance value as 0.00 
             })
+4
source share
1 answer

you can use

 data <- transform(data, D= A+B, E= A-B)
0
source

Source: https://habr.com/ru/post/1599479/


All Articles