Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formal argument "type" matched by multiple actual arguments

Tags:

plot

r

I have translated a program from R to C++. The program in question runs multiple iterations of itself with different values then produces a histogram and plot. C++ graphs are finicky so I decided to save the values in csv format and graph them in R. The files are fairly large, for smaller size files, 10 iterations produces 23000 rows and 3 columns. Of course this increase drastically for 100 or 1000 iterations. The format of the csv files is 1,3,0.0107171 which corresponds to col num, row num and data. Then I run this into R:

>data<-read.csv(file.choose(),header=T)
>plot(data,type="b", pch=19, xlab="X", ylab="Y")
Error in plot.default(...) : 
  formal argument "type" matched by multiple actual arguments

As a side note:

> hist(data[,3], xlab="Step length (m)", main="")

the histogram works without any problems. Please tell me if i can provide any more details, I am not so good when it comes to R so I might be missing something obvious. Thanks in advance.

like image 852
user2082985 Avatar asked Apr 18 '13 03:04

user2082985


1 Answers

You are passing a data.frame to plot, which dispatches plot.data.frame, which will, for a data.frame with more than 2 columns, call

pairs(data.matrix(data))

So you could pass arguments in ... that are valid for pairs (type is not)

However I think you probably want to think about what you want to plot from your data

  • What should be on the x axis
  • What should be on the y axis

And then create your call to plot (or perhaps matplot) as required.

like image 61
mnel Avatar answered Sep 19 '22 09:09

mnel