trouble with my axis on r studio graph

Hi there, I'm really stuck on how to make the graphs for my data set work, especially how to make my axis work.

ggplot(data, aes(x = x, y = y)) +
geom_point(color = "blue") +
labs(title = "Effect of GNI on Mean Years of Schooling", x = "Gross National Income (GNI)", y = "Mean Years of Schooling")

It looks like your values are stored as characters or as a factor rather than as numbers. Please post the output of

dput(head(data,10))

Where data is the data frame that you are using to make the plot.

2 Likes

Try converting data$x to numeric. You can do that is the aes, with as.numeric(x). Then you can format the numbers with the label functions from the {scales} package. I like to use cut_short_scale() because it's very compact and intuitive for most people. 100K, 1.0M in stead of 1e5, 1e6 etc.

ggplot(data, aes(x = as.numeric(x), y = y)) +
  scale_x_continuous(labels = scales::label_number(scale_cut = scales::cut_short_scale())) +
    geom_point(color = "blue") +
    labs(title = "Effect of GNI on Mean Years of Schooling", x = "Gross National Income (GNI)", y = "Mean Years of Schooling")

1 Like

structure(list(Rank = structure(1:10, levels = c("1", "2", "3",
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48",
"49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70",
"71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81",
"82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92",
"93", "94", "95", "96", "97", "98", "99", "100", "101", "102",
"103", "104", "105", "106", "107", "108", "109", "110", "111",
"112", "113", "114", "115", "116", "117", "118", "119", "120",
"121", "122", "123", "124", "125", "126", "127", "128", "129",
"130", "131", "132", "133", "134", "135", "136", "137", "138",
"139", "140", "141", "142", "143", "144", "145", "146", "147",
"148", "149", "150", "151", "152", "153", "154", "155", "156",
"157", "158", "159", "160", "161", "162", "163", "164", "165",
"166", "167", "168", "169", "170", "171", "172", "173", "174",
"175", "176", "177", "178", "179", "180", "181", "182", "183",
"184", "185", "186", "187", "188", "189", "190", "191", "192",
"193"), class = "factor"), Country = structure(c(88L, 171L, 156L,
77L, 38L, 162L, 16L, 63L, 100L, 68L), levels = c("Afghanistan",
"Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda",
"Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
"Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
"Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
"Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria",
"Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada",
"Cayman Islands", "Central African Republic", "Chad", "Chile",
"China", "Colombia", "Comoros", "Congo", "Congo Republic", "Costa do Marfim",
"Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech republic",
"Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor",
"Ecuador", "Egypt", "El Salvador", "Eritrea", "Estonia", "Eswatini",
"Ethiopia", "Federated States of Micronesia", "Fiji", "Finland",
"France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece",
"Grenade", "Guatemala", "Guinea", "Guyana", "Haiti", "Honduras",
"Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran",
"Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan",
"Kazakhstan", "Kenya", "Kuwait", "Kyrgyzstan", "Laos", "Latvia",
"Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania",
"Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives",
"Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius",
"Mexico", "Moldavia", "Mongolia", "Montenegro", "Morocco", "Mozambique",
"Myanmar", "Namibia", "Nepal", "Netherlands", "New Caledonia",
"New Zealand", "Nicaragua", "Niger", "Nigeria", "North Korea",
"North Macedonia", "Northern Mariana Islands", "Norway", "Oman",
"Pakistan", "Palestine", "Panama", "Papua New Guinea", "Paraguay",
"Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar",
"Romania", "Russia", "Rwanda", "Saint Helena", "Saint Lucia",
"Saint Vincent and the Grenadines", "Sao Tome and Principe",
"Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone",
"Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia",
"South Africa", "South Korea", "South Sudan", "Spain", "Sri Lanka",
"Sudan", "Suriname", "Sweden", "Switzerland", "Syria", "Taiwan",
"Tajikistan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago",
"Tunisia", "Türkiye", "Turkmenistan", "Turks and Caicos Islands",
"Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
"United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela",
"Vietnam", "Yemen", "Zambia", "Zimbabwe"), class = "factor"),
Average.IQ = c(106.48, 106.47, 105.89, 105.37, 104.1, 102.35,
101.6, 101.2, 101.07, 100.74), Continent = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L), levels = c("Africa",
"Asia", "Central America", "Europe", "Europe/Asia", "North America",
"Oceania", "South America"), class = "factor"), Literacy.Rate = structure(c(51L,
48L, 49L, 46L, 48L, 50L, 52L, 52L, 52L, 51L), levels = c("0.19",
"0.3", "0.32", "0.33", "0.37", "0.38", "0.4", "0.43", "0.48",
"0.49", "0.52", "0.56", "0.58", "0.59", "0.6", "0.61", "0.63",
"0.64", "0.65", "0.66", "0.67", "0.68", "0.7", "0.71", "0.72",
"0.74", "0.75", "0.76", "0.77", "0.78", "0.79", "0.8", "0.81",
"0.82", "0.83", "0.84", "0.85", "0.86", "0.87", "0.88", "0.89",
"0.9", "0.91", "0.92", "0.93", "0.94", "0.95", "0.96", "0.97",
"0.98", "0.99", "1"), class = "factor"), Nobel.Prizes = structure(c(17L,
5L, 1L, 2L, 8L, 1L, 3L, 6L, 1L, 20L), levels = c("0", "1",
"2", "3", "4", "5", "6", "8", "11", "12", "13", "19", "21",
"22", "27", "28", "29", "32", "71", "111", "137", "400"), class = "factor"),
HDI..2021. = structure(c(136L, NA, 142L, 150L, 88L, 136L,
103L, 143L, 139L, 145L), levels = c("0.385", "0.394", "0.4",
"0.404", "0.426", "0.428", "0.446", "0.449", "0.455", "0.465",
"0.477", "0.478", "0.479", "0.481", "0.492", "0.498", "0.5",
"0.501", "0.508", "0.509", "0.511", "0.512", "0.514", "0.525",
"0.534", "0.535", "0.539", "0.544", "0.549", "0.556", "0.558",
"0.564", "0.565", "0.571", "0.575", "0.576", "0.577", "0.585",
"0.586", "0.593", "0.597", "0.602", "0.607", "0.615", "0.618",
"0.621", "0.627", "0.628", "0.632", "0.633", "0.639", "0.661",
"0.666", "0.667", "0.675", "0.683", "0.685", "0.686", "0.691",
"0.692", "0.693", "0.699", "0.703", "0.705", "0.706", "0.709",
"0.713", "0.714", "0.715", "0.717", "0.718", "0.72", "0.727",
"0.73", "0.731", "0.739", "0.74", "0.745", "0.747", "0.751",
"0.752", "0.754", "0.758", "0.759", "0.762", "0.764", "0.767",
"0.768", "0.77", "0.773", "0.774", "0.78", "0.782", "0.785",
"0.788", "0.79", "0.795", "0.796", "0.8", "0.802", "0.803",
"0.805", "0.808", "0.809", "0.81", "0.811", "0.812", "0.816",
"0.821", "0.822", "0.829", "0.831", "0.832", "0.838", "0.842",
"0.846", "0.848", "0.855", "0.858", "0.863", "0.866", "0.875",
"0.876", "0.887", "0.889", "0.89", "0.895", "0.896", "0.903",
"0.905", "0.911", "0.916", "0.918", "0.919", "0.921", "0.925",
"0.929", "0.93", "0.935", "0.936", "0.937", "0.939", "0.94",
"0.941", "0.942", "0.945", "0.947", "0.948", "0.951", "0.952",
"0.959", "0.961", "0.962"), class = "factor"), Mean.years.of.schooling...2021 = structure(c(80L,
NA, 67L, 69L, 33L, 72L, 68L, 76L, 72L, 85L), levels = c("2.1",
"2.2", "2.3", "2.6", "2.9", "3", "3.1", "3.2", "3.8", "4.1",
"4.3", "4.4", "4.5", "4.6", "4.7", "4.9", "5", "5.1", "5.2",
"5.4", "5.6", "5.7", "5.9", "6", "6.2", "6.4", "6.7", "7",
"7.1", "7.2", "7.3", "7.4", "7.6", "7.8", "7.9", "8.1", "8.3",
"8.4", "8.5", "8.6", "8.7", "8.8", "8.9", "9", "9.2", "9.3",
"9.4", "9.6", "9.8", "9.9", "10", "10.2", "10.3", "10.4",
"10.5", "10.6", "10.7", "10.8", "10.9", "11", "11.1", "11.3",
"11.4", "11.6", "11.7", "11.8", "11.9", "12.1", "12.2", "12.3",
"12.4", "12.5", "12.6", "12.7", "12.8", "12.9", "13", "13.2",
"13.3", "13.4", "13.5", "13.7", "13.8", "13.9", "14.1"), class = "factor"),
GNI...2021 = structure(c(150L, NA, 178L, 170L, 111L, 153L,
114L, 159L, 179L, 165L), levels = c("732", "768", "966",
"1076", "1198", "1240", "1289", "1314", "1364", "1466", "1484",
"1622", "1729", "1824", "2118", "2133", "2167", "2172", "2181",
"2210", "2361", "2481", "2482", "2664", "2700", "2848", "2889",
"3085", "3142", "3218", "3344", "3409", "3575", "3621", "3696",
"3810", "3851", "3877", "4009", "4021", "4079", "4192", "4474",
"4548", "4566", "4620", "4624", "4790", "4811", "5025", "5075",
"5298", "5466", "5472", "5625", "5745", "6309", "6583", "6590",
"7303", "7679", "7700", "7867", "7879", "7917", "8111", "8296",
"8634", "8723", "8834", "8920", "9438", "9526", "9924", "9977",
"9980", "10258", "10312", "10588", "10800", "11466", "11488",
"11732", "11961", "12048", "12246", "12306", "12349", "12578",
"12672", "12948", "13001", "13021", "13158", "13256", "13367",
"13484", "14131", "14257", "14370", "14384", "14664", "14875",
"15242", "15336", "15448", "15918", "16198", "16792", "17030",
"17504", "17896", "17990", "18849", "19123", "19974", "20839",
"20925", "21269", "22025", "22465", "23079", "23392", "23943",
"24563", "25831", "26658", "26957", "27054", "27166", "29002",
"30027", "30132", "30486", "30690", "31033", "32789", "32803",
"33034", "33155", "37931", "38048", "38188", "38354", "38745",
"38884", "39497", "39746", "41524", "42274", "42840", "44057",
"44501", "45225", "45937", "46112", "46808", "49238", "49452",
"51167", "52293", "52920", "53619", "54489", "54534", "55782",
"55979", "60365", "62574", "62607", "64490", "64660", "64765",
"66933", "76169", "84649", "87134", "90919", "146830"), class = "factor"),
Population...2023 = structure(c(26L, 3L, 151L, 174L, 40L,
134L, 190L, 145L, 1L, 179L), levels = c("\t39315", " 32291",
"10143543", "10156239", "102262809", "10247605", "103.699",
"10329931", "10341277", "10412652", "10495295", "10593798",
"10612086", "107.66", "11088796", "11194449", "112716599",
"11332973", "11337053", "1136455", "115.224", "11686140",
"11724764", "117337368", "1210822", "123294513", "12388571",
"12458223", "126.184", "1260138", "126527060", "128455567",
"1300557", "1322766", "13238559", "1360596", "13712828",
"14094683", "14190612", "1425671352", "1428627663", "144444359",
"1485510", "1534937", "16665409", "16944826", "172954319",
"17618299", "17763163", "180.251", "18092026", "18143379",
"18190484", "18278568", "1830212", "19606634", "19629590",
"19892812", "20569738", "2085679", "20931751", "2119675",
"216422446", "21893579", "223804632", "231.856", "23227014",
"23251485", "23293699", "2330318", "240485658", "2436567",
"2604172", "26160822", "26439112", "2675353", "2716391",
"2718352", "27202843", "2773168", "277534123", "2777971",
"281.996", "2825544", "2832439", "28647293", "28838499",
"28873034", "292.991", "30325732", "30896590", "3210848",
"3260314", "334.506", "33897354", "339996564", "34121985",
"3423109", "34308525", "34352719", "3435931", "34449825",
"3447157", "35163944", "36684203", "36744634", "36947025",
"3728282", "3748902", "375.319", "37840044", "38781292",
"4008617", "41.996", "410.825", "41026068", "412.624", "42239854",
"4310108", "44.104", "4468087", "452.524", "45504560", "45606481",
"45773884", "4644384", "47519628", "48109006", "48582334",
"4862989", "49.796", "5040000", "5056935", "51784059", "52085168",
"521.022", "5212173", "5228100", "535.065", "5353930", "5418377",
"54577997", "5474360", "55100587", "5545475", "5742316",
"5795199", "58870763", "5910913", "6.115", "6014723", "60414495",
"6106869", "623.237", "626.485", "63.837", "6364943", "64756584",
"6516100", "654.768", "6687717", "6735348", "67438106", "67736802",
"6861524", "6888388", "69310", "704.15", "7046311", "7149077",
"71801279", "73.161", "740.425", "7491609", "76.965", "7633779",
"787.425", "813.834", "83294633", "852.075", "85816199",
"8791092", "8796669", "89172767", "8958961", "9053799", "9174520",
"936.375", "94.298", "9498238", "9516871", "98858950"), class = "factor")), row.names = c(NA,
10L), class = "data.frame")

The data frame you posted does not have any columns named x or y, but those are the column names you used in your ggplot code. Working from the axis labels of your plot, I guessed at the correct columns to plot. They were indeed factors, converting them first to characters, to recover their original text appearance, and then with as.numeric. You need to check carefully that the numbers shown are correct.

library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.3
data <- structure(list(Rank = structure(1:10, levels = c("1", "2", "3",
                                                 "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
                                                 "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
                                                 "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",
                                                 "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48",
                                                 "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
                                                 "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70",
                                                 "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81",
                                                 "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92",
                                                 "93", "94", "95", "96", "97", "98", "99", "100", "101", "102",
                                                 "103", "104", "105", "106", "107", "108", "109", "110", "111",
                                                 "112", "113", "114", "115", "116", "117", "118", "119", "120",
                                                 "121", "122", "123", "124", "125", "126", "127", "128", "129",
                                                 "130", "131", "132", "133", "134", "135", "136", "137", "138",
                                                 "139", "140", "141", "142", "143", "144", "145", "146", "147",
                                                 "148", "149", "150", "151", "152", "153", "154", "155", "156",
                                                 "157", "158", "159", "160", "161", "162", "163", "164", "165",
                                                 "166", "167", "168", "169", "170", "171", "172", "173", "174",
                                                 "175", "176", "177", "178", "179", "180", "181", "182", "183",
                                                 "184", "185", "186", "187", "188", "189", "190", "191", "192",
                                                 "193"), class = "factor"), 
               Country = structure(c(88L, 171L, 156L,
                                     77L, 38L, 162L, 16L, 63L, 100L, 68L), 
                                   levels = c("Afghanistan","Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda",
                                              "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
                                              "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
                                              "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
                                              "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria",
                                              "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada",
                                              "Cayman Islands", "Central African Republic", "Chad", "Chile",
                                              "China", "Colombia", "Comoros", "Congo", "Congo Republic", "Costa do Marfim",
                                              "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech republic",
                                              "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor",
                                              "Ecuador", "Egypt", "El Salvador", "Eritrea", "Estonia", "Eswatini",
                                              "Ethiopia", "Federated States of Micronesia", "Fiji", "Finland",
                                              "France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece",
                                              "Grenade", "Guatemala", "Guinea", "Guyana", "Haiti", "Honduras",
                                              "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran",
                                              "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan",
                                              "Kazakhstan", "Kenya", "Kuwait", "Kyrgyzstan", "Laos", "Latvia",
                                              "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania",
                                              "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives",
                                              "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius",
                                              "Mexico", "Moldavia", "Mongolia", "Montenegro", "Morocco", "Mozambique",
                                              "Myanmar", "Namibia", "Nepal", "Netherlands", "New Caledonia",
                                              "New Zealand", "Nicaragua", "Niger", "Nigeria", "North Korea",
                                              "North Macedonia", "Northern Mariana Islands", "Norway", "Oman",
                                              "Pakistan", "Palestine", "Panama", "Papua New Guinea", "Paraguay",
                                              "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar",
                                              "Romania", "Russia", "Rwanda", "Saint Helena", "Saint Lucia",
                                              "Saint Vincent and the Grenadines", "Sao Tome and Principe",
                                              "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone",
                                              "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia",
                                              "South Africa", "South Korea", "South Sudan", "Spain", "Sri Lanka",
                                              "Sudan", "Suriname", "Sweden", "Switzerland", "Syria", "Taiwan",
                                              "Tajikistan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago",
                                              "Tunisia", "Türkiye", "Turkmenistan", "Turks and Caicos Islands",
                                              "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
                                              "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela",
                                              "Vietnam", "Yemen", "Zambia", "Zimbabwe"), class = "factor"),
               Average.IQ = c(106.48, 106.47, 105.89, 105.37, 104.1, 102.35,
                              101.6, 101.2, 101.07, 100.74), 
               Continent = structure(c(2L,2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L), levels = c("Africa","Asia", "Central America", "Europe", "Europe/Asia", "North America",
                                                                                          "Oceania", "South America"), class = "factor"), 
               Literacy.Rate = structure(c(51L,48L, 49L, 46L, 48L, 50L, 52L, 52L, 52L, 51L), 
                                         levels = c("0.19","0.3", "0.32", "0.33", "0.37", "0.38", "0.4", "0.43", "0.48",
                                                    "0.49", "0.52", "0.56", "0.58", "0.59", "0.6", "0.61", "0.63",
                                                    "0.64", "0.65", "0.66", "0.67", "0.68", "0.7", "0.71", "0.72",
                                                    "0.74", "0.75", "0.76", "0.77", "0.78", "0.79", "0.8", "0.81",
                                                    "0.82", "0.83", "0.84", "0.85", "0.86", "0.87", "0.88", "0.89",
                                                    "0.9", "0.91", "0.92", "0.93", "0.94", "0.95", "0.96", "0.97",
                                                    "0.98", "0.99", "1"), class = "factor"), 
               Nobel.Prizes = structure(c(17L,5L, 1L, 2L, 8L, 1L, 3L, 6L, 1L, 20L), 
                                        levels = c("0", "1","2", "3", "4", "5", "6", "8", "11", "12", "13", "19", "21","22", "27", "28", "29", "32", "71", "111", "137", "400"), class = "factor"),
               HDI..2021. = structure(c(136L, NA, 142L, 150L, 88L, 136L,
                                        103L, 143L, 139L, 145L), levels = c("0.385", "0.394", "0.4",
                                                                            "0.404", "0.426", "0.428", "0.446", "0.449", "0.455", "0.465",
                                                                            "0.477", "0.478", "0.479", "0.481", "0.492", "0.498", "0.5",
                                                                            "0.501", "0.508", "0.509", "0.511", "0.512", "0.514", "0.525",
                                                                            "0.534", "0.535", "0.539", "0.544", "0.549", "0.556", "0.558",
                                                                            "0.564", "0.565", "0.571", "0.575", "0.576", "0.577", "0.585",
                                                                            "0.586", "0.593", "0.597", "0.602", "0.607", "0.615", "0.618",
                                                                            "0.621", "0.627", "0.628", "0.632", "0.633", "0.639", "0.661",
                                                                            "0.666", "0.667", "0.675", "0.683", "0.685", "0.686", "0.691",
                                                                            "0.692", "0.693", "0.699", "0.703", "0.705", "0.706", "0.709",
                                                                            "0.713", "0.714", "0.715", "0.717", "0.718", "0.72", "0.727",
                                                                            "0.73", "0.731", "0.739", "0.74", "0.745", "0.747", "0.751",
                                                                            "0.752", "0.754", "0.758", "0.759", "0.762", "0.764", "0.767",
                                                                            "0.768", "0.77", "0.773", "0.774", "0.78", "0.782", "0.785",
                                                                            "0.788", "0.79", "0.795", "0.796", "0.8", "0.802", "0.803",
                                                                            "0.805", "0.808", "0.809", "0.81", "0.811", "0.812", "0.816",
                                                                            "0.821", "0.822", "0.829", "0.831", "0.832", "0.838", "0.842",
                                                                            "0.846", "0.848", "0.855", "0.858", "0.863", "0.866", "0.875",
                                                                            "0.876", "0.887", "0.889", "0.89", "0.895", "0.896", "0.903",
                                                                            "0.905", "0.911", "0.916", "0.918", "0.919", "0.921", "0.925",
                                                                            "0.929", "0.93", "0.935", "0.936", "0.937", "0.939", "0.94",
                                                                            "0.941", "0.942", "0.945", "0.947", "0.948", "0.951", "0.952",
                                                                            "0.959", "0.961", "0.962"), class = "factor"), 
               Mean.years.of.schooling...2021 = structure(c(80L,NA, 67L, 69L, 33L, 72L, 68L, 76L, 72L, 85L), 
                                                          levels = c("2.1","2.2", "2.3", "2.6", "2.9", "3", "3.1", "3.2", "3.8", "4.1",
                                                                     "4.3", "4.4", "4.5", "4.6", "4.7", "4.9", "5", "5.1", "5.2",
                                                                     "5.4", "5.6", "5.7", "5.9", "6", "6.2", "6.4", "6.7", "7",
                                                                     "7.1", "7.2", "7.3", "7.4", "7.6", "7.8", "7.9", "8.1", "8.3",
                                                                     "8.4", "8.5", "8.6", "8.7", "8.8", "8.9", "9", "9.2", "9.3",
                                                                     "9.4", "9.6", "9.8", "9.9", "10", "10.2", "10.3", "10.4",
                                                                     "10.5", "10.6", "10.7", "10.8", "10.9", "11", "11.1", "11.3",
                                                                     "11.4", "11.6", "11.7", "11.8", "11.9", "12.1", "12.2", "12.3",
                                                                     "12.4", "12.5", "12.6", "12.7", "12.8", "12.9", "13", "13.2",
                                                                     "13.3", "13.4", "13.5", "13.7", "13.8", "13.9", "14.1"), class = "factor"),
               GNI...2021 = structure(c(150L, NA, 178L, 170L, 111L, 153L,
                                        114L, 159L, 179L, 165L), levels = c("732", "768", "966",
                                                                            "1076", "1198", "1240", "1289", "1314", "1364", "1466", "1484",
                                                                            "1622", "1729", "1824", "2118", "2133", "2167", "2172", "2181",
                                                                            "2210", "2361", "2481", "2482", "2664", "2700", "2848", "2889",
                                                                            "3085", "3142", "3218", "3344", "3409", "3575", "3621", "3696",
                                                                            "3810", "3851", "3877", "4009", "4021", "4079", "4192", "4474",
                                                                            "4548", "4566", "4620", "4624", "4790", "4811", "5025", "5075",
                                                                            "5298", "5466", "5472", "5625", "5745", "6309", "6583", "6590",
                                                                            "7303", "7679", "7700", "7867", "7879", "7917", "8111", "8296",
                                                                            "8634", "8723", "8834", "8920", "9438", "9526", "9924", "9977",
                                                                            "9980", "10258", "10312", "10588", "10800", "11466", "11488",
                                                                            "11732", "11961", "12048", "12246", "12306", "12349", "12578",
                                                                            "12672", "12948", "13001", "13021", "13158", "13256", "13367",
                                                                            "13484", "14131", "14257", "14370", "14384", "14664", "14875",
                                                                            "15242", "15336", "15448", "15918", "16198", "16792", "17030",
                                                                            "17504", "17896", "17990", "18849", "19123", "19974", "20839",
                                                                            "20925", "21269", "22025", "22465", "23079", "23392", "23943",
                                                                            "24563", "25831", "26658", "26957", "27054", "27166", "29002",
                                                                            "30027", "30132", "30486", "30690", "31033", "32789", "32803",
                                                                            "33034", "33155", "37931", "38048", "38188", "38354", "38745",
                                                                            "38884", "39497", "39746", "41524", "42274", "42840", "44057",
                                                                            "44501", "45225", "45937", "46112", "46808", "49238", "49452",
                                                                            "51167", "52293", "52920", "53619", "54489", "54534", "55782",
                                                                            "55979", "60365", "62574", "62607", "64490", "64660", "64765",
                                                                            "66933", "76169", "84649", "87134", "90919", "146830"), class = "factor"),
               Population...2023 = structure(c(26L, 3L, 151L, 174L, 40L,
                                               134L, 190L, 145L, 1L, 179L), 
                                             levels = c("\t39315", " 32291","10143543", "10156239", "102262809", "10247605", "103.699",
                                                        "10329931", "10341277", "10412652", "10495295", "10593798",
                                                        "10612086", "107.66", "11088796", "11194449", "112716599",
                                                        "11332973", "11337053", "1136455", "115.224", "11686140",
                                                        "11724764", "117337368", "1210822", "123294513", "12388571",
                                                        "12458223", "126.184", "1260138", "126527060", "128455567",
                                                        "1300557", "1322766", "13238559", "1360596", "13712828",
                                                        "14094683", "14190612", "1425671352", "1428627663", "144444359",
                                                        "1485510", "1534937", "16665409", "16944826", "172954319",
                                                        "17618299", "17763163", "180.251", "18092026", "18143379",
                                                        "18190484", "18278568", "1830212", "19606634", "19629590",
                                                        "19892812", "20569738", "2085679", "20931751", "2119675",
                                                        "216422446", "21893579", "223804632", "231.856", "23227014",
                                                        "23251485", "23293699", "2330318", "240485658", "2436567",
                                                        "2604172", "26160822", "26439112", "2675353", "2716391",
                                                        "2718352", "27202843", "2773168", "277534123", "2777971",
                                                        "281.996", "2825544", "2832439", "28647293", "28838499",
                                                        "28873034", "292.991", "30325732", "30896590", "3210848",
                                                        "3260314", "334.506", "33897354", "339996564", "34121985",
                                                        "3423109", "34308525", "34352719", "3435931", "34449825",
                                                        "3447157", "35163944", "36684203", "36744634", "36947025",
                                                        "3728282", "3748902", "375.319", "37840044", "38781292",
                                                        "4008617", "41.996", "410.825", "41026068", "412.624", "42239854",
                                                        "4310108", "44.104", "4468087", "452.524", "45504560", "45606481",
                                                        "45773884", "4644384", "47519628", "48109006", "48582334",
                                                        "4862989", "49.796", "5040000", "5056935", "51784059", "52085168",
                                                        "521.022", "5212173", "5228100", "535.065", "5353930", "5418377",
                                                        "54577997", "5474360", "55100587", "5545475", "5742316",
                                                        "5795199", "58870763", "5910913", "6.115", "6014723", "60414495",
                                                        "6106869", "623.237", "626.485", "63.837", "6364943", "64756584",
                                                        "6516100", "654.768", "6687717", "6735348", "67438106", "67736802",
                                                        "6861524", "6888388", "69310", "704.15", "7046311", "7149077",
                                                        "71801279", "73.161", "740.425", "7491609", "76.965", "7633779",
                                                        "787.425", "813.834", "83294633", "852.075", "85816199",
                                                        "8791092", "8796669", "89172767", "8958961", "9053799", "9174520",
                                                        "936.375", "94.298", "9498238", "9516871", "98858950"), class = "factor")), row.names = c(NA,10L), class = "data.frame")


data$GNI...2021 <- as.numeric(as.character(data$GNI...2021))
data$Mean.years.of.schooling...2021 <- as.numeric(as.character(data$Mean.years.of.schooling...2021))
ggplot(data, aes(x = GNI...2021, y = Mean.years.of.schooling...2021)) +
  geom_point(color = "blue") +
  labs(title = "Effect of GNI on Mean Years of Schooling", x = "Gross National Income (GNI)", y = "Mean Years of Schooling")
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-05-19 with reprex v2.0.2

Thank you so so much for your help. That makes a lot more sense!

This topic was automatically closed 90 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.