#*****************************************************************************80 # ## caffeine_scatter: scatter plot of cataract incidence / caffeine intake. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 25 August 2020 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "caffeine_scatter\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Read a data file of cataract incidence versus caffeine intake." ) cat ( " Display the data as a scatter plot.." ) filename = "caffeine_data.txt" data <- read.table ( filename, header = FALSE ) cataracts = data[,1] caffeine = data[,2] # # Get least squares line # lm ( caffeine ~ cataracts ) filename = "caffeine_scatter.png" png ( filename ) plot ( data[,1], data[,2], xlab = "Daily caffeine intake (mg)", ylab = "Blindness due to cataracts (%)", main = "Caffeine and cataracts", pch = 19, col = "red" ) # # Draw least squares line. # I haven't figured out how to extract these values from lm(). # abline ( 212.650, -4.031 ) grid ( ) cat ( ' Graphics saved as "', filename, '"\n' ) # # Terminate. # cat ( "\n" ) cat ( "caffeine_scatter:\n" ) cat ( " Normal end of execution.\n" ) quit ( )