在 R 中,打印数据框中人口密度最高的国家

In R, Print the country with the highest population density in the dataframe

https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2019_TotalPopulationBySex.csv

我想打印人口密度最高的国家以及该数据库数据框中给出的国家的所有详细信息。也只有 2020

的数据

我该怎么做?

可以吗?

data=read.csv('https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2019_TotalPopulationBySex.csv', header = T)
a= unique(data[data$PopDensity==max(data[data$Time==2020,'PopDensity']),'Location'])
print(a)
view(data[data$Location==a&data$Time==2020,])