Reputation: 15
species 0 30 nM 100nM
MeHg -14.78 -21.66 -20.41
<1 kDa -13.33 -15.41 -16.68
1-3 kDa -14.66 -15.29 -15.35
3-10 kDa -15.71 -17.19 -17.73
10-100 kDa -16.77 -17.57 -17.77
100 kDa-700 nm -23.46 -23.76 -21.62
This is my matrix in csv file, I want to draw multiple barplot in R.
Data <- read.csv ("Book1.csv", header=T)
Data2<-as.matrix(Data)
barplot <-(Data2, main="abc", xlab="a", ylab="b", beside=T)
It shows
Error in -0.01 * height : non-numeric argument to binary operator.
I do not know how to change the code
Upvotes: 1
Views: 553
Reputation: 263352
I think you are attempting to pass arguments to barplot
using <-
. That's just not how R handles functional parameters. Furthermore, barplot
takes either a single numeric vector of values, or a numeric matrix. You've given it a character matrix, since that first column could only be a character vector and matrices need to have all of their columns of the same storage type. Hence, the error about "non-numeric argument". Instead, skip the step where you convert to a matrix and instead leave the first column out using a negative index:
barplot( data.matrix(dat[-1]), main="abc", xlab="a", ylab="b", beside=T)
Upvotes: 1