Question

In: Computer Science

R-Studio (R Programming Language) 4. Let the data x be given by `x <- c(1, 8,...

R-Studio (R Programming Language)


4. Let the data x be given by
`x <- c(1, 8, 2, 6, 3, 8, 5, 5, 5, 5)`
Use R to compute the following functions. Note, we use X1 to denote the first element of x (which is 1) etc.   
1. `(X1 + X2 + . . .+ X10)/10` (use sum)   
2. Find log10(Xi) for each i. (Use the log function which by default is base e)
3. Find `(Xi - 4.4)/2.875` for each i. (Do it all at once)   
4. Find the difference between the largest and smallest values of x. (This is the range. You can use `max` and
`min` or guess a built in command.)

```{r}
#insert your code
```

Solutions

Expert Solution

# create vector
x <- c(1, 8, 2, 6, 3, 8, 5, 5, 5, 5)
#1.`(X1 + X2 + . . .+ X10)/10` (use sum)
avg<-sum(x)/10
avg
# 2. Find log10(Xi) for each i. (Use the log function which by default is base e)
for (X in x){
print(log10(X))
}
#3. Find `(Xi - 4.4)/2.875` for each i. (Do it all at once)
for (X in x){
print((X - 4.4)/2.875)
}
#4. Find the difference between the largest and smallest values of x.
diff <- max(x) - min(x)
diff

/*OUTPUT */

/* PLEASE UPVOTE */


Related Solutions

C Programming Language. A chessboard consists of 8 squares x 8 squares for a total of...
C Programming Language. A chessboard consists of 8 squares x 8 squares for a total of 64 squares. The squares of the chessboard are identified, from the perspective of the player with the white pieces, by the letters a – h for the 8 columns or files (starting from that player’s left), and 1 – 8 for the 8 rows or ranks (starting closest to that player). One of the chess pieces, the knight, can move in any direction by...
R-Studio (R Programming Language) 1. How would you create a vector `V` containing the values 0,...
R-Studio (R Programming Language) 1. How would you create a vector `V` containing the values 0, 0.25, 0.5, 0.75, and 1?    ```{r} #insert your code ``` 2. Name the elements of `V`: first, second, middle, fourth, last. Describe two ways of naming elements in `V` ```{r} #insert your code ``` 3. Suppose you keep track of your mileage each time you fill up. At your last 6 fill-ups the mileage was 65311 65624 65908 66219 66499 66821 67145 67447....
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio...
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio development environment 3. To practice on writing a C# program Task 1: Create documentation for the following program which includes the following: a. Software Requirement Specification (SRS) b. Use Case Task 2: Write a syntactically and semantically correct C# program that models telephones. Your program has to be a C# Console Application. You will not implement classes in this program other than the class...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub class is derived from the Account class and implements the ITransaction interface. There are two class variables i.e. variables that are shared but all the objects of this class. A short description of the class members is given below: CheckingAccount Class Fields $- COST_PER_TRANSACTION = 0.05 : double $- INTEREST_RATE = 0.005 : double - hasOverdraft: bool Methods + «Constructor» CheckingAccount(balance =...
in the c programming language input is given in the form The input will be of...
in the c programming language input is given in the form The input will be of the form [number of terms] [coefficient k] [exponent k] … [coefficient 1] [exponent 1] eg. 5 ─3 7 824 5 ─7 3 1 2 9 0 in this there are 5 terms with -3x^7 being the highest /* Initialize all coefficients and exponents of the polynomial to zero. */ void init_polynom( int coeff[ ], int exp[ ] ) { /* ADD YOUR CODE HERE...
C PROGRAMMING 1. Write a C Language inline function that computes the cube of float X,...
C PROGRAMMING 1. Write a C Language inline function that computes the cube of float X, if X is greater than 1 and X is less than 100. Put the inline function in a main program that reads X from the keyboard, calls the function, and then outputs the result. 2. Show an empty statement and detail what it does? 3. A collection of predefined functions is called a Database                    C) Subroutine                       E) None of these Library                       D) Directive 4....
Let A = R x R, and let a relation S be defined as: “(x​1,​ y​1)​...
Let A = R x R, and let a relation S be defined as: “(x​1,​ y​1)​ S (x​2,​ y​2)​ ⬄ points (x​1,​ y​1)​ and (x​2,​ y​2)​are 5 units apart.” Determine whether S is reflexive, symmetric, or transitive. If the answer is “yes,” give a justification (full proof is not needed); if the answer is “no” you ​must​ give a counterexample.
Let X = {1, 2, 3, 4, 5, 6} and let ∼ be given by {(1,...
Let X = {1, 2, 3, 4, 5, 6} and let ∼ be given by {(1, 1),(2, 2),(3, 3),(4, 4),(5, 5),(6, 6),(1, 3),(1, 5),(2, 4),(3, 1),(3, 5), (4, 2),(5, 1),(5, 3)}. Is ∼ an equivalence relation? If yes, write down X/ ∼ .
1. Let R be the relation on A = {1, 2, 3, 4, 5} given by...
1. Let R be the relation on A = {1, 2, 3, 4, 5} given by R = {(1, 1),(1, 3),(2, 2),(2, 4),(2, 5),(3, 1),(3, 3),(4, 2),(4, 4),(4, 5),(5, 2),(5, 4),(5, 5)}. (a) Draw the digraph which represents R. (b) Give the 0 -1 matrix of R with respect to the natural ordering. (c) Which of the five properties (reflexive, irreflexive, symmetric, antisymmetric, transitive) does R have? Give a brief reason why or why not each property holds. 2. Let...
Let L = {x = a r b s c t | r + s =...
Let L = {x = a r b s c t | r + s = t, r, s, t ≥ 0}. Give the simplest proof you can that L is not regular using the pumping lemma.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT