How to calculate the mean sd of a vector without using the in-built R function

0 votes
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.
Jul 25, 2022 in Data Analytics by avinash
• 1,840 points

edited Mar 4 3 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP