My categorical variable, risk, is divided into three groups: ADV, HHM, and POV.

It's the,2:5 of my dataset and an old textbook example. I used the following code, which appears to be incorrect despite the fact that it is correct according to the textbook example:

ddply(.data = MPLS[,2:5],.variables =.(MPLS\$risk), myrisk

na.rm = TRUE,.fun = mean)

Earlier today, I received an error message for a section of code that read:

mean(MPLS[,2:5], na.rm = TRUE) - mymeans

When I googled it, I discovered that the R software had changed, and I needed to find another to operate with.
Jun 17, 2022 381 views

## 1 answer to this question.

```df<-data.frame(risk= rep(c("ADV","HHM","POV"),10),
#1  ADV 30.78281 30.00721 29.80906 29.25936
#2  HHM 29.76175 29.63864 29.39256 29.40070
#3  POV 29.00964 30.48258 29.20662 28.77509
#4  ADV 29.60631 30.35032 32.00376 30.70374
#5  HHM 31.38653 30.28896 29.48756 30.32430
#6  POV 30.33102 30.40897 29.55796 30.10585

library(dplyr)

df %>% group_by(risk) %>% summarise_all(mean)

# A tibble: 3 x 5
#  <fct>  <dbl>  <dbl>  <dbl>  <dbl>
1 ADV     30.3   30.2   30.2   30.4
2 HHM     29.7   30.5   29.8   29.9
3 POV     29.3   30.2   29.9   30.2

```
• 3,040 points

## https://www.edureka.co/community/183864/mean-of-categorical-variables-from-plyr-package

I'm modelling with the fpp2 package's data ...READ MORE

## How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

+1 vote

## Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE

+1 vote

## Finding number of missing values and removing those missing values from a data-frame

To find number of missing values for ...READ MORE

## R: Sample from a neighborhood according to scores

I would suggest you to use the truncated ...READ MORE

## How to sample random rows in dataframe?

Create data frame and then implement as ...READ MORE

## How to sample n random rows per group in a dataframe?

You can assign a random ID to ...READ MORE

## 100 samples of 20 from the dataset and drawing regression lines along with population regression line

I have a datasetwith two variables hours ...READ MORE