Skip to content
Prev 14725 / 29559 Next

Help: plot part of the correlogram

On Tue, 3 Apr 2012, ??? wrote:

            
Please learn about str() to see the internal structure of objects:

library(ncf)
x <- expand.grid(1:20, 1:5)[,1]
y <- expand.grid(1:20, 1:5)[,2]
z <- rmvn.spa(x=x, y=y, p=2, method="exp"),
fit1 <- correlog(x=x, y=y, z=z[,1], increment=0.1, resamp=1000)
plot(fit1)
str(fit1)
# fit1 is a list of class "correlog", with vector components of equal
# length. One is p, so:
fit1$p
# are the apparent p-values (uncorrected for multiple comparisons I think,
# computed by permutation) IMO not to be trusted especially for narrow 
# increments
class(fit1) <- NULL
df1 <- as.data.frame(fit1)
fit2 <- as.list(df1[1:50,])
str(fit2)
class(fit2) <- "correlog"
# reconstruct object as class "correlog" after selecting rows from
# data.frame
plot(fit2)

Hope this helps,

Roger