Dear Prof. Bivand, Thank you for replying to my email so quickly! And I am looking for the next release of the package.
Also thank you for telling me the proper way of communication in the email list. I appreciate it and will follow it. Have a warm nice weekend! Ҷ�� YE, Xiang THINKING SPATIALLY<http://www.linkedin.com/in/spatialyexiang>. Ph.D. in Spatial Statistics ________________________________ ������: Roger Bivand <roger.biv...@nhh.no> ����ʱ��: 2024��1��18�� 20:52 �ռ���: R Special Interest Group on using Geographical data and Mapping <r-sig-geo@r-project.org>; Xiang Ye <xian...@buffalo.edu> ����: Re: How to attach customized row.names to poly2nb() [?ͨ�������յ����� roger.biv...@nhh.no ��?��?��??? https://aka.ms/LearnAboutSenderIdentification�����˽�?һ��?ʲ?����Ҫ]<https://aka.ms/LearnAboutSenderIdentification%EF%BC%8C%E4%BB%A5%E4%BA%86%E8%A7%A3?%E4%B8%80%E7%82%B9?%E4%BB%80?%E5%BE%88%E9%87%8D%E8%A6%81]> Please never attach screenshots, nobody can copy/paste the code shown in them. Thus: library(spdep) library(spDataLarge) data(bristol_zones) bqueen <- poly2nb(bristol_zones, row.names=bristol_zones$name) However, updating to also suppport sf removed the facility of setting through the row.names= argument: attr(bqueen, "region.id")[bqueen[[1]]] # [1] "2" "39" "44" "50" "86" "94" https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fr-spatial%2Fspdep%2Fblob%2Fb815397c2ce0d58b3b4ca0c36bba7b5c3abbbcc2%2FR%2Fpoly2nb.R%23L16-L20&data=05%7C02%7Cxiangye%40buffalo.edu%7Cba13b377482e474835fa08dc18245b32%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638411791628580321%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=FJyVOpUcPHsy0jEtiXNIh4clAk6XZgeU5lFwlcXwBj4%3D&reserved=0<https://github.com/r-spatial/spdep/blob/b815397c2ce0d58b3b4ca0c36bba7b5c3abbbcc2/R/poly2nb.R#L16-L20> poly2nb(as(bristol_zones, "Spatial"), row.names = bristol_zones$name) attr(bqueen, "region.id")[bqueen[[1]]] # [1] "Bath and North East Somerset 003" "Bristol 038" # [3] "Bristol 043" "Bristol 049" # [5] "South Gloucestershire 024" "South Gloucestershire 032" I've raised this issue https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fr-spatial%2Fspdep%2Fissues%2F143&data=05%7C02%7Cxiangye%40buffalo.edu%7Cba13b377482e474835fa08dc18245b32%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638411791628589305%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=N4KsmyMx4YbonTJxI1ygLNETbxj%2BFO4g%2BLhdbwOWB%2FU%3D&reserved=0<https://github.com/r-spatial/spdep/issues/143> so this should work again at the next release. Roger -- Roger Bivand Emeritus Professor Norwegian School of Economics Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway roger.biv...@nhh.no ________________________________________ From: R-sig-Geo <r-sig-geo-boun...@r-project.org> on behalf of Xiang Ye via R-sig-Geo <r-sig-geo@r-project.org> Sent: 18 January 2024 13:30 To: R Special Interest Group on using Geographical data and Mapping Subject: [R-sig-Geo] How to attach customized row.names to poly2nb() Dear community, It should be a very simple question with a straightforward answer - so please forgive my foolishness. By default, poly2nb() provides the neighbor list of a region in terms of numbers, for example: library(spdep) library(spDataLarge) poly2nb(bristol_zones) -> bqueen bqueen[1] The output is [cid:157ba602-300e-4f6b-8875-ea050def287c] which is expected. But often the case this is not convenient. So I want to provide a vector of names to label each region, and expect when I type bqueen[1], it can return something like a list of place names. According to the help of poly2nb(), this is implemented by row.names(). However, it does not work: [cid:be6a526c-5629-4c17-af44-972fb84f4a04] It looks like the output neglects the argument of row.names. How should I solve this issue? Thanks in advance! Ҷ�� YE, Xiang THINKING SPATIALLY<https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fspatialyexiang&data=05%7C02%7Cxiangye%40buffalo.edu%7Cba13b377482e474835fa08dc18245b32%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638411791628593387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WS4Fa7MZqC4jJKgIXA1rNEbef7vREC4I6DJQHoSZTG0%3D&reserved=0<http://www.linkedin.com/in/spatialyexiang>>. Ph.D. in Spatial Statistics [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo