0

500種のデータフレームと、さまざまな種の25,000ポイントの局所観測があります。個々の種のポイントマップを作成したいと思います。マップ上の各ポイントは種の出現です。作成するマップが非常に多いため、これをループで実行する必要があります。これは私がこれまでに持っているものです。

#loop for making species map 1.1
species <- levels(raw$SpCode)
for(i in 1:length(species))  
            {
            #open the file for writing
             pdf(species[i], file=".pdf", width=5, height=4)
             plot (wrld_simpl, xlim=c(-100,-55), ylim=c(23,63), axes=TRUE, col='light grey')
             box() #adds box around map
             title(main=species[i]) #adds main title to map which should be the species name associated with the data
             points(raw, species[i]$longitude, species[i]$latittude, col='black', pch=21, bg="red", cex=0.85)
             dev.off()
             }

私が得ている主なエラー出力は次のとおりです。

“Error in species[i]$longitude : $ operator is invalid for atomic vectors
In addition: Warning message:
‘mode(onefile)’ differs between new and previous==> NOT changing ‘onefile’"

これを進める方法についてのアドバイスは役に立ちます。maptoolsパッケージを使用して、これらのマップを作成しようとしています。

乾杯、イスラエル

4

1 に答える 1

0

種マップ 1.2 を pdf として保存するためのループ

これを理解するのを手伝ってくれてありがとうジョラン!:)

species <- levels(raw$SpCode)
for(i in 1:length(species))  
            {
            #open the file for writing
             pdf(paste0(species[i],".pdf"),width=5,height=4)
             plot (wrld_simpl, xlim=c(-100,-55), ylim=c(23,63), axes=TRUE, col='light grey')
             box() #adds box around map
             title(main=species[i]) #adds main title to map which should be the species name associated with the data
             points(raw$longitude[raw$SpCode == species[i]],raw$latitude[raw$SpCode == species[i]], col='black', pch=21, bg="red", cex=0.85)
             dev.off()
             }
于 2013-01-31T23:13:25.657 に答える