Amit Patel <amitrhelp at yahoo.co.uk> writes:
> x <- loadings(BHPLS1)
>
> my loadings contain variable names rather than numbers.
No, they don't.
>>str(x)
> loadings [1:94727, 1:10] -0.00113 -0.03001 -0.00059 -0.00734 -0.02969 ...
> - attr(*, "dimnames")=List of 2
> ..$ : chr [1:94727] "PCIList1" "PCIList2"
"PCIList3" "PCIList4" ...
> ..$ : chr [1:10] "Comp 1" "Comp 2" "Comp 3"
"Comp 4" ...
> - attr(*, "explvar")= Named num [1:10] 14.57 6.62 7.59 5.91 3.26
...
> ..- attr(*, "names")= chr [1:10] "Comp 1" "Comp
2" "Comp 3" "Comp 4" ...
Look at the first line of output. These are the values, and they are
numeric (it is a matrix). The other lines are attributes of the matrix.
>>plot(BHPLS1, "loadings", comps = 1:2, legendpos =
"topleft", labels = "numbers",
>>xlab = "nm")
> Error in loadingplot.default(x, ...) :
> Could not convert variable names to numbers.
This says that loadingplot.default could not convert variable _names_ to
numbers. That is not surprising, since the variable names are PCIList1,
PCIList2, etc., and the documentation for loadinplot says:
with '"numbers"', the variable names are converted to
numbers, if
possible. Variable names of the forms '"number"' or
'"number
text"' (where the space is optional), are handled.
So don't ask the plot function to use numbers as labels. Use e.g. names
instead: labels = "names".
Tip: It is always a good idea to read the output and error messages very
carefully.
--
Regards,
Bj?rn-Helge Mevik