source("http://macosa.dima.unige.it/r.R") # If I have not already loaded the library ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- # Example: average consumption of kg of fresh fruit per year by an Italian. year = c(1880,1890,1900,1910,1920,1930,1940,1950,1960,1970,1980) fruit = c(19, 21, 23, 28, 31, 27, 23, 37, 65, 88, 79) # max is useful for choosing the "Plane": I find the maximum is 88, so I change y # between 0 and 90 max(fruit) # [1] 88 BF=4; HF=2.5 Plane(1880,1980, 0,90) polyline(year,fruit, "blue"); POINT(year,fruit,"brown") # I also put two inscriptions along the axes with these commands: abovex("year"); abovey("fruit") # Let's see how to enter the data in tabular form. # I prepare an 11-row, 2-column table. I call it G. G = array(dim=c(11,2)) # With: data.entry(G) # I insert data (and names) in the table on the left obtaining the table on the right: # Then I click [X]. With: G # I obtain: year fruit [1,] 1880 19 [2,] 1890 21 [3,] 1900 23 [4,] 1910 28 [5,] 1920 31 [6,] 1930 27 [7,] 1940 23 [8,] 1950 37 [9,] 1960 65 [10,] 1970 88 [11,] 1980 79 # G[1,1] is 1880, G[1,2] is 19, G[2,1] is 1890, .., G[11,2] is 79. BF=4; HF=2.5 Plane(1880,1980, 0,90) polyline(G[1:11,1],G[1:11,2],"blue") POINT(G[1:11,1],G[1:11,2],"brown") abovex("year"); abovey("fruit") more