This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(maptools)
## Loading required package: sp
## Checking rgeos availability: FALSE
##      Note: when rgeos is not available, polygon geometry     computations in maptools depend on gpclib,
##      which has a restricted licence. It is disabled by default;
##      to enable gpclib, type gpclibPermit()
library(rgdal)
## rgdal: version: 0.9-2, (SVN revision 526)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 1.11.2, released 2015/02/10
## Path to GDAL shared files: C:/Users/Franklin/Documents/R/win-library/3.2/rgdal/gdal
## GDAL does not use iconv for recoding strings.
## Loaded PROJ.4 runtime: Rel. 4.9.1, 04 March 2015, [PJ_VERSION: 491]
## Path to PROJ.4 shared files: C:/Users/Franklin/Documents/R/win-library/3.2/rgdal/proj
library(spatstat)
## 
## spatstat 1.41-1       (nickname: 'Ides of March') 
## For an introduction to spatstat, type 'beginner'
setwd("C:/Project3/point_data")
crn = readOGR(".","USCont_CRN")
## OGR data source with driver: ESRI Shapefile 
## Source: ".", layer: "USCont_CRN"
## with 117 features
## It has 6 fields
crn.sp = as(crn, "SpatialPoints")
summary(crn.sp)
## Object of class SpatialPoints
## Coordinates:
##                  min     max
## coords.x1 -2313146.7 2122466
## coords.x2   387755.6 3090392
## coords.x3        3.0    9828
## Is projected: TRUE 
## proj4string :
## [+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0
## +y_0=0 +ellps=GRS80 +units=m +no_defs]
## Number of points: 117
crn.pp = as(crn.sp, 'ppp')
q = quadratcount(crn.pp, 6, 3)
plot(q)
plot(crn.pp, add=T)

quadrat.test(crn.pp, 6, 3)
## 
##  Chi-squared test of CSR using quadrat counts
##  Pearson X2 statistic
## 
## data:  crn.pp
## X2 = 21, df = 17, p-value = 0.4526
## alternative hypothesis: two.sided
## 
## Quadrats: 6 by 3 grid of tiles
ws = readOGR(".","WS_clip")
## OGR data source with driver: ESRI Shapefile 
## Source: ".", layer: "WS_clip"
## with 1857 features
## It has 7 fields
ws.sp = as(ws, "SpatialPoints")
summary(ws.sp)
## Object of class SpatialPoints
## Coordinates:
##                min     max
## coords.x1 -2339664 2162388
## coords.x2   278429 3138892
## Is projected: TRUE 
## proj4string :
## [+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0
## +y_0=0 +ellps=GRS80 +units=m +no_defs]
## Number of points: 1857
ws.pp = as(ws.sp, 'ppp')
q = quadratcount(ws.pp, 6, 3)
plot(q)
plot(ws.pp, add=T)

quadrat.test(ws.pp, 6, 3)
## 
##  Chi-squared test of CSR using quadrat counts
##  Pearson X2 statistic
## 
## data:  ws.pp
## X2 = 565.52, df = 17, p-value < 2.2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 6 by 3 grid of tiles

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.