2017-08-10 15 views
0

私は2つの変数(ディスクとバンド)の散布図を作成し、 "ggpubr"パッケージにある関数 "ggscatter"を使用したいと思います。私は[.data.frameに次のエラーに定義されていない列データフレームエラー

エラーを取得ggscatter機能を使用しようとするたびに(データは、X):未定義の列はここで

を選択した私のコードは、STRの

install.packages("ggpubr") 
library("ggpubr") 
my_data <- All_Data_Summer_17_ 
head(my_data, 6) 
ggscatter(my_data, x = "band", y = "Disk", 
     add = "reg.line", conf.int = TRUE, 
     cor.coef = TRUE, cor.method = "pearson", 
     xlab = "Band", ylab = "Disk (cm)") 

出力(ありますmy_data)

Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 24 obs. of 22 variables: 
$ Sample ID : chr "NP-A-1" "NP-A-2" "NP-A-3" "NP-A-4" ... 
$ Lat  : num 36.6 36.6 36.6 36.6 36.6 ... 
$ Lon  : num -95 -95 -95 -95 -95 ... 
$ Temp  : num 29.1 30.5 30.6 30.7 31 ... 
$ SpCond  : num 0.077 0.081 0.082 0.086 0.088 0.09 0.084 0.09 0.084 0.085 ... 
$ Cond  : int 83 90 90 95 98 99 93 99 93 96 ... 
$ Resist  : num 12107 11116 11066 10537 10248 ... 
$ TDS  : num 0.05 0.053 0.053 0.056 0.057 0.058 0.055 0.058 0.055 0.055 ... 
$ Sal  : num 0.03 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 ... 
$ pH   : num 8.87 9.41 9.56 9.77 9.61 9.38 9.89 9.67 9.89 9.85 ... 
$ Chl  : num 62.1 40.1 3.7 1.4 4.2 5.6 41.5 17.8 4.5 7.7 ... 
$ ODO  : num 5.69 8.76 8.28 8.35 8.75 ... 
$ TSS  : num 1.111 0.667 2.556 3.333 0.778 ... 
$ TP   : num 0 1.03 0.01 -0.02 -0.01 -0.03 0.01 -0.01 -0.03 0.01 ... 
$ TN   : num 0.2 0.3 1.9 0.3 1.1 0.5 1.6 0.9 0.5 0.7 ... 
$ NO3-N  : num 0.43 0.18 0.71 0.36 0.25 0.42 0.26 0.17 0.24 0.19 ... 
$ NH3-N  : num 0.3 0.2 -0.3 -0.1 -0.4 -0.3 -0.3 -0.3 -0.2 -0.1 ... 
$ Chloro-a : num 8.23 7.19 15.37 12.6 14.22 ... 
$ Disk: num 55.5 68 50 50.5 69 65 65 67.7 70 66 ... 
$ band : num 0.000093 0.000096 0.000103 0.000152 0.000088 0.000089 0.000096 0.000097 0.000092 0.000101 ... 
$ Green Band : num 0.000163 0.000169 0.000154 0.000276 0.00016 0.00013 0.00015 0.000175 0.000171 0.000163 ... 
$ Red Band : num 0.00012 0.000145 0.000126 0.000246 0.000117 0.000095 0.000116 0.00011 0.000108 0.000126 ... 

出力dput(my_data)

dput(my_data) 
structure(list(`Sample ID` = c("NP-A-1", "NP-A-2", "NP-A-3", 
"NP-A-4", "NP-A-5", "NP-A-6", "NP-A-7", "NP-A-8", "NP-A-9", "NP-A-10", 
"NP-A-11", "NP-A-12", "NP-A-13", "NP-A-14", "NP-A-15", "NP-A-16", 
"NP-A-17", "NP-B-1", "NP-B-2", "NP-B-3", "NP-B-4", "NP-B-5", 
"NP-B-6", "NP-B-7"), Lat = c(36.568738, 36.569005, 36.569258, 
36.569554, 36.569585, 36.569382, 36.56928, 36.568647, 36.568809, 
36.569124, 36.569425, 36.569331, 36.56919, 36.569071, 36.568888, 
36.568633, 36.568869, 36.568651, 36.568932, 36.56946, 36.569893, 
36.570058, 36.569811, 36.56988), Lon = c(-94.96671, -94.966703, 
-94.966604, -94.966647, -94.96698, -94.966928, -94.966923, -94.967296, 
-94.9677, -94.967761, -94.967911, -94.968069, -94.967358, -94.968107, 
-94.968018, -94.968049, -94.968293, -94.968723, -94.968833, -94.968396, 
-94.968101, -94.967793, -94.967141, -94.96663), Temp = c(29.12, 
30.49, 30.6, 30.71, 30.97, 30.83, 30.82, 30.64, 30.42, 31.62, 
31.96, 31.16, 31.16, 32.88, 32.03, 31, 32.41, 31.79, 31.93, 32.17, 
32.16, 32.55, 32.61, 32.83), SpCond = c(0.077, 0.081, 0.082, 
0.086, 0.088, 0.09, 0.084, 0.09, 0.084, 0.085, 0.08, 0.079, 0.083, 
0.079, 0.086, 0.094, 0.078, 0.183, 0.183, 0.183, 0.183, 0.183, 
0.183, 0.183), Cond = c(83L, 90L, 90L, 95L, 98L, 99L, 93L, 99L, 
93L, 96L, 91L, 88L, 93L, 90L, 97L, 105L, 89L, 206L, 207L, 208L, 
208L, 209L, 210L, 210L), Resist = c(12107.2, 11115.7, 11066.2, 
10537.1, 10247.7, 10051, 10700.4, 10076.5, 10753.3, 10434.4, 
11023, 11304, 10741.8, 11058.1, 10270.4, 9536.35, 11269.8, 4845.53, 
4834.38, 4815.44, 4814.59, 4787.82, 4770.86, 4755.86), TDS = c(0.05, 
0.053, 0.053, 0.056, 0.057, 0.058, 0.055, 0.058, 0.055, 0.055, 
0.052, 0.051, 0.054, 0.051, 0.056, 0.061, 0.051, 0.119, 0.119, 
0.119, 0.119, 0.119, 0.119, 0.119), Sal = c(0.03, 0.04, 0.04, 
0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 
0.04, 0.04, 0.03, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08), 
    pH = c(8.87, 9.41, 9.56, 9.77, 9.61, 9.38, 9.89, 9.67, 9.89, 
    9.85, 9.46, 9.42, 9.75, 9.19, 10.02, 8.83, 9.65, 7.89, 8.14, 
    8.21, 8.22, 8.4, 8.21, 8.18), Chl = c(62.1, 40.1, 3.7, 1.4, 
    4.2, 5.6, 41.5, 17.8, 4.5, 7.7, 8.2, 7.7, 120.3, 3.1, 7.8, 
    3.6, 3.2, 9.8, 7.6, 6, 10, 8.1, 6.3, 4.3), ODO = c(5.69, 
    8.76, 8.28, 8.35, 8.75, 8.59, 10.1, 10.06, 9.14, 10.32, 9.1, 
    8.41, 8.03, 9.63, 9.77, 8.91, 10.16, 7.17, 7.31, 7.41, 7.49, 
    7.75, 6.98, 7.09), TSS = c(1.1111, 0.6667, 2.5556, 3.3333, 
    0.7778, -27.3333, 2.1111, -0.3333, 1.2222, -32.6667, -0.2222, 
    2.3333, -0.2222, 1.1111, 1.4444, 2.6667, 0.1111, 6.3333, 
    7, 5, 5.4444, 6.4444, 3, 2.7778), TP = c(0, 1.03, 0.01, -0.02, 
    -0.01, -0.03, 0.01, -0.01, -0.03, 0.01, 0.04, -0.01, -0.03, 
    0, 0.01, 0.03, 0.04, 0.2, -0.01, 0, -0.03, 0.04, 0.01, -0.01 
    ), TN = c(0.2, 0.3, 1.9, 0.3, 1.1, 0.5, 1.6, 0.9, 0.5, 0.7, 
    0.6, 1, 0.8, 0.1, 0.4, 1.6, 0.6, 0.8, 0.6, 0.5, 0.9, 1.2, 
    0.3, 0.6), `NO3-N` = c(0.43, 0.18, 0.71, 0.36, 0.25, 0.42, 
    0.26, 0.17, 0.24, 0.19, 0.17, 0.41, 0.6, 0.23, 0.3, 0.26, 
    0.22, 0.32, 0.63, 0.36, 0.24, 0.33, 0.55, 0.36), `NH3-N` = c(0.3, 
    0.2, -0.3, -0.1, -0.4, -0.3, -0.3, -0.3, -0.2, -0.1, 0.1, 
    -0.2, 0.2, -0.1, -0.3, -0.1, 0.1, -0.5, 0.2, 0.5, -0.3, 0.2, 
    -0.4, -0.1), `Chloro-a` = c(8.23, 7.19, 15.37, 12.6, 14.22, 
    4.56, 7.2, 8.61, 6.31, 8.74, 5.59, 10.92, 5.24, 4.26, 5.48, 
    6.26, 4.75, 11.45, 10.39, 11.79, 9.59, 9.82, 7.97, 7.92), 
    `Disk` = c(55.5, 68, 50, 50.5, 69, 65, 65, 67.7, 70, 
    66, 69, 67, 69, 62, 60, 62, 66, 50, 52, 50, 40, 57, 57, 62 
    ), `band` = c(9.3e-05, 9.6e-05, 0.000103, 0.000152, 
    8.8e-05, 8.9e-05, 9.6e-05, 9.7e-05, 9.2e-05, 0.000101, 0.000102, 
    9.6e-05, 0.000106, 8.7e-05, 9.1e-05, 0.000126, 0.000107, 
    0.000139, 0.000139, 0.000135, 0.000174, 0.000144, 0.000137, 
    0.000134), `Green Band` = c(0.000163, 0.000169, 0.000154, 
    0.000276, 0.00016, 0.00013, 0.00015, 0.000175, 0.000171, 
    0.000163, 0.000177, 0.000188, 0.000131, 0.000162, 0.000166, 
    0.000233, 0.000204, 0.000265, 0.00023, 0.000254, 0.000325, 
    0.000262, 0.000263, 0.00028), `Red Band` = c(0.00012, 0.000145, 
    0.000126, 0.000246, 0.000117, 9.5e-05, 0.000116, 0.00011, 
    0.000108, 0.000126, 0.000128, 0.000133, 9.3e-05, 0.000114, 
    0.000113, 0.000176, 0.000136, 0.000215, 0.000198, 0.00019, 
    0.000218, 0.00021, 0.000205, 0.000223)), .Names = c("Sample ID", 
"Lat", "Lon", "Temp", "SpCond", "Cond", "Resist", "TDS", "Sal", 
"pH", "Chl", "ODO", "TSS", "TP", "TN", "NO3-N", "NH3-N", "Chloro-a", 
"Disk", "band", "Green Band", "Red Band"), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -24L), spec = structure(list(
    cols = structure(list(`Sample ID` = structure(list(), class = c("collector_character", 
    "collector")), Lat = structure(list(), class = c("collector_double", 
    "collector")), Lon = structure(list(), class = c("collector_double", 
    "collector")), Temp = structure(list(), class = c("collector_double", 
    "collector")), SpCond = structure(list(), class = c("collector_double", 
    "collector")), Cond = structure(list(), class = c("collector_integer", 
    "collector")), Resist = structure(list(), class = c("collector_double", 
    "collector")), TDS = structure(list(), class = c("collector_double", 
    "collector")), Sal = structure(list(), class = c("collector_double", 
    "collector")), pH = structure(list(), class = c("collector_double", 
    "collector")), Chl = structure(list(), class = c("collector_double", 
    "collector")), ODO = structure(list(), class = c("collector_double", 
    "collector")), TSS = structure(list(), class = c("collector_double", 
    "collector")), TP = structure(list(), class = c("collector_double", 
    "collector")), TN = structure(list(), class = c("collector_double", 
    "collector")), `NO3-N` = structure(list(), class = c("collector_double", 
    "collector")), `NH3-N` = structure(list(), class = c("collector_double", 
    "collector")), `Chloro-a` = structure(list(), class = c("collector_double", 
    "collector")), `Disk` = structure(list(), class = c("collector_double", 
    "collector")), `band` = structure(list(), class = c("collector_double", 
    "collector")), `Green Band` = structure(list(), class = c("collector_double", 
    "collector")), `Red Band` = structure(list(), class = c("collector_double", 
    "collector"))), .Names = c("Sample ID", "Lat", "Lon", "Temp", 
    "SpCond", "Cond", "Resist", "TDS", "Sal", "pH", "Chl", "ODO", 
    "TSS", "TP", "TN", "NO3-N", "NH3-N", "Chloro-a", "Disk", 
    "band", "Green Band", "Red Band")), default = structure(list(), class = c("collector_guess", 
    "collector"))), .Names = c("cols", "default"), class = "col_spec")) 
+0

それは問題は、データを見ずであるかを知るのは難しいですが、あなたは、あなたが「バンド」と「ディスク」という名前の 'my_data'データフレームの列を持っていることを確信していますか? –

+0

@Oriol Mirosaはいあります。 my_dataは、22個のobsと24個の変数で構成されるデータフレームです。変数 'band'と 'Disk'があります。私はそれを.csvとしてインポートしました – Perro

+0

これは繰り返し聞こえるかもしれませんが、私はOriolMirosaと一緒です... 'dput(head(my_data、n = 2))'または少なくとも 'str(my_data) '。私たちが今までに見たことのないデータに関する疑問に答えることは、長い道のりになります。 ( 'head(my_data、6)'の出力は表示されているものを実際に提供するだけで十分ではありません。他の2つは各列の 'class'のより良い表示を与えます) – r2evans

答えて

0

わかりやすい答えはまず相関係数を実行してからCIを実行することです。 おそらくあなたはggpubrのMaintainerにバグを報告できます。

ggscatter(my_data, x = "band", 
        y = "Disk", 
        add = "reg.line", 
        cor.coef = FALSE, 
        cor.method = "pearson", 
        conf.int = TRUE, 
        xlab = "Band", 
        ylab = "Disk (cm)") 

Plot

関連する問題