Hbrandi
Hbrandi

Reputation: 171

Compute mean in R dependent on specific value in another variable

I have my dataset called IMS, consisting of 11 variables. strong text

I would like to compute the mean for the variable std.y for all observations where the variable pi == 1.

Anyone who can tell me how to compute this? :)

Best Regards, Henrik

Upvotes: 0

Views: 4611

Answers (1)

Señor O
Señor O

Reputation: 17412

mean(IMS$std.y[IMS$pi==1])

This is something you can get from most introductory texts on R - I'd recommend you look through those before posting questions here.

Upvotes: 6

Related Questions