1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

R > data.csvを読込んでplot(x,y)する > read.table()使用

Last updated at Posted at 2016-09-11
動作環境
RStudio 0.99.903 on Windows 7 pro
R version 3.3.1 

ファイル

D:\TestData\160911_R
に以下のファイルがあるとする。

data.csv
1
2
3
4
5

本題 v0.1

  • data.csvをread.table()で読込む
  • 読込んだ項目は列ごとにV1, V2, V3...となる
    • 今回の例はV1のみ
  • plotする時にそのV1というのを指定する

yの値は練習なのでxと同じにした。

> setwd("D:/TestData/160911_R")
> x<-read.table("data.csv")
> y<-read.table("data.csv")
> plot(x$V1,y$V1)

結果

qiita.png

v0.2

軸ラベルに「$V1」をつけたくない場合は以下のようにする。
別の変数に置く (xtmp -> xなど)。

> setwd("D:/TestData/160911_R")
> xtmp<-read.table("data.csv")
> ytmp<-read.table("data.csv")
> x<-xtmp$V1
> y<-ytmp$V1
> plot(x,y)

qiita.png

参考 http://stackoverflow.com/questions/17551193/r-color-scatter-plot-points-based-on-values

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?