私はRが初めてで、これは本当に基本的なことですが、うまくいきません。たとえば、このdata.frameの列6:11の行を合計したい:
dput(タブ.res)
tab.res <- structure(c("RIL", "RIL", "RIL", "RIL", "RIL", "RIL", "RIL", "RIL", "RIL", "1993"," 1994", "1995", "1996", "1998", "2000", "2003", "2006", "2009", "0.622648030237929", "0.622780354568876", "0.623028859270455", "0.623336617104674", "0.624702676975245" , "0.62229896748978", "0.619100952240793", "0.62242230375717", "0.621052639967347", "21.8279151394679", "18.558235100949", "19.1066487340136", "19.4658454721166", "19.7990392265612", "20.5366574203101", "22.3737846431613", "21.6823832708024", "22.5832057096871", "558.462585034014", "460.190476190476", "457.319727891156", "455.210884353742", "437.78231292517", "455.360544217687", "569.442176870748", "488.367346938776", "512.421768707483", "42.048152226551", "35.7094330210724" , "36.4311339004591", "35.8460590917321", "33.3991893243174", "33.9938868563961", "39.9166803633779", "34.7098561898221", "35.4769784708925", "44.0903088045558", "40.5555666070647", "41.419372563604", "43.5776682933757", "45.5922072021568", " 46.0154886164247"、"47.3378504648163"、"46.41940144389"、"49.5580273139249", "40.6511227624141", "39.1466514500133", "40.4409858368967", "41.4903119307394", "42.9108185069093", "45.7459942527593", "47.7880868127877", "48.8291523581031", "48.3273707080036", "31.3644667603767", "31.0971941969479", "32.4804982013221" , "32.4553994494653", "34.2369548403931", "35.6674106248615", "38.53520691726", "38.8160980443", "40.8055122694451", "24.5415097525631", "23.5956393932039", "23.6298291129159", "24.6786066881199", "25.3372707363408", "25.7293935423119", " 26.2842616375337"、"29.2438109789201"、"29.6350482936186"、"76.6236464549925", "44.5672068727091", "46.962777170159", "48.0267179639631", "51.298941016064", "53.5121260383574", "55.4511984380194", "53.5652556461721", "55.2830178740705"), .Dim = c(9L, 11L), .Dimnames = list (NULL, c("Treat", "Year", "WD", "BA", "StemD", "AGB.10.20", "AGB.20.30", "ABG.30.40", "ABG.40.50", " ABG.50.60"、"ABG.60.+")))Dimnames = list(NULL, c("Treat", "Year", "WD", "BA", "StemD", "AGB.10.20", "AGB.20.30", "ABG.30.40", "ABG.40.50" "、"ABG.50.60"、"ABG.60.+")))Dimnames = list(NULL, c("Treat", "Year", "WD", "BA", "StemD", "AGB.10.20", "AGB.20.30", "ABG.30.40", "ABG.40.50" "、"ABG.50.60"、"ABG.60.+")))
これで問題は解決するはずです:
tab.res$total <- rowSums(subset(tab.res, select=6:11))
しかし、私は取得し続けます:
rowSums(subset(tab.res, select = 6:11)) のエラー: 'x' は数値でなければなりません
「as.numeric」を使用してエラーが発生したものを変換しようとしましたが、どこにも行きません...誰に電話して問題がどこにあるのか教えてください。