我有一个原始的经度/纬度数据,其格式无法由R map处理.所以我想知道是否有一些R函数或算法来帮助我将这些原始数据转换为可读格式.(也许是UTM)这是我的原始数据:
纬度: "32-14-23 N""31-04-27 N""33-45-28 N"
经度: "121-22-38 W""119-30-05 W""122-47-52 W"
我希望将格式转换为(下面的示例是模拟数据):
经度: -2.748
纬度: 53.39
在R语言中,我想使用switch语句来替换nest if else语句.我想为新列分配值,我的想法是:
## Create a function to seperate the case
Range <- function(x)
if (CityData_Group_Copy$BadDebtNum[x] < 26)
{ CityData_Group_Copy$BadDebtRange[x] <- "1~25"}
else if(CityData_Group_Copy$BadDebtNum[x] > 25 && CityData_Group_Copy$BadDebtNum[x] < 51)
{CityData_Group_Copy$BadDebtRange[x] <- "26~50"}
else if(CityData_Group_Copy$BadDebtNum[x] > 51 && CityData_Group_Copy$BadDebtNum[x] < 76)
{CityData_Group_Copy$BadDebtRange[x] <- "51~75"}
else if(CityData_Group_Copy$BadDebtNum[x] > 75 && CityData_Group_Copy$BadDebtNum[x] < 101)
{CityData_Group_Copy$BadDebtRange[x] <- "76~100"}
else if(CityData_Group_Copy$BadDebtNum[x] > 100)
{ CityData_Group_Copy$BadDebtRange[x] <- "100+"}
## Assign the result to the new column "CityData_Group_Copy$BadDebtRange"
for(i in 1: nrow(CityData_Group_Copy) ){
Range(i)
}
Run Code Online (Sandbox Code Playgroud)
我也试过这个解决方案: …