Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I am starting learning R now and having a couple of questions, hope someone

ID: 642726 • Letter: H

Question

Hi, I am starting learning R now and having a couple of questions, hope someone can help me out.

1. how to use a data set to calculate mean , median, standard deviation, and other things? For example, if I have a data set I, with two variables named age and salary. If I want to calculate mean and median for each of them, how should I do? If I want to use age and salary as seuqences, how should I do?

2. How can I make a formula with a sequence? For example, after I make a sequence x, I want to use it to make this fomula: y = ax+b, whereas a and b are two constants.

3. how do I add, substract, or mutiple two formulas? specifically those formulas with sequences as input, so that I can obtain sequences as output as well.

thanks again,

Explanation / Answer

1)
marks = students$marks # In student dalalist calculating the marks standard deviation
sd(marks)
similarly mean,median function

2 & 3)
------------------------------------------------------------------
I can explain through these examples....
class(fo <- y ~ x1*x2) # "formula"
fo
typeof(fo) # R internal : "language"
terms(fo)

environment(fo)
environment(as.formula("y ~ x"))
environment(as.formula("y ~ x", env = new.env()))

---------------------------------------------------------------------------------------------
## Create a formula for a model with a large number of variables:
xnam <- paste0("x", 1:25)
(fmla <- as.formula(paste("y ~ ", paste(xnam, collapse= "+"))))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote