I run an apply-family function over a big dataset and so I wonder if there is a way to know how is going the job so far, how many elements got viewed so far, or something like this?
You can consider creating a global counter, and specify when you want to print the progress, for example, you can print a notice whenever 10% of your data has been processed;
counter <- 0
data <- rnorm(100)
results <- sapply(data, function(x) {
counter <<- counter + 1;
if(counter %in% seq(0, length(y), 10))
print(paste(counter, "% has been processed"))})
[1] "10 % has been processed"
[1] "20 % has been processed"
[1] "30 % has been processed"
[1] "40 % has been processed"
[1] "50 % has been processed"
[1] "60 % has been processed"
[1] "70 % has been processed"
[1] "80 % has been processed"
[1] "90 % has been processed"
[1] "100 % has been processed"
You could add a print statement to the function you are using like this
apply(mtcars,2, function(i) {print(i[1])
mean(i)})
Isn't pretty but does what you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With