Save item within function

Hi,

I'm trying to create a function that saves its output while running but nothing happens.
how can I do it?

my_function -> function(x){
        y -> x+5
        save(y, file = "output.rda")
}

Works, but it's not recommended

sv_5_more <- function(x) {
    y <- x + 5
    save(y, file = "output.Rds")
}

sv_5_more(2)

load("output.Rds")
y
#> [1] 7

Created on 2020-08-09 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.