I have the following function:
stats <- function(data) {
maxDay <<- max(data$TotalGB)
avgDay <<- mean(data$TotalGB)
P95Day <<- quantile(data$TotalGB, probs = (.95))
return(list(paste0("The max number of GBs for is: ", maxDay), paste0("The average number of GBs is: ", avgDay),
paste0("The 95P GBs is: ", P95Day)))
}
This function returns the following results:
[[1]]
[1] "The max number of GBs for is: 700"
[[2]]
[1] "The average number of GBs is: 350"
[[3]]
[1] "The 95P GBs is: 655"
Now if I want to obtain these stats for more than 1 user, I am doing the following
user1 <- stats(df_1)
user2 <- stats(df_2)
When I do this, the value for maxDay, avgDay and P95Day will reflect the stats from user 2. What can I add so that instead of overriding the results, I could obtain the unique stats for each user.
I was thinking of just doing something like user1$avgDay but this returns in NULL
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…