0

I have a small data frame (see below) containing 2 species "Aganope" and "Brienope" (factor format) with its geographical coordinates (19 lines records for Aganope and 12 lines for Brienope). I want to make the map of this species and, for the first one, my code is:

library(dismo)
str(data)
data
data<-data[1:19,]
str(data)
data
acgeo <- subset(data, !is.na(EST) & !is.na(SOUTH))
dim(acgeo)
acgeo[1:19, c(1:3,1:3)]
# Placer tous les lieux de récolte de Aganope sur le fond de carte bioclimate 5
points(acgeo$EST, acgeo$SOUTH, col="red", pch=21, bg="black", cex=1)

In this code, I choose my species by the number of lines of the data frame (here species "Aganope" since line 1 to line 19). I will have very soon many more species in this data frame. My question is : Do you have a method for mapping this species by the factor's name (Aganope or Brienope) and NOT by numbering the line of the data frame?

Yours sincerely

Here is my data frame

Number  Species_name    Collector_name  East    South  
1   Aganope Antila_1186 49.8427778  -15.4327778  
2   Aganope Bar_2365    48.4166667  -17.5500000  
3   Aganope Bern_1760   50.2344444  -15.3352778  
4   Aganope Carl_43 49.7500000  -15.4833333  
5   Aganope Flore_1979  49.7666667  -15.5000000  
6   Aganope Milir_3654  49.7666667  -15.5000000  
7   Aganope Perret_2062 50.4333333  -15.1833333  
8   Aganope Raharim_21401   49.7166667  -16.4500000  
9   Aganope Ralim_109   50.0138889  -15.2869444  
10  Aganope Sciza_1351  49.9500000  -15.6000000  
11  Aganope Sciza_1354  50.0166667  -15.7833333  
12  Aganope Sciza_1370  49.7666667  -15.5000000  
13  Aganope Sciza_2016  49.7666667  -15.5000000  
14  Aganope Serfa_18305 49.8497222  -15.4194444  
15  Aganope Serfa_19221 49.3916667  -17.2833333  
16  Aganope Serfa_28814 49.8833333  -16.8833333  
17  Aganope Serfa_28847 49.8997222  -16.8983333  
18  Aganope Serfa_32138 48.9333333  -19.0333333  
19  Aganope Serfa_32245 48.9333333  -19.0333333  
20  Brienope    Dery_10119  47.1000000  -24.9833333  
21  Brienope    Dery_10210  46.9350000  -25.0486111  
22  Brienope    Dery_4230   46.9983333  -25.0397222  
23  Brienope    Dutz_544    47.0000000  -24.9500000  
24  Brienope    Dutz_756    47.1666667  -24.7833333  
25  Brienope    Rabetra_1835    46.8500000  -25.0666667  
26  Brienope    Rabetra_1892    47.0000000  -24.9500000  
27  Brienope    Rason_5 47.1569444  -24.8127778  
28  Brienope    Ratafika_748    46.9980556  -25.0405556  
29  Brienope    Scott_2473  46.9963889  -25.0416667  
30  Brienope    Serfa_21443 47.2000000  -24.5750000  
31  Brienope    Serfa_28332 46.9330556  -25.0494444  
tonytonov
  • 25,060
  • 16
  • 82
  • 98
  • You didn't include a sample value for `data` here so your problem isn't [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Read that link for tips on sharing sample data so that we can run the same code as you. Why have you included `library(dismo)` here? You don't seem to be using any functions from that package. I'm guessing you might just want `acgeo[acgeo[,1]=="Aganope",]` assuming that the species is in the first column. – MrFlick Jul 03 '14 at 20:29
  • have you tried `newdata <- acgeo[acgeo$species == "Aganope",]`? that's similar to what @MrFlick suggested, but if `data` is something `gbif` produced (or a similar function), then you can just subset on the `species` column. – hrbrmstr Jul 04 '14 at 01:01
  • As an advance thank you for yours responses. I send in the previous message my data frame. – user3370470 Jul 04 '14 at 14:05

1 Answers1

0

Yes!

Note that you cannot call points without calling a plot before. There're some other issues with the notation used in your code and the one in the table.

data <- read.csv() #Your raw data
subset<-data[data$Species_name == "Aganope",]
plot(subset$East, subset$South, col="red", pch=21, bg="black", cex=1)

Good luck!

CRP
  • 405
  • 2
  • 11