Skip to content

A bug in plotcc.R #3

@reza-bagheri

Description

@reza-bagheri

In plotcc.R file in the folder R/chapter5/, you have used:

contour(gridvalsX,gridvalsY,matrix(Probs,nrow=dim(Xv)[[1]],ncol=dim(Xv)[[2]],byrow=TRUE),add=TRUE)

However, it should be:

contour(gridvalsX,gridvalsY,matrix(Probs,nrow=dim(Xv)[[2]],ncol=dim(Xv)[[1]],byrow=TRUE),add=TRUE)

That is because in the meshgrid output, the rows of the output array X are copies of the vector gridvalsX, so the length of gridvalsX is equal to the number of columns in mesh$X which is dim(Xv)[[2]], and length of gridvalsY is equal to the number of rows in mesh$X which is dim(Xv)[[1]]. The code runs since both gridvalsX and gridvalsY have the same dimension, however, if you make them different, you get an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions