[R] How to use a matrix in pcurve?
XP Sun
xpsun at ict.ac.cn
Sun Oct 24 09:24:23 CEST 2004
Hi, Everyone,
I want to calculate the principal curve of a points set.
First I read the points'coordinate with function "scan",
then converted it to matrix with the function "matrix",
and fit the curve with function "principal.curve".
Here is my data in the file "bmn007.data":
0.023603 -0.086540 -0.001533
0.024349 -0.083877 -0.001454
..
..
0.025004 -0.083690 -0.001829
0.025562 -0.083877 -0.001857
0.026100 -0.083877 0.000090
0.025965 -0.083877 0.002574
and the code as follow:
pp <- scan("bmn007.data", quiet= TRUE)
x <- matrix(pp, nc=2, byrow=TRUE)
fit <- principal.curve(x, plot = TRUE)
points(fit,col="red")
By now, I got a right result.
But when i changed to use pcurve with matrix x as "pcurve(x)",
an error was thrown as following:
Estimating starting configuration using : CA
Error in h %*% diag(sqrt(d)) : non-conformable arguments
How to convert a matrix to the format could be accepted by "pcurve"?
Any help appreciated!
Regards
- Sun
More information about the R-help
mailing list