On the example given below, which can easily be done using the levelplot
function of R
, I would like to ask a question of interpretation: if, for example, I have several values with drat
on the x axis, and hp
on the y-axis, how R decided which color to put in the cell referring to the cross-section of drat
with hp
? Is it by the mean of these various values? Or is it if most of them are in the defined range?
Anyway ... I researched this and found nothing that could answer my question. If anyone can help, thank you in advance.
Have a look at the 'panel' argument, which inherets from 'xyplot', and argument 'panel' inherits from 'scales'. Consider specifying these. Or consider specifying the 'at' argument in levelplot().
level.colors(panel='xyplot(at=)
where at = breakpoints along the range (-1 to +1)
https://stat.ethz.ch/R-manual/R-devel/library/lattice/html/levelplot.html
https://stat.ethz.ch/pipermail/r-help/2010-January/223707.html
Numerical values ranging 1 to -1 and all on-diagonal (the lower left to upper right diagonal) values at 1 suggests a correlation matrix is being used as data. Regular users of R will recognize those column names as coming from a subset of the example dataset mtcars
's columns. So any variable has correlation of 1 with itself. I'll demonstrate below.
cor(mtcars[c('cyl','disp','hp','drat','wt','qsec','vs')])
cyl disp hp drat wt qsec vs
cyl 1.0000000 0.9020329 0.8324475 -0.69993811 0.7824958 -0.59124207 -0.8108118
disp 0.9020329 1.0000000 0.7909486 -0.71021393 0.8879799 -0.43369788 -0.7104159
hp 0.8324475 0.7909486 1.0000000 -0.44875912 0.6587479 -0.70822339 -0.7230967
drat -0.6999381 -0.7102139 -0.4487591 1.00000000 -0.7124406 0.09120476 0.4402785
wt 0.7824958 0.8879799 0.6587479 -0.71244065 1.0000000 -0.17471588 -0.5549157
qsec -0.5912421 -0.4336979 -0.7082234 0.09120476 -0.1747159 1.00000000 0.7445354
vs -0.8108118 -0.7104159 -0.7230967 0.44027846 -0.5549157 0.74453544 1.0000000
levelplot(cor(mtcars[c('cyl','disp','hp','drat','wt','qsec','vs')]))
So the colors represent single values coming from that correlation matrix. each entry is the result of an operation like:
cor(mtcars$disp, mtcars$cyl)
(I'm not sure why your color scale is so short.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.