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.
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
And then create your call to plot
(or perhaps matplot
) as required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With