Hello,
I'm beggining on R and i'm trying to create a function which gives me a vector of randow numbers.
For that, i do like this :
The problem is that i want to make a print of the mean and the standard deviation of thoses random numbers but i can't do it.
Thank you for your help.
If I've understood your problem this chunk of code will satisfy:
Random <- function (x) { Vector<-c(rnorm(x)) paste("The mean is",mean(Vector),"and the standard deviation is:",sd(Vector),".") } Random(10)
Thanks for your answer.
But in fact, the work i have to do must follow 2 steps :
You mean something like this?
Random <- function (x) { Vector<-c(rnorm(x)) writeLines("The generated vector is:") print(Vector) writeLines(paste0("The mean is ",mean(Vector),", and the standard deviation is ",sd(Vector),".")) } Random(10)
That is exactly the result i wanted, thank you very much for your help
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.