Hi Bruce, I wonder how it could have worked exactly as you quoted in the past.
the problem starts here > fname <- "Buzz.txt" > # First assign data set to All with All<- *dataset* > All<- fname actually you don't assign a dataset to 'All', but a character (the file name), I assume you want to read this file with read.table or alike Best Am 17.12.2024 um 13:30 schrieb Bruce Miller: > 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)) > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttps://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. Eik Vettorazzi Universitätsklinikum Hamburg-Eppendorf Institut für Medizinische Biometrie und Epidemiologie Christoph-Probst-Weg 1 4. Obergeschoss, Raum 04.1.021.1 20246 Hamburg Telefon: +49 (0) 40 7410 - 58243 Fax: +49 (0) 40 7410 - 57790 Web:www.uke.de/imbe -- _____________________________________________________________________ Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Prölß, Prof. Dr. Blanche Schwappach-Pignataro, Corinna Wriedt _____________________________________________________________________ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.