Using help on this site I have already got the following code from where I can perform certain analyses. However, I'd now like to perform analyses on a certain variable (column z) within the point shapefile. To do this I need to establish 'marks' on column z (the 7th column). This column provides either a '4' or a '10', defining two types of point.

Can anyone assist?

##Run libraries: 

##set the working directory

##read in the shapefiles
Points <- readOGR(getwd(), "MyPointShapefile")
StudyArea <- readOGR(getwd(), "MyPolygonShapefile")

##create the window from polygon shp
w <- as.owin(StudyArea)

##coerce the points to window
pts.ppp <- as.ppp(coordinates(Points), w)

If the marks are created based off another attribute, then you could probably just use an if-else statement. You can simply create a new column by creating a variable ie.

Points$NewMarks <- ifelse(X, Y, Z)


X = Your argument (if statement), Y = Your then statement (for you: 4), and Z = Else statement (for you: 10)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.