i want to make Beautyful linear graph from r. i attached csv data below in the code.

library(ggplot2)
library(sf)

research <- read.csv("E:/Research data/research/Copy of research11(1).csv")
View(research)
summary(research)

ggplot(data = research,
mapping = aes(x = Year,
y = FOREST))+
geom_point(size = 5)+
geom_line(colour = "red")

Year URBAN CROPLAND Pasture FOREST
Total Forests Percentage Growth rate mean
1900 24614 45.88 0 984.56
1901 24553 45.77 -0.2478 982.12
1902 24544 45.75 -0.0367 981.76
1903 24527 45.72 -0.0693 981.08
1904 24506 45.68 -0.0856 980.24
1905 24487 45.65 -0.0775 979.48
1906 24424 45.53 -0.2573 976.96
1907 24406 45.50 -0.0737 976.24
1908 24383 45.45 -0.0942 975.32
1909 24359 45.41 -0.0984 974.36
1910 24331 45.36 -0.1149 973.24
1911 24260 45.22 -0.2918 970.4
1912 24235 45.18 -0.1031 969.4
1913 24217 45.14 -0.0743 968.68
1914 24204 45.12 -0.0537 968.16
1915 24177 45.07 -0.1116 967.08
1916 24117 44.96 -0.2482 964.68
1917 24099 44.92 -0.0746 963.96
1918 24079 44.89 -0.0830 963.16
1919 24061 44.85 -0.0748 962.44
1920 24030 44.80 -0.1288 961.2
1921 23973 44.69 -0.2372 958.92
1922 23950 44.65 -0.0959 958
1923 23956 44.66 0.0251 958.24
1924 23930 44.61 -0.1085 957.2
1925 23895 44.54 -0.1463 955.8
1926 23831 44.42 -0.2678 953.24
1927 23792 44.35 -0.1637 951.68
1928 23747 44.27 -0.1891 949.88
1929 23687 44.16 -0.2527 947.48
1930 23626 44.04 -0.2575 945.04
1931 23558 43.92 -0.2878 942.32
1932 23507 43.82 -0.2165 940.28
1933 23446 43.71 -0.2595 937.84
1934 23362 43.55 -0.3583 934.48
1935 23317 43.47 -0.1926 932.68
1936 23243 43.33 -0.3174 929.72
1937 23175 43.20 -0.2926 927
1938 23104 43.07 -0.3064 924.16
1939 23036 42.94 -0.2943 921.44
1940 22963 42.81 -0.3169 918.52
1941 22889 42.67 -0.3223 915.56
1942 22831 42.56 -0.2534 913.24
1943 22753 42.41 -0.3416 910.12
1944 22693 42.30 -0.2637 907.72
1945 22631 42.19 -0.2732 905.24
1946 22557 42.05 -0.3270 902.28
1947 22485 41.92 -0.3192 899.4
1948 22423 41.80 -0.2757 896.92
1949 22360 41.68 -0.2810 894.4
1950 22301 41.57 -0.2639 892.04
1951 22246 41.47 -0.2466 889.84
1952 22170 41.33 -0.3416 886.8
1953 22110 41.22 -0.2706 884.4
1954 22042 41.09 -0.3076 881.68
1955 21974 40.96 -0.3085 878.96
1956 21913 40.85 -0.2776 876.52
1957 21839 40.71 -0.3377 873.56
1958 21772 40.59 -0.3068 870.88
1959 21696 40.44 -0.3491 867.84
1960 21628 40.32 -0.3134 865.12
1961 21560 40.19 -0.3144 862.4
1962 21493 40.07 -0.3108 859.72
1963 21424 39.94 -0.3210 856.96
1964 21353 39.81 -0.3314 854.12
1965 21281 39.67 -0.3372 851.24
1966 21210 39.54 -0.3336 848.4
1967 21138 39.40 -0.3395 845.52
1968 21076 39.29 -0.2933 843.04
1969 21014 39.17 -0.2942 840.56
1970 20938 39.03 -0.3617 837.52
1971 20876 38.92 -0.2961 835.04
1972 20805 38.78 -0.3401 832.2
1973 20736 38.65 -0.3317 829.44
1974 20664 38.52 -0.3472 826.56
1975 20601 38.40 -0.3049 824.04
1976 20534 38.28 -0.3252 821.36
1977 20464 38.15 -0.3409 818.56
1978 20391 38.01 -0.3567 815.64
1979 20315 37.87 -0.3727 812.6
1980 20245 37.74 -0.3446 809.8
1981 20167 37.59 -0.3853 806.68
1982 20100 37.47 -0.3322 804
1983 20030 37.34 -0.3483 801.2
1984 19965 37.22 -0.3245 798.6
1985 19845 37.02 -0.6011 793.8
1986 19812 36.93 -0.1663 792.48
1987 19745 36.81 -0.3382 789.8
1988 19662 36.65 -0.4204 786.48
1989 19598 36.53 -0.3255 783.92
1990 19527 36.40 -0.3623 781.08
1991 19378 36.12 -0.7630 775.12
1992 19225 35.84 -0.7896 769
1993 19069 35.55 -0.8114 762.76
1994 18924 35.28 -0.7604 756.96
1995 18752 34.96 -0.9089 750.08
1996 18597 34.67 -0.8266 743.88
1997 18441 34.38 -0.8388 737.64
1998 18293 34.10 -0.8026 731.72
1999 18131 33.80 -0.8856 725.24
2000 17981 33.52 -0.8273 719.24
2001 17927 33.42 -0.3003 717.08
2002 17881 33.33 -0.2566 715.24
2003 17827 33.23 -0.3020 713.08
2004 17777 33.14 -0.2805 711.08
2005 17728 33.05 -0.2756 709.12
2006 17670 32.94 -0.3272 706.8
2007 17610 32.83 -0.3396 704.4
2008 17560 32.73 -0.2839 702.4
2009 17513 32.65 -0.2677 700.52
2010 17453 32.53 -0.3426 698.12
2011 17498 32.62 0.2578 699.92
2012 17543 32.70 0.2572 701.72
2013 17585 32.78 0.2394 703.4
2014 17630 32.86 0.2559 705.2
2015 17668 32.94 0.2155 706.72
2016 17678 32.95 0.0566 707.12
2017 17691 32.98 0.0735 707.64
2018 17717 33.03 0.1470 708.68
2019 17731 33.05 0.0790 709.24

Have a look at the R graph gallery. It is a good starting point for using R to create data visualizations.

# package library
library(tidyverse)

# random data 
set.seed(200)

research <- tibble(
  year = seq(1900, 1999, 1),
  forest = rnorm(n = 100, mean = 45, sd = 5)
)

# view
glimpse(research)
#> Rows: 100
#> Columns: 2
#> $ year   <dbl> 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 191…
#> $ forest <dbl> 45.42378, 46.13230, 47.16278, 47.79033, 45.29878, 44.42680, 39.…

# line graph
ggplot(
  data = research,
  mapping = aes(
     x = year,
     y = forest
  )
) +
  geom_point(size = 5) +
  geom_line(color = "red") +
  ylim(0, NA) + # y scale limits 
  theme_minimal() + # a default theme 
  labs(title = "Beautiful line graph") # plot title 

Created on 2023-12-18 with reprex v2.0.2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.