TransWikia.com

R: saving/printing all intermediate results

Data Science Asked by An Nguyen on February 26, 2021

currently, we have developed a model at work and it is at the verification step. the goal is for another person to receive output from each and every step of calculation to verify.
The issue is that the model is quite complex and large due to Montecarlo simulation and also being assembled from various scripts (ca. 20 scripts with further for/if test within).
it also has too many intermediate and temporary variables (like temporary row index or col index) to use write.csv() after every line.
Hence, I wonder if anybody faces the same issue before or having a systematic package or method to implement these features? Many thanks. for example:

f <- function(x) { #toy function doing rowSums
output <- rowSums(x); return(output) }

set.seed(12345)
# generate a temporary matrix
randomMatrix  <- matrix(rnorm(1e6*10),ncol = 10, nrow = 1e6) #this need to be saved/stored/printed
y             <- 1*2 + 3 #this need to be saved/stored/printed  
t             <- f(x)    #this need to be saved/stored/printed

finalvariable <- t^y     #this need to be saved/stored/printed 

# many thanks 

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP