1

これは、私が取り組んでいるデータセットのサンプルで、変数stepとの間でピアソン相関検定を実行していzます。

> head(datacorr)
  Date & Time [Local]  Latitude Longitude     step   x   y         z
1 2018-06-18 15:32:00 -2.436589  34.81398 4410.099  14  10  18.24621
2 2018-06-18 15:36:00 -2.438691  34.81222 4620.307  11  15  18.60108
3 2018-06-18 15:40:00 -2.438472  34.81164 4682.904 112 164 198.84468
4 2018-06-18 15:44:00 -2.437794  34.81141 4702.586  90 278 293.42787
5 2018-06-18 15:48:00 -2.437766  34.81177 4662.585  11   7  13.05272
6 2018-06-18 15:52:00 -2.437416  34.81284 4541.207  16   2  16.17849

テストの実行と基本の作成に問題はありませんが、 from packageplot()を使用してより詳細な視覚化を行いたいと考えています。出力を含む私のスクリプトは次のとおりです。ggscatter()ggpubr

> corre<-cor.test(datacorr$step, datacorr$z, method=c("pearson"))
> print(corre)

    Pearson's product-moment correlation

data:  datacorr$step and datacorr$z
t = -6.2382, df = 15021, p-value = 4.546e-10
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.06676964 -0.03487023
sample estimates:
       cor 
-0.0508329 

> plot(datacorr$step,datacorr$z)
> step<-datacorr$step
> activityz<-datacorr$z
> library("ggpubr")
> ggscatter(datacorr, x = step, y = activityz, 
+           add = "reg.line", conf.int = TRUE, 
+           cor.coef = TRUE, cor.method = "pearson",
+           xlab = "Step Length", ylab = "Activity Z")
Error in .check_data(data, x, y, combine = combine | merge != "none") : 
  Can't find the y elements in the data.

ggscatter()別の投稿に基づいてコードを使用しました。エラーが発生し続ける理由を誰かが知っていますか? 私はRが初めてですが、すべての引数を正しく定義しているように見えます。R でピアソン相関検定を視覚化する方法 (フィーチャー ライン、r 係数、p 値など) について代替手段がある場合は、提案を受け付けています。

どんな助けでも大歓迎です!

4

1 に答える 1