I am trying to write a summarizing print function in R to with the outputs below. I'm not sure how to get it to print with a new line for each output. My code so far is below as well. Any help would be appreciated. Outputs: Mean Median Min Max Standard deviation Quantiles (at 0.05 and 0.95) Skewness
Here is my code so far
printInfo <- function(myVector)
{
print(
mean(myVector)
median(myVector)
min(myVector)
max(myVector)
sd(myVector)
quantile(myVector, probs = c(0.05, 0.95))
library(moments)
skewness(myVector))
}
library(moments)
printInfo <- function(myVector)
{
cat(
"mean: ", mean(myVector), "\n",
"median: ", median(myVector), "\n",
"min: ", min(myVector), "\n",
"max: ", max(myVector), "\n",
"sd: ", sd(myVector), "\n",
"quantile: ", quantile(myVector, probs = c(0.05, 0.95)), "\n",
"skewness: ", skewness(myVector), "\n")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.