在 pls 包中加载一个数据集,该数据集包括 60 个汽油样品在 401 个波长下的光谱强度,以及它们的辛烷值。在我的例子中:
library(pls)
#Data set
data(gasoline)
'data.frame': 60 obs. of 2 variables:
$ octane: num 85.3 85.2 88.5 83.4 87.9 ...
$ NIR : 'AsIs' num [1:60, 1:401] -0.0502 -0.0442 -0.0469 -0.0467 -0.0509 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr "1" "2" "3" "4" ...
.. ..$ : chr "900 nm" "902 nm" "904 nm" "906 nm"
我喜欢用辛烷值绘制 NIR 的 3D 表示,我的圣杯图是:
但是这个输出图是在 matlab 中创建的,而不是在 R 中创建的。原始代码是(https://it.mathworks.com/help/stats/examples/partial-least-squares-regression-and-principal-components-regression。 html ):
load spectra
whos NIR octane
[dummy,h] = sort(octane);
oldorder = get(gcf,'DefaultAxesColorOrder');
set(gcf,'DefaultAxesColorOrder',jet(60));
plot3(repmat(1:401,60,1)',repmat(octane(h),1,401)',NIR(h,:)');
set(gcf,'DefaultAxesColorOrder',oldorder);
xlabel('Wavelength Index'); ylabel('Octane'); axis('tight');
grid on
请问R中有任何想法或类似的功能/包吗?提前致谢!