Great, you've decided to look into jenga! Although we won't be playing a game, we can still have fun by making RData files a little easier to work with. Here is a typical example in which you may want to use a jenga stack.
methods <- c("Method 1", "Method 2", "Method 3") sims.1 <- create_stack(methods)
status_stack(sims.1)
We can see that all slots are empty! Lets add some data to the slot. The default is to save the jenga stack to an RData file with the name of the stack. If you don't want to save it, but rather only commit to memory, set save=FALSE
.
res <- c(1,2,3,4,5,6) update_stack(stack=sims.1, objects = res, slots = "Method 1", save=FALSE)
We can now check on the status of our jenga stack again:
status_stack(sims.1)
We can also update more than one slot at a time. Suppose we now have data for Methods 2 and 3. We can combine the results into a list and update 2 slots at once.
res2 <- c(2,3,4,5,6,7) res3 <- c(3,4,5,6,7,8) res <- list(res2,res3) update_stack(stack=sims.1, objects = res, slots =c("Method 2", "Method 3"), save=FALSE)
If we check the status of the stack again, we will see now that it is all filled!
status_stack(sims.1)
Say now that you want to extend the stack to hold a fourth method for your simulation study. We can easily add another slot using the extend_stack
function.
new.method <- "Method 4" extend_stack(stack=sims.1, new.slot = new.method ) status_stack(sims.1)
If you want to merge jenga stacks, then we can use the merge_stack
function to make this easy.
sims.2 <- lapply(sims.1, function(x) x[1:3]) sims.2 <- sims.2[1:2] names(sims.2) <- c("Method 2-1", "Method 2-2")
new.stack <- merge_stack(sims.1, sims.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.