[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.

相关推荐
Poetinthedusk几秒前
WPF应用跟随桌面切换
开发语言·wpf
Hello World . .6 分钟前
数据结构:二叉树(Binary tree)
c语言·开发语言·数据结构·vim
叫我辉哥e17 分钟前
新手进阶Python:办公看板升级交互式可视化+移动端适配+多终端同步
开发语言·python
1candobetter12 分钟前
JAVA后端开发——Spring Boot 组件化自动配置机制
java·开发语言·spring boot
一个网络学徒16 分钟前
python练习3
开发语言·python
专注VB编程开发20年20 分钟前
无 $ 后缀的变体版函数(Mid、InStr)
java·开发语言
程序员敲代码吗20 分钟前
C++运行库修复指南:解决游戏办公软件报错问题
开发语言·c++·游戏
熊猫钓鱼>_>25 分钟前
深入理解Java堆栈:从原理到面试实战
java·开发语言·面试·职场和发展·面向对象·堆栈·oop
地球资源数据云26 分钟前
R语言网络分析与路径规划——线数据应用实战:规划散步路线
数据分析·r语言
孞㐑¥28 分钟前
算法—哈希表
开发语言·c++·经验分享·笔记·算法