英文:
How to prevent prettyR describe() from printing in console
问题
I am using the prettyR package's describe function to calculate the mean, standard deviation, median, kurtosis and skewness of a dataset. The code I use is as follows:
library(prettyR)
a <- describe(data, num.desc = c("mean", "sd", "median", "kurtosis", "skewness"))
The dataset in question, however, is very long, so the function proceeds to print the whole list of data in the R console under "description of structure." This takes a long time and makes it hard to read results of previous code in the console due to lots of scrolling required. The output in the console looks as follows:
Description of structure(list(x=c(...)), row.names = c(...), class = "data.frame")
Is there any way to prevent the above output from printing in the console? I just want the 'a' object so I can call it to look at the mean etc. Any help would be much appreciated as the R documentation has been getting me nowhere! Thanks.
英文:
I am using the prettyR package's describe function to calculate the mean, standard deviation, median, kurtosis and skewness of a dataset. The code I use is as follows:
library(prettyR)
a <- describe(data,num.desc=c("mean","sd","median","kurtosis","skewness"))
The dataset in question however is very long so the function proceeds to print the whole list of data in the R console under "description of structure". This takes a long time and makes it hard to read results of previous code in the console due to lots of scrolling required. The output in the console looks as follows:
Description of structure(list(x=c(...)),row.names=c(...),class="data.frame")
Is there any way to prevent the above output from printing in the console? I just want the a object so I can call it to look at the mean etc. Any help would be much appreciated as the R documentation has been getting me nowhere!
Thanks.
答案1
得分: 1
Badly implemented cat
, should be message
, not so pretty. Wouldn't use such packages, also not maintained since 4 years.
However can be silenced with capture.output
into something.
nul <- capture.output(des <- prettyR::describe(mtcars))
des
Numeric
mean median var sd valid.n
mpg 20.09 19.20 36.32 6.03 32
cyl 6.19 6.00 3.19 1.79 32
disp 230.72 196.30 15360.80 123.94 32
hp 146.69 123.00 4700.87 68.56 32
drat 3.60 3.70 0.29 0.53 32
wt 3.22 3.33 0.96 0.98 32
qsec 17.85 17.71 3.19 1.79 32
vs 0.44 0.00 0.25 0.50 32
am 0.41 0.00 0.25 0.50 32
gear 3.69 4.00 0.54 0.74 32
carb 2.81 2.00 2.61 1.62 32
Better use psych::describe(mtcars)
.
英文:
Badly implemented cat
, should be message
, not so pretty. Wouldn't use such packages, also not maintained since 4 years.
However can be silenced with capture.output
into something.
nul <- capture.output(des <- prettyR::describe(mtcars))
des
# Numeric
# mean median var sd valid.n
# mpg 20.09 19.20 36.32 6.03 32
# cyl 6.19 6.00 3.19 1.79 32
# disp 230.72 196.30 15360.80 123.94 32
# hp 146.69 123.00 4700.87 68.56 32
# drat 3.60 3.70 0.29 0.53 32
# wt 3.22 3.33 0.96 0.98 32
# qsec 17.85 17.71 3.19 1.79 32
# vs 0.44 0.00 0.25 0.50 32
# am 0.41 0.00 0.25 0.50 32
# gear 3.69 4.00 0.54 0.74 32
# carb 2.81 2.00 2.61 1.62 32
Better use psych::describe(mtcars)
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论