lundi 22 juin 2015

R programming doesn't recognize else [duplicate]

This question already has an answer here:

I am create if - else within R script and I get unexpected token "else"

library(ggmap)
Sub1 <- sep[grep("SEP.11", names(sep))]
sep$newCol <- 100*rowSums(Sub1)/rowSums(sep[4:7])
library(sp)
coords <- cbind(Longitude = as.numeric(as.character(sep$Longitude)),Latitude=as.numeric(as.character(sep$Latitude)))

if (sep$newCol < 50){
  sep.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)],proj4string = CRS("+init=epsg:4326"))
}
else  {
  sep2.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)],proj4string = CRS("+init=epsg:4326"))
}

I checked the correct formatting for if - else in R programming, why this error?

Aucun commentaire:

Enregistrer un commentaire