[R] dercribe: to get the mean and sd, and print with paste

Of course you can hard-coded the standard deviation and mean GPA values.

like:

R 复制代码
#Using the command describe, tell what is the standard deviation and the mean GPA of the students in Year 4 (GE_survey_Y4)
#the variable name is Q19_actual_GPA
#Please write your code below
library(psych)
describe(GE_survey_Y4$Q19_actual_GPA)

and:

R 复制代码
standard_deviation <-0.31
print(standard_deviation)
mean_GPA1 <- 3.33
print(mean_GPA1)

but you have an alternative way to dynamically do it:

Create a df to store the sedcribe result and use stats$ to get the stored answer:

R 复制代码
stats <- describe(GE_survey_Y4$Q19_actual_GPA)
standard_deviation <- stats$sd
mean_GPA1 <- stats$mean

The instruction "#Please write a sentence with your answer below" is asking you to provide a written interpretation or summary of the results obtained from your code. This is often done in academic or professional settings to ensure that the reader understands the significance of the results without having to interpret the code themselves.

R 复制代码
If you have a variable statsanswer1 containing the number 7 and you want to report it in a sentence, you can use the paste() function to concatenate the text with the value of the variable. Here's how you can do it:

statsanswer1 <- 7
report_sentence <- paste("The answer is", statsanswer1)
print(report_sentence)

In this code, paste() combines the string "The answer is" with the value of statsanswer1 to create the sentence "The answer is 7". The print() function is then used to display the sentence.

Don't use "+" or "," directly, may work in Java or Python but not here.

相关推荐
yousuotu1 分钟前
基于Python的亚马逊销售数据集探索性数据分析
开发语言·python·数据分析
Knight_AL2 分钟前
Java 内存溢出(OOM)排查实战指南:从复现到 MAT Dump 分析
java·开发语言
糯诺诺米团2 分钟前
C++多线程打包成so给JAVA后端(Ubuntu)<1>
java·开发语言
MSTcheng.5 分钟前
【C++】平衡树优化实战:如何手搓一棵查找更快的 AVL 树?
开发语言·数据结构·c++·avl
superman超哥7 分钟前
Rust 泛型参数的使用:零成本抽象的类型级编程
开发语言·后端·rust·零成本抽象·rust泛型参数·类型级编程
Thomas_YXQ8 分钟前
Unity3D IL2CPP如何调用Burst
开发语言·unity·编辑器·游戏引擎
superman超哥8 分钟前
仓颉并发调试利器:数据竞争检测的原理与实战
开发语言·仓颉编程语言·仓颉
秦苒&10 分钟前
【C语言】字符函数和字符串函数:字符分类函数 、字符转换函数 、 strlen 、strcpy、 strcat、strcmp的使用和模拟实现
c语言·开发语言
小白学大数据10 分钟前
Python 网络爬虫:Scrapy 解析汽车之家报价与评测
开发语言·爬虫·python·scrapy