[R] Error in eval(expr, envir, enclos) : object 'Rayos' not found???

David Winsemius dwinsemius at comcast.net
Tue May 15 15:56:30 CEST 2012


On May 15, 2012, at 5:58 AM, Jhope wrote:

> Hi R-listers,
>
> I am trying to make a trellis boxplot with the HSuccess (y-axis) in  
> each
> Rayos (beach sections) (x-axis), for each Aeventexhumed (A, B, C) -  
> nesting
> event. I am not able to do so and keep receiving:
>
> Error in eval(expr, envir, enclos) : object 'Rayos' not found
>
> Please advise,
>

You are passing vectors to lattice and expecting grouping. It doesn't  
generally expect to be getting vectors as its main data argument,  
instead expect to gather than from a dataframe. It's possible  
everything would work if you instead used;

bwplot(HSuccess~Rayos|Aeventexhumed, data=data.to.analyze)

(Untested, of course, since you have not made the question  
reproducible, or minimal for that matter.)

-- 
David.
> Jean
>
>
> require(plyr)
>
> resp <- read.csv("ABC Arribada R File Dec 12 Jean Jang.csv")
> envir <- read.csv("Responses Environ. Arribada Dec. 12.csv")
>
> resp <- resp[!is.na(resp$Aeventexhumed), ]
> resp$QuadratEvent <- paste(resp$QuadratID, resp$Aeventexhumed, sep="")
> resp$QuadratEvent <- as.character(resp$QuadratEvent)
>
> envir <- envir[!is.na(envir$Aeventexhumed), ]
> envir$QuadratEvent <- paste(envir$QuadratID, envir$Aeventexhumed,  
> sep="")
> envir$QuadratEvent <- as.character(envir$QuadratEvent)
>
>
> ExDate <- Sector <- Quadrat <- Aeventexhumed <- NULL
> ST1 <- ST2 <- ST3 <- ST4 <- ST0 <- NULL
> Shells <- Hatchlings <- MaxHatch <- DeadHatch <- NULL
> Oldeggs <- TotalEggs <- QuadratEvent <- NULL
>
> for (q in unique(as.character(resp$QuadratEvent))) {
>
>    s <- resp[as.character(resp$QuadratEvent) == q, ]
>
>    ExDate <- c(ExDate, as.character(s$ExDate[1]))
>    Sector <- c(Sector, as.character(s$Sector[1]))
>    Quadrat <- c(Quadrat, as.character(s$Quadrat[1]))
>    Aeventexhumed <- as.character(c(Aeventexhumed,
> as.character(s$Aeventexhumed[1])))
>    QuadratEvent<- c(QuadratEvent, q)
>
>    ST1 <- c(ST1, sum(s$ST1, na.rm=TRUE))
>    ST2 <- c(ST2, sum(s$ST2, na.rm=TRUE))
>    ST3 <- c(ST3, sum(s$ST3, na.rm=TRUE))
>    ST4 <- c(ST4, sum(s$ST4, na.rm=TRUE))
>    ST0 <- c(ST0, sum(s$ST0, na.rm=TRUE))
>
>    Shells <- c(Shells, sum(s$Shells, na.rm=TRUE))
>    Hatchlings <- c(Hatchlings, sum(s$Hatchlings, na.rm=TRUE))
>    MaxHatch <- c(MaxHatch, sum(s$MaxHatch, na.rm=TRUE))
>    DeadHatch <- c(DeadHatch, sum(s$DeadHatch, na.rm=TRUE))
>    Oldeggs <- c(Oldeggs, sum(s$Oldeggs, na.rm=TRUE))
>    TotalEggs <- c(TotalEggs, sum(s$TotalEggs, na.rm=TRUE))
> }
>
> responses <- data.frame(QuadratEvent, ExDate, Sector, Quadrat,
>                        Aeventexhumed, ST0, ST1, ST2, ST3, ST4, Shells,
>                        Hatchlings, MaxHatch, DeadHatch, Oldeggs,
>                        TotalEggs, stringsAsFactors=FALSE)
>
> responses$QuadratEvent <- as.character(responses$QuadratEvent)
>
> data.to.analyze <- join(responses, envir, by="QuadratEvent")
> data.to.analyze$NotHatched <- data.to.analyze$TotalEggs -
> data.to.analyze$MaxHatch
> data.to.analyze$Rayos <- paste("Rayos", data.to.analyze$Rayos,  
> sep=".")
>
> HSuccess <- Shells/TotalEggs
>> library(lattice)
>> trellis.par.set(col.whitebg())
>> bwplot(HSuccess~Rayos|Aeventexhumed)
> Error in eval(expr, envir, enclos) : object 'Rayos' not found
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-in-eval-expr-envir-enclos-object-Rayos-not-found-tp4630049.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list