作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制作了一个散点图,需要在图表中的某处包含年龄和高度的 PIL 逊相关系数。这是我已经完成的部分工作。
plot(survey$Age, survey$Height,main="A scatter plot of Age against Height",xlab="Age(years)",ylab="Height(cm)")
我使用的数据集在这里。调查
Name Sex Age Height Weight Forearm Pulse Eyes Pizza
1 Kaito McCarthy Male 17 182 55 26 88 Purple Mushroom
2 James Durand Male 18 185 103 28 90 Brown Spinach
3 Kaito Hajek Male 20 171 49 25 92 Brown Sausage
4 Liam Steiner Male 18 176 58 25 68 Green Sausage
5 Kevin Gonzalez Male 21 158 57 23 68 Brown Sausage
6 Momoko Durand Female 21 155 43 25 84 Purple Spinach
7 Julian Takahashi Male 18 199 114 29 74 Blue Prawns
8 Fabian Rodriguez Male 19 176 90 25 76 Brown Mushroom
9 Samuel Kennedy Male 17 191 68 29 86 Purple Sausage
10 Vicente Carrasco Male 23 176 52 25 88 Purple Spinach
11 Nina Hajek Female 19 153 34 24 62 Purple Pineapple
12 Nanami Gonzalez Female 19 160 56 26 98 Purple Spinach
13 Kazuya Carrasco Male 19 170 47 25 82 Green Mushroom
14 Tomas Durand Male 22 178 62 25 76 Brown Mushroom
15 Mary Simon Female 21 174 49 27 72 Brown Pineapple
16 James Bernard Male 22 162 40 24 80 Purple Pineapple
17 Ciara Steiner Female 23 172 82 27 86 Purple Pineapple
18 Krishna Durand Female 19 185 99 28 78 Green Pineapple
19 Ana Rodriguez Female 18 168 66 25 72 Brown Pineapple
20 Daiki Takahashi Female 17 155 45 24 84 Brown Pineapple
21 Tomaz Rodriguez Male 17 182 83 27 74 Brown Spinach
22 Akane Gonzalez Female 17 164 42 25 90 Blue Pineapple
23 Neli Castro Female 18 162 73 26 72 Green Spinach
24 Riku Carrasco Male 18 185 68 28 82 Green Sausage
25 Leonie Castro Female 18 146 50 23 84 Purple Mushroom
26 Alejandra Lopez Female 23 169 47 25 74 Purple Prawns
27 Lea Summers Female 18 160 51 24 58 Blue Pineapple
28 Ava Castro Female 18 170 69 25 72 Brown Pineapple
29 Tyler Steiner Male 24 185 57 27 76 Purple Mushroom
30 Jacob Carrasco Male 24 167 46 24 78 Green Sausage
31 Nina Lopez Female 25 169 47 26 64 Brown Pineapple
32 Kaeda Gonzalez Female 24 164 50 25 80 Green Pineapple
33 Rebeka Lopez Female 21 155 47 235 50 Brown Mushroom
34 Mary Kennedy Female 24 158 37 24 76 Purple Sausage
35 Leah Castro Female 23 177 88 27 80 Blue Mushroom
36 Michelle Bernard Female 23 155 36 24 80 Blue Pineapple
37 Shin Lopez Male 19 170 47 24 76 Green Pineapple
38 Rose Takahashi Female 21 170 48 26 60 Brown Spinach
39 Emilie Steiner Female 23 160 74 25 82 Green Mushroom
40 Nathan Durand Male 21 180 100 26 86 Blue Prawns
41 Jonas Takahashi Male 19 186 95 27 80 Blue Pineapple
42 Nicolas Summers Male 21 181 65 26 62 Green Pineapple
Cheerful Kiss
1 Moderately No
2 Moderately No
3 Moderately Yes
4 Quite a bit Yes
5 Moderately Yes
6 Moderately Yes
7 Moderately Yes
8 Moderately Yes
9 Moderately No
10 Quite a bit No
11 Quite a bit Yes
12 Moderately No
13 Moderately Yes
14 Moderately Yes
15 Moderately No
16 Quite a bit Yes
17 Moderately No
18 Quite a bit No
19 Moderately No
20 Moderately Yes
21 Moderately No
22 Moderately Yes
23 Moderately No
24 Moderately Yes
25 Moderately Yes
26 Moderately No
27 A Little Yes
28 Quite a bit Yes
29 Quite a bit Yes
30 Moderately Yes
31 Quite a bit Yes
32 Moderately Yes
33 Moderately Yes
34 Moderately Yes
35 A Little Yes
36 Moderately Yes
37 Moderately No
38 Moderately No
39 Moderately Yes
40 Quite a bit Yes
41 Moderately Yes
42 Moderately No
最佳答案
我通常使用legend
或text
向绘图添加信息。例如:
legend(x='bottomright', legend='Cor = 0.34')
在你的情况下,它会更像这样:
legend(x='bottomright', legend=paste('Cor =',round(cor(survey$Age, survey$Height),2)))
关于r - 在散点图上添加 PIL 逊相关系数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20823491/
我是一名优秀的程序员,十分优秀!