作成日 2015-08-17
最終更新日
概要
RStudioで、Csvデータを読み込みます。
操作

右上の枠のEnvironmentタブから、Import Datasetをクリックし、From Text File.. を選択します。

ファイル選択ダイアログが開きます。読み込むファイルを選択します。

エラーダイアログが表示されます。いろいろ動作を確認して見ると、読み込める場所が限定されているようです。
Rの使用しているプロジェクトフォルダ内にcsvファイルをコピーして入れておかないと認識しないようです。

プロジェクトフォルダに、csvファイルをコピーしたのち、再び開くとImport Datasetダイアログが開きます。問題無ければ、「Import」をクリックして読み込みます。

各パラメータを確認していきます。

「Heding」は、データセットの列名の行が含まれているかどうか指定します。
「Name」は、データフレームの名前になります。ここでは、「deck」というRオブジェクトにデータが保存されます。
「Encoding」csvファイルに使用されている文字コードを指定します。通常は。「Automatic」のままで問題ありません。

「Row names」は、行の名前の指定方法です。

「Separator」は、区切り文字です。

「Decimal」は、小数点の区切り記号です。日本では、「Period」が使われています。

「Quote」は、文字列を囲む記号です。

「Comment」は、コメント記号です。使用しているコメント記号を選択します。

「na.string」は、データが記入されていないことを示す記号です。

「String as factors」ボックスの選択を解除すると、文字列をファクタではなく、文字列として扱うことができます。

「Import」をクリックして、読み込むと、右上の枠に、deckデータフレームが表示され、

左上の枠に、Sourceタブが追加され、データフレームの内容が表示されます。
Sourceタブは、View()関数でも表示することができます。右上の枠の、deckをダブルクリックするのと等価です。
View(deck)
参考書籍
