matloff / fasteR

Fast Lane to Learning R!
921 stars 146 forks source link

(Possibly) Incompatible code in Lesson 27 #18

Open khangquangtran opened 1 year ago

khangquangtran commented 1 year ago

The first two code lines in Lesson 27:

plot(mlb$Age,mlb$Weight,col=mlb$PosCategory)

and

with(mlb,plot(Age,Weight,col=PosCategory,cex=0.6))

are not compatible with current version of R (4.2.1).

The error when using these two lines:

Error in plot.xy(xy, type, ...) : invalid color name 'Catcher'

Suggested fixes based on Stack Overflow (link: https://stackoverflow.com/questions/66854539/r-does-not-assign-colors-to-plot-function):

plot(mlb$Age,mlb$Weight,col=as.factor(mlb$PosCategory))

and

with(mlb,plot(Age,Weight,col=as.factor(PosCategory),cex=0.6))

However, I am not sure if these suggested fixes are compatible with earlier versions of R.

matloff commented 1 year ago

Thanks. Was not a version issue. Anyway, I rewrote Lessons 29 and 30 completely. Thanks again.