[R] Error message: object 'A' not found
stephg0809
stephg0809 at gmail.com
Thu Dec 1 22:51:38 CET 2011
I ran the following code:
And I run into problems with the last line of code (when it says
hn<-......). I keep getting an error code: Error in distsamp(~hab ~ 1,
peldist, keyfun = "halfnorm", output = "density", :
object 'A' not found
I would appreciate any and all help.
rm(list=ls(all=TRUE)) #clear the computer's
memory of variables
setwd("E:\\Analysis")
# Part 1
library(unmarked) # this loads the
'unmarked' package in R
Pellet <- read.table("PelletDistance.csv", sep=",", header=T) # read in the
data
head(Pellet) # this provides a
header of the first few lines of data and variable names
Treatment <- Pellet[66:166,] # Isolates
data for just the good habitat
Control <- Pellet[1:65,] # same for bad
habitat
hist(Pellet$Distance,freq=F,xlim=c(0,7)) # plots a histogram, or
frequency distribution of the data
# Part 2
# Create formated distance response matrix
cp <- c(0,0.50,2,3.50,5.00,6.50) # Distance cut
points defining distance intervals
yDat <- formatDistData(Pellet, "Distance", "Line", cp) # This creates a
formatted data matrix for number of observations at each distance interval
for each transect
yDat
# Prepare habitat covariates for each transect based on the stratum they
reside in
hab <-
matrix(c("C","C","C","C","C","C","C","C","C","T","T","T","T","T","T","T","T","T"),nrow=18,ncol=1)
#CHANGE THIS!!! nrow=# of T and Cs or A-Ks (same #)
hab <- data.frame(hab)
#Year effects
year <-
matrix(c("Year1","Year1","Year1","Year1","Year2","Year2","Year2","Year2","Year2","Year1","Year1","Year1","Year1","Year2","Year2","Year2","Year2","Year2"),nrow=18,ncol=1)
#CHANGE THIS!!! to match number of A-Ks And change nrow
year <- data.frame(year)
# Prepare transect lengths
len <-
as.numeric(c(100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100))
#Make this equal A, AA....KK for number of 10000s
# Organize distance data along with covariates and metadata, MAKE SURE THESE
COVARIATES ARE RIGHT, MAYBE I CAN ADD MINE HERE
peldist <- unmarkedFrameDS(y=yDat, siteCovs = data.frame(hab, year),
dist.breaks=cp, tlength=len, survey="Line", unitsIn="m")
peldist # look at the data
summary(peldist) # get a summary of
the data
# Part 3
# Fit models without covariates
hn <- distsamp(~1 ~1, peldist, keyfun="halfnorm", output="density",
unitsOut="ha")
--
View this message in context: http://r.789695.n4.nabble.com/Error-message-object-A-not-found-tp4140237p4140237.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list