I'm just having trouble understanding what must be a pretty straightforward remedy. I'm attempting to create two functions: one to determine the mean from a vector of values and the other to calculate the standard deviation. What I currently have is this:
Calculate Average - Function (Vec)
print(sum(vec)/length(vec))
}
list d – list (5,5)
calc avg(list d)
This is the error that is displayed: invalid 'type' (list) of arguments in sum(vec) error
The code is quite straightforward in my thoughts, however for some reason, R's sum function fails to detect the vec variable. It functions properly if I declare it simply as usual.
I'd be grateful for any assistance, and I admit that I know nothing about R.
Thanks.