To find the average of a single variable in a dataset in R, you can use the mean()
function.
Assuming your dataset is named data
and the variable you want to find the average for is named var
, you can use the following code:
main.r15 chars2 lines
This code will return the average value of the var
variable in the data
dataset.
If you want to round the average value to a certain number of decimal places, you can use the round()
function. For example, to round the average to 2 decimal places, you can use the following code:
main.r25 chars2 lines
I hope this helps!
gistlibby LogSnag