help with writing function

Dear all,
I am encountering the error 'mydata not found' when running the below function.
It is related tot the predictAll function from the gamlss package. Somehow the original data (mydata) used for fitting the gamlss object is not recognized, even though I specify it specifically in the first row of the function.
Does anyone know how to solve this?
Many thanks in advance!

You need to show how you are calling this function.

iadl_irt_normscore(iald_irt=66, lftd=55, educ_dich=1, gamlss_obj=gmod), where gmod is a gamlss model object.

when you fit with gamlss, there is no general mechanism by which your original data is packed into allowing you to get it back in the form it went in. If you want that, I think you would have construct it.

# default example of gamlss use
library(gamlss)
data(abdom)
mod<-gamlss(y~pb(x),sigma.fo=~pb(x),family=BCT, data=abdom, method=mixed(1,20))
plot(mod)
# end of default example 

# these dont do anything ...
mod$mydata
mod$abdom

#constructing it to contain the original data
mod$mydata <- abdom
# now it is there
mod$mydata

A newbie stuck in date formatting.

The started_at column contains both date and time. I need to extract the date only. I used the functions below and I got errors.

all_trips_clean$date <- as.Date(all_trips_clean$started_at)
Error in charToDate(x): character string is not in a standard unambiguous format

Then I decided to change the date format, and got into a bigger mess:

all_trips_cleaned <- mdy_hms(all_trips_clean$started_at)
Warning message: All formats failed to parse. No formats found.

Please help.

Your reply is not related to the original topic. If my suggestion does not work, it would be best to start a new topic with your question.

The data includes hour and minute but not seconds. Try mdy_hm()instead.

Didn't mean to hijack the thread, but I found one solution to my problem so just wanted to share for benefit of others. The below will change the column type to character while updating the string to y/m/d h:m:s format:

all_trips_clean$started_at <- as.character(as.POSIXct(all_trips_clean$started_at, format = "%m/%d/%Y %H:%M"))

Then, I can use the below to change col type to date-time format:

x <- all_trips_clean %>% mutate(started_at = ymd_hms(started_at))

And then extraction of any further date,time value is a walk in the park.