I have the following csv file:

name,x,y,z
category,delta,gamma,epsilon
a,1,2,3
b,4,5,6
c,7,8,9

I'd like to create a numeric matrix of just the numbers in this csv dataset.

I've tried the following program:

sample.data <- read.csv("sample.csv")
numerical.data <- as.matrix(sample.data[-1,-1])

However, print(numerical.data) returns what appears to be a matrix of
characters:

  x   y   z
2 "1" "2" "3"
3 "4" "5" "6"
4 "7" "8" "9"

How do I force it to be numbers rather than characters?

Thanks,
Andrew

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to