需要帮助使用R绘制图形吗
我刚开始学习R,不知道如何绘制性别直方图(男性女性其他,都在x轴上分类)和反应时间(数字,y轴)。此外,还需要显示反应时间在性别之间的分布。谢谢。 在您的案例中,使用三级变量的直方图是很困难的。也许更合适的图形是条形图。 让我们假设您有一个与此数据帧结构大致相似的数据帧:需要帮助使用R绘制图形吗,r,R,我刚开始学习R,不知道如何绘制性别直方图(男性女性其他,都在x轴上分类)和反应时间(数字,y轴)。此外,还需要显示反应时间在性别之间的分布。谢谢。 在您的案例中,使用三级变量的直方图是很困难的。也许更合适的图形是条形图。 让我们假设您有一个与此数据帧结构大致相似的数据帧: df <- data.frame( Gender = c(rep("male", 33), rep("female", 33), rep("other", 34)), Reaction_time = c(rnor
df <- data.frame(
Gender = c(rep("male", 33), rep("female", 33), rep("other", 34)),
Reaction_time = c(rnorm(100)^2)
)
head(df)
Gender Reaction_time
1 male 0.1041879
2 male 0.0125468
3 male 0.8123625
4 male 0.2690723
5 male 1.0718162
6 male 2.5211264
欢迎来到苏莫妮卡。请提供一些数据来解决您的问题。这将使其他人更容易帮助你。
par(mar=c(4,4,1,4)) # set the margins of the plot
stripchart(df$Reaction_time~df$Gender, # plot the two variables against each other
method="jitter", # avoid overplotting
xlab="Reaction time", # label the x-axis
ylab="Gender") # label the y-axis