r

R: Calculating cumulative number of unique entries

情到浓时终转凉″ 提交于 2021-02-18 15:57:37
问题 I have a data frame from several experiments. I am looking to calculate cumulative number of unique values obtained after each successive experiment. For example, consider: test <- data.frame(exp = c( rep("exp1" , 4) , rep("exp2" , 4), rep("exp3" , 4) , rep("exp4" , 5) ) , entries = c("abcd","efgh","ijkl","mnop", "qrst" , "uvwx" , "abcd","efgh","ijkl" , "qrst" , "uvwx", "yzab" , "yzab" , "cdef" , "mnop" , "uvwx" , "ghij")) > test exp entries 1 exp1 abcd 2 exp1 efgh 3 exp1 ijkl 4 exp1 mnop 5

dynamically add rows to rhandsontable in shiny and R

假如想象 提交于 2021-02-18 15:57:26
问题 I'm trying to create an app which ultimately needs the mean and sd of a protein's concentration on the log scale . Since the log-scale values are almost never reported, I've found references which allow me to approximate log-scale using commonly available data (the mean + sd, median + range, median + IQR, 5 point summary, etc.). Users will enter the data using a table currently implemented using rhandsontable until I've added enough error handling to accommodate CSV files, and I want to limit

dynamically add rows to rhandsontable in shiny and R

白昼怎懂夜的黑 提交于 2021-02-18 15:57:10
问题 I'm trying to create an app which ultimately needs the mean and sd of a protein's concentration on the log scale . Since the log-scale values are almost never reported, I've found references which allow me to approximate log-scale using commonly available data (the mean + sd, median + range, median + IQR, 5 point summary, etc.). Users will enter the data using a table currently implemented using rhandsontable until I've added enough error handling to accommodate CSV files, and I want to limit

R: Calculating cumulative number of unique entries

a 夏天 提交于 2021-02-18 15:57:08
问题 I have a data frame from several experiments. I am looking to calculate cumulative number of unique values obtained after each successive experiment. For example, consider: test <- data.frame(exp = c( rep("exp1" , 4) , rep("exp2" , 4), rep("exp3" , 4) , rep("exp4" , 5) ) , entries = c("abcd","efgh","ijkl","mnop", "qrst" , "uvwx" , "abcd","efgh","ijkl" , "qrst" , "uvwx", "yzab" , "yzab" , "cdef" , "mnop" , "uvwx" , "ghij")) > test exp entries 1 exp1 abcd 2 exp1 efgh 3 exp1 ijkl 4 exp1 mnop 5

Using Shiny fileInput to get path only

岁酱吖の 提交于 2021-02-18 15:31:47
问题 I have a very large fixed width file I need to read in using my Shiny application. The way my program is currently structured is the ui.R contains a fileInput allowing the user to locate the file using the browser. On the server side, I only capture the path to the file such as the following: path2file <- reactive({ infile <- input$path2file if (is.null(infile)) return(NULL) infile$datapath }) A subsequent function takes that path as input and the proceeds to read in the file according to its

Using Shiny fileInput to get path only

蓝咒 提交于 2021-02-18 15:31:32
问题 I have a very large fixed width file I need to read in using my Shiny application. The way my program is currently structured is the ui.R contains a fileInput allowing the user to locate the file using the browser. On the server side, I only capture the path to the file such as the following: path2file <- reactive({ infile <- input$path2file if (is.null(infile)) return(NULL) infile$datapath }) A subsequent function takes that path as input and the proceeds to read in the file according to its

R: Use active binding in object generator to conditionally add new class to R6 objects

半腔热情 提交于 2021-02-18 14:42:48
问题 I have a simple R6 object generator: thing <- R6Class("youngThing", private = list( ..age = 0), active = list( age = function(){ private$..age <- private$..age + 1 private$..age } ) ) That gives me a simple R6 object, where ..age increases by 1 every time the active age field is called: a_thing <- thing$new() a_thing$age # [1] 1 I want the object class of a_thing to change given a threshold value of the private field ..age , like this: class(a_thing) # [1] "youngThing" "R6" for(timestep in 1

Method to operate on each row of data.table without using apply function

可紊 提交于 2021-02-18 13:53:21
问题 I wrote a simple function below: mcs <- function(v) { ifelse(sum((diff(sort(v)) > 6) > 0), NA, sd(v)) } It is supposed to take a vector, sort it and then check if there is difference greater than 6 in each successive difference. It returns NA if there is a difference greater than 6 and the standard deviation if there is not. I would like to apply this function across all rows of a data table (choosing only certain columns) and then append the return value for each row as a new column entry to

Cumulative Returns with NA's in R

左心房为你撑大大i 提交于 2021-02-18 13:47:12
问题 I have the following data frame: df <- data.frame(Return1=c(NA, NA, .03, .04, .05), Return2=c(.25, .33, NA, .045, .90), Return3=c(.04, .073, .08, .04, .01)) Return1 Return2 Return3 1 NA 0.250 0.040 2 NA 0.330 0.073 3 0.03 NA 0.080 4 0.04 0.045 0.040 5 0.05 0.900 0.010 I would like to compute the cumulative returns, but there are missing values in the dataframe. I used: cumprod(df+1)-1 Getting as a result Return1 Return2 Return3 1 NA 0.2500 0.0400000 2 NA 0.6625 0.1159200 3 NA NA 0.2051936 4

Cumulative Returns with NA's in R

£可爱£侵袭症+ 提交于 2021-02-18 13:46:46
问题 I have the following data frame: df <- data.frame(Return1=c(NA, NA, .03, .04, .05), Return2=c(.25, .33, NA, .045, .90), Return3=c(.04, .073, .08, .04, .01)) Return1 Return2 Return3 1 NA 0.250 0.040 2 NA 0.330 0.073 3 0.03 NA 0.080 4 0.04 0.045 0.040 5 0.05 0.900 0.010 I would like to compute the cumulative returns, but there are missing values in the dataframe. I used: cumprod(df+1)-1 Getting as a result Return1 Return2 Return3 1 NA 0.2500 0.0400000 2 NA 0.6625 0.1159200 3 NA NA 0.2051936 4