[R] Mutate issue help needed

Neotropical bat risk assessments
Tue, 17 Dec 2024 13:44:50 -0000

Hi all,

It has been a year or so since I have run this code to plot temporal
activity.
It was working now I am getting an error related to MUTATE.

Error in UseMethod("mutate") :
 ? no applicable method for 'mutate' applied to an object of class
"character"
Any help/suggestions welcomed.
Tnx to all the R code gurus out there.
R v 4.4.0

Bat Dude

The saved code I used is below.? Perhaps a package has changed since I
last ran this?
++++++++++++++++++++++++

library(lubridate) *#date functions come from here*

library(tidyverse) *# dplyr and ggplot2 from here*

*setwd("T:\\Hondurus\\Temporal")*

*library(ggplot2); theme_set(theme_bw())#Works well*

*fname <- "Buzz.txt"*

#First assign data set to All with All<- *dataset*

All<- *fname *

# This uses Night and Time for X-Y labels

 ?evening <- function(datetime) {

update(datetime

, yday = yday(datetime) - if_else(am(datetime), 1, 0)

, hour = 17 *#Definedfor 17:00*

, minute = 0

, second = 0

)

}

*# Create labels and corresponding breaks for the time in seconds from 1700*

label_hours = c("17:00", "18:00", "19:00",
"20:00", "21:00", "22:00",
"23:00", "00:00", "01:00", "02:00",
"03:00", "04:00", "05:00", "06:00")

break_hours = c(0, 1:13*3600)

*# Fix the data column, combine the date and hour/min, and calculate the
elapsed time from #1700 in seconds*

 ?polished <-

All %>%

mutate(*#convert Date from chr to Date*

Date = as.Date(Date, "%m/%d/%Y")

*#combine day and hour/min including **UTC*

, datetime = as.POSIXct(paste(Date, Time, sep = " ","%Y-%m-%d
%H:%M"),
tz = "UTC")

*#Now calculate the number of seconds since the start of the evening*

, evening = evening(datetime)

, Night = format(as.Date(evening), "%b %d, %Y")

, Time = as.double(datetime - evening, "secs")

)

*Error in UseMethod("mutate") :
 ? no applicable method for 'mutate' applied to an object of class
"character"*

ggplot(polished, aes(x =Night, y = Time, colour = Species)) +

#geom_jitter() +

geom_point()+

*scale_colour_hue(l=40)+*

ggtitle(label = 'Feeding buzz temporal activity')+

facet_grid(. ~ Night) +facet_wrap(facets = ~Species)+

scale_y_continuous(labels = label_hours, breaks = break_hours) +

theme(axis.text.x = element_text(angle = 270))



--
Bruce W. Miller, PhD.
Neotropical bat acoustic assessments, ID keys and Fact Sheets
Research Fellow - Wildlife Conservation Society - Ret.
Research Associate, American Museum of Natural History

Freely mentoring the next generation of bat biologists and conservationists
since 1995

If we lose the bats, we may lose much of the tropical vegetation and the lungs
of the planet

Using acoustic sampling to identify and map species distributions
and pioneering acoustic tools for ecology and conservation of bats for >28
years.

https://www.researchgate.net/profile/Bruce-Miller-5
Key projects include providing free interactive identification keys and call
fact sheets for the vocal signatures of New World Bats

	[[alternative HTML version deleted]]