Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要帮助使用R绘制图形吗_R - Fatal编程技术网

需要帮助使用R绘制图形吗

需要帮助使用R绘制图形吗,r,R,我刚开始学习R,不知道如何绘制性别直方图(男性女性其他,都在x轴上分类)和反应时间(数字,y轴)。此外,还需要显示反应时间在性别之间的分布。谢谢。 在您的案例中,使用三级变量的直方图是很困难的。也许更合适的图形是条形图。 让我们假设您有一个与此数据帧结构大致相似的数据帧: df <- data.frame( Gender = c(rep("male", 33), rep("female", 33), rep("other", 34)), Reaction_time = c(rnor

我刚开始学习R,不知道如何绘制性别直方图(男性女性其他,都在x轴上分类)和反应时间(数字,y轴)。此外,还需要显示反应时间在性别之间的分布。谢谢。

在您的案例中,使用三级变量的直方图是很困难的。也许更合适的图形是条形图。 让我们假设您有一个与此数据帧结构大致相似的数据帧:

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