-2

I am having trouble operating Matrixs. First, I want to make factor data to integer so i can operate. Second, The First col, which shows date, should be factor. How can i change?

SGod
  • 13
  • 1
  • 4
  • 1
    You're going to need to post some sample data (not as a picture). By "sample data", I mean a representative and small piece of data that, if we show you how to manipulate, you can easily adapt it to your full-size data. Please read about [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and [minimal](http://stackoverflow.com/help/mcve) questions, then edit your question. (As is, my first thought for an answer is almost entirely the use of `as.integer` and `factor`, but that seems too easy.) – r2evans Jan 19 '17 at 06:19
  • 1
    "I used as.matrix(read.csv())" Well, don't do that. A matrix is not the appropriate data structure for this data. – Roland Jan 19 '17 at 07:24

1 Answers1

1

Try this:

d <- data.frame(1:10, letters[1:10])
data.matrix(d)

Also you can try this too :

m = matrix(scan("file.csv", what=numeric(), skip=1))

skip=1 to skip a header line.

Hope this will help you

emme
  • 215
  • 1
  • 8