bayesLife Package

I was having a problem while running the bayesLife package. For your information, I have successfully installed the package and my Rstudio is the updated version (4.3.2). Nevertheless, the output keeps showing that it could not find the function bayesLife, what should I do? I am really hoping for an answer soon. Because currently, I am working on my final year project.


le_female <- read_excel("FYP SEM6/le_female.xlsx")


country_code <- "Malaysia"
le_data <- le_female[which(le_female$Location == country_code),]

years <- le_data$Year
life_expectancy <- le_data$Adjusted Life Expectancy



"Year" %in% names(le_data)
"Adjusted Life Expectancy" names (le_data)

all(is.numeric(le_data$Adjusted Life Expectancy))
"Adjusted Life Expectancy" %in% names(le_data)

plot(years, life_expectancy, type = "l", main = paste("Life Expectancy in", country_code),
xlab = "Year", ylab = "Life Expectancy", col = "blue")

model <- bayesLife(years=years, data=life_expectancy, iterations=10000)

fit <- model$fit()

It would help to have some sample data and any error messages.

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between


I cannot see how this expression can work

life_expectancy <- le_data$Adjusted Life Expectancy

R will not accept a variable with spaces. Youcan write it as

`Adjusted Life Expectancy`  

or perhaps

Adjusted_Life Expectancy

should work.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.