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 > 2行目から600行目までを浮動小数点数として読込む > xwrk<-as.numeric(as.matrix(x$V1)[2:600])

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

データ

value.csv
someValue1
0.0002154
0.0013023
0.0006595
0.0001275
0.0006590
0.0001183
0.0008723
0.0001750
0.0003121
0.0001123
0.0018614
0.0004775
0.0007699
0.0005948
...

読込み

1行目の項目名(someValue1)を除いた2行目から600行目までをプロットしたい。

> setwd("D:/TestData/160911_R")
> x<-read.table("value.csv")
> plot(x$V1[2:600])

上記を実行したところ、以下となり、希望のグラフではなかった。

qiita.png

> head(x$V1)
[1] someValue1 0.0002154 0.0013023 0.0006595 0.0001275
[6] 0.0006590
628 Levels: 0.0000182 0.0000283 0.0000410 ... someValue1

stackoverflowにてas.numeric()を使った例があった。

ただし、as.numeric()だけではよく分からない数値が得られることがあるので、as.matrix()も併用するようだ。

> setwd("D:/TestData/160911_R")
> x<-read.table("value.csv")
> xwrk<-as.numeric(as.matrix(x$V1)[2:600])
> plot(xwrk)

qiita.png

as.matrixあたりの書き方は以下でもよい。

xwrk<-as.numeric(as.matrix(x$V1[2:600]))
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?