質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
R

R言語は、「S言語」をオープンソースとして実装なおした、統計解析向けのプログラミング言語です。 計算がとても速くグラフィックも充実しているため、数値計算に向いています。 文法的には、統計解析部分はS言語を参考にしており、データ処理部分はSchemeの影響を受けています。 世界中の専門家が開発に関わり、日々新しい手法やアルゴリズムが追加されています。

Q&A

解決済

1回答

2460閲覧

R言語でパッケージのforecastが使えない

yukioh

総合スコア1

R

R言語は、「S言語」をオープンソースとして実装なおした、統計解析向けのプログラミング言語です。 計算がとても速くグラフィックも充実しているため、数値計算に向いています。 文法的には、統計解析部分はS言語を参考にしており、データ処理部分はSchemeの影響を受けています。 世界中の専門家が開発に関わり、日々新しい手法やアルゴリズムが追加されています。

0グッド

0クリップ

投稿2020/05/22 05:47

前提・実現したいこと

R言語でforecastのパッケージを使いたい。

発生している問題・エラーメッセージ

インストール後にlibrary(forecast)を実行しても、何も表示されない。
sword.forecast <- forecast(sword.ts)を実行すると、エラーが表示される。

> library(forecast) > sword.forecast <- forecast(sword.ts) forecast(sword.ts) でエラー: 関数 "forecast" を見つけることができません

該当のソースコード

RGui(64bit)

1> sword <- read.csv("DemandforSword.csv") 2> sword.ts <- ts(sword, frequency=12, start=c(2010,1)) 3> install.packages("forecast",dependencies=TRUE) 4 パッケージを ‘C:/Users/shiko/OneDrive/ドキュメント/R/win-library/4.0’ 中にインストールします 5 (‘lib’ が指定されていないため) 6 URL 'https://cran.mtu.edu/bin/windows/contrib/4.0/forecast_8.12.zip' を試しています 7Content type 'application/zip' length 2534059 bytes (2.4 MB) 8downloaded 2.4 MB 9 10 パッケージ ‘forecast’ は無事に展開され、MD5 サムもチェックされました 11 12 ダウンロードされたパッケージは、以下にあります 13 C:\Users\shiko\AppData\Local\Temp\Rtmp4iYCr8\downloaded_packages 14> library(forecast) 15> sword.forecast <- forecast(sword.ts) 16 forecast(sword.ts) でエラー: 17 関数 "forecast" を見つけることができません

試したこと

library()とsearch()はしてみました。

search()

[1] ".GlobalEnv" "package:class" "package:stats"
[4] "package:graphics" "package:grDevices" "package:utils"
[7] "package:datasets" "package:methods" "Autoloads"
[10] "package:base"

library()は下記のような体裁でした(字数が多すぎて質問にすべて盛り込めず、かなり削ってしまっています)

パッケージ (ライブラリ ‘C:/Users/shiko/OneDrive/ドキュメント/R/win-library/4.0’ 中):

abind Combine Multidimensional Arrays
AER Applied Econometrics with R
assertthat Easy Pre and Post Assertions
backports Reimplementations of Functions Introduced
Since R-3.0.0
base64enc Tools for base64 encoding
BH Boost C++ Header Files
callr Call R from R
car Companion to Applied Regression
carData Companion to Applied Regression Data Sets
cellranger Translate Spreadsheet Cell Ranges to Rows and
Columns
chron Chronological Objects which can Handle Dates
and Times
cli Helpers for Developing Command Line
Interfaces
clipr Read and Write from the System Clipboard
coda Output Analysis and Diagnostics for MCMC
colorspace A Toolbox for Manipulating and Assessing
Colors and Palettes
crayon Colored Terminal Output
curl A Modern and Flexible Web Client for R
data.table Extension of data.frame
date Functions for Handling Dates
desc Manipulate DESCRIPTION Files
digest Create Compact Hash Digests of R Objects
ellipsis Tools for Working with ...
evaluate Parsing and Evaluation Tools that Provide
More Details than the Default
fansi ANSI Control Sequence Aware String Functions
farver High Performance Colour Space Manipulation
forcats Tools for Working with Categorical Variables
(Factors)
forecast Forecasting Functions for Time Series and
Linear Models
Formula Extended Model Formulas
fracdiff Fractionally Differenced ARIMA aka
ARFIMA(P,d,q) Models
fts R Interface to 'tslib' (a Time Series Library
in C++)
ggplot2 Create Elegant Data Visualisations Using the
Grammar of Graphics
timeDate Rmetrics - Chronological and Calendar Objects
zoo S3 Infrastructure for Regular and Irregular
Time Series (Z's Ordered Observations)

パッケージ (ライブラリ ‘C:/Program Files/R/R-4.0.0/library’ 中):

base The R Base Package
boot Bootstrap Functions (Originally by Angelo
Canty for S)
class Functions for Classification
cluster "Finding Groups in Data": Cluster Analysis
Extended Rousseeuw et al.
codetools Code Analysis Tools for R
compiler The R Compiler Package
datasets The R Datasets Package
forecast Forecasting Functions for Time Series and
Linear Models
timeDate Rmetrics - Chronological and Calendar Objects
zoo S3 Infrastructure for Regular and Irregular
Time Series (Z's Ordered Observations)
)

補足情報(FW/ツールのバージョンなど)

学んでいる教材によると、 library(forecast)を実行すると本来、
Loading required package: zoo
Loading required package: timeDate
などの表示が表れ、最後に
this is forecast 5.2と表示されると書いてありました。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Windows10Pro(64bit)のRにforecastをインストールしてみましたが、
問題なくロードまでできました。
インストール時に、エラーメッセージや警告など表示されませんでしたか?

> install.packages("forecast") package ‘xts’ successfully unpacked and MD5 sums checked package ‘TTR’ successfully unpacked and MD5 sums checked package ‘curl’ successfully unpacked and MD5 sums checked package ‘quadprog’ successfully unpacked and MD5 sums checked package ‘quantmod’ successfully unpacked and MD5 sums checked package ‘fracdiff’ successfully unpacked and MD5 sums checked package ‘lmtest’ successfully unpacked and MD5 sums checked package ‘timeDate’ successfully unpacked and MD5 sums checked package ‘tseries’ successfully unpacked and MD5 sums checked package ‘urca’ successfully unpacked and MD5 sums checked package ‘zoo’ successfully unpacked and MD5 sums checked package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked package ‘forecast’ successfully unpacked and MD5 sums checked The downloaded binary packages are in D:\temp\user\RtmpuiygqC\downloaded_packages > library(forecast) Registered S3 method overwritten by 'quantmod': method from as.zoo.data.frame zoo This is forecast 8.12 Crossvalidated is a great place to get help on forecasting issues: http://stats.stackexchange.com/tags/forecasting. Warning message: パッケージ ‘forecast’ はバージョン 3.6.3 の R の下で造られました >

投稿2020/05/24 06:29

technocore

総合スコア7247

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yukioh

2020/05/26 21:41

ご回答、ありがとうございます。 library(forecast)を実行しても、何も起きず、エラーも出ないのです。 forecast(sword.ts)を実行して、初めてエラーが出ます。 私のパソコンの個別のバグなのでしょうか。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問