実現したいこと
R初心者です。頂いたtest用のデータとスクリプトなぜか私のパソコンでやるとエラー3つも出ました。
データを一切弄ってませんし、スクリプトも全部コピペだったのですが、エラーの解決方法をいただけませんでしょうか。
発生している問題・分からないこと
ソースありません
代入可能の部分がありませんなどのエラーを解決できません
エラーメッセージ
error
1UseMethod("predict") でエラー: 2 'predict' をクラス "train" のオブジェクトに適用できるようなメゾットがありません 3load$load でエラー: 4 'closure' 型のオブジェクトは部分代入可能ではありません 5
該当のソースコード
> library(tidyverse) ── Attaching core tidyverse packages ───────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ── ✔ dplyr 1.1.4 ✔ readr 2.1.5 ✔ forcats 1.0.0 ✔ stringr 1.5.1 ✔ ggplot2 3.5.1 ✔ tibble 3.2.1 ✔ lubridate 1.9.4 ✔ tidyr 1.3.1 ✔ purrr 1.0.4 ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag() ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors > library(vegan) 要求されたパッケージ permute をロード中です 要求されたパッケージ lattice をロード中です This is vegan 2.6-10 > source("R/MLP.R") > input <- read.delim("test_data/Franzosa_2018_IBD.motus25.tsv", header = T, row.names = 1, check.names = F) > input <- data.frame(t(input), check.names = F) > load <- MLP(input, "motus25", "metacardis", "load") Model Path: data/metacardis/model.motus25.rds INFO: 412 species were used in the selected model, and 412 (100%) were found in the input file. Missing species have been supplemented. UseMethod("predict") でエラー: 'predict' をクラス "train" のオブジェクトに適用できるようなメソッドがありません > > md <- read.delim("test_data/Franzosa_2018_IBD.metadata.tsv", header = T, row.names = 1, check.names = F) > df <- data.frame(md, load = load$load) load$load でエラー: 'closure' 型のオブジェクトは部分代入可能ではありません > ggplot(df, aes(x = Disease, y = log10(load), fill = Disease)) + theme_bw() + geom_boxplot() Error in `ggplot()`: ! `data` cannot be a function. ℹ Have you misspelled the `data` argument in `ggplot()` Run `rlang::last_trace()` to see where the error occurred.
# 必要なライブラリをロードします library(tidyverse) library(vegan) # MLP本体をロードします source("R/MLP.R") # 入力データを読み込みます. 菌種 x サンプルの相対存在量データです input <- read.delim("test_data/Franzosa_2018_IBD.motus25.tsv", header = T, row.names = 1, check.names = F) # サンプル x 菌種行列に変換します input <- data.frame(t(input), check.names = F) # 存在量を推定します load <- MLP(input, "motus25", "metacardis", "load") # サンプルのメタデータを読み込みます md <- read.delim("test_data/Franzosa_2018_IBD.metadata.tsv", header = T, row.names = 1, check.names = F) # メタデータと存在量データを結合します df <- data.frame(md, load = load$load) # 疾患ごとにboxplotグラフを描画します ggplot(df, aes(x = Disease, y = log10(load), fill = Disease)) + theme_bw() + geom_boxplot()
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
素人すぎてどこを修正すればいいかわかりませんでした
補足
特になし

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。