Question

In: Statistics and Probability

How do I input this in R studio 1. Combine the following lists into a matrix...

How do I input this in R studio

1. Combine the following lists into a matrix called animals, where each list becomes a row:

Cats = 2,2,4

Dogs = 1,2,1

Cows = 30,35,41

2. Add column names of “Farm A”, Farm B”, and “Farm C”.

3. Transpose the rows and columns in animals and store the result to a matrix called farms.

4. Display the contents of farms.

Solutions

Expert Solution

The R output


COMMANDS are given below

#we have 3 lists
cats=list(2,2,4)
dogs=list(1,2,1)
cows=list(30,35,41)

#1. Combine lists into a matrix called animals, where each list becomes a row
animals=rbind(cats, dogs, cows); animals

#2 Add column names
colnames(animals)<- c("Farm A", "Farm B", "Farm C"); animals

#3. Taking transpose and storing it into farms
farms=t(animals)

#4. displaying the contents of farms
farms


Related Solutions

How do I do this in R Studio? 1 Students who performed poorly on a City...
How do I do this in R Studio? 1 Students who performed poorly on a City of New York Skills Assessment Test were enrolled in a summer math program. Scores of 10 students before and after the summer program were recorded. They were: Before = 18,18,21,18,18,20,23,23,21,17 After = 24,25,33,29,33,36,34,36,34,27 (Scores for individual students are in the same order in each list.) Did the NYC summer math program improve student performance significantly? 8. How many points did student scores improve on...
Show that R-1(a)R(a) = I, where I is the identity matrix and R(a) is the rotation matrix.
Show that R-1(a)R(a) = I, where I is the identity matrix and R(a) is the rotation matrix. This equation shows that the inverse coordinate transformation returns you to the original coordinate system.  
How is this done in R-studio? I have been trying to figure it out but I...
How is this done in R-studio? I have been trying to figure it out but I am getting more and more confused. While imprisoned by the Germans during World War II, the English mathematician John Kerrich tossed a coin 10,000 times and obtained 5067 heads. Let p be the probability of a head on a single toss. We wish to check if the data are consistent with the hypothesis that the coin was fair. a) Set up the hypotheses. Why...
How do you graph integers in r studio. I made new data frames for specific parts...
How do you graph integers in r studio. I made new data frames for specific parts of the data I wanted to use and then got the sum of a column and saved it as a variable under values. My goal is to know how to graph these integer values in a barplot comparing all the values.
How do you plot continuous versus category in r studio
How do you plot continuous versus category in r studio
In R studio Write a function that takes as an input a positive integer and uses...
In R studio Write a function that takes as an input a positive integer and uses the print() function to print out all the numbers less than the input integer. (Example: for input 5, the function should print the numbers 1,2,3,4 { for input 1, the function should not print a number.) Use the lapply function, do not use any of the loop commands in your code.
how do you test for regression in R studio with variables x and y
how do you test for regression in R studio with variables x and y
1. Basic use of R/R Studio. Solve the following problem in R and print out the...
1. Basic use of R/R Studio. Solve the following problem in R and print out the commands and outputs. (a) Create a vector of the positive odd integers less than 100; Remove the values greater than 60 and less than 80; Find the variance of the remaining set of values (b) What’s the difference in output between the commands 2*1:5 and (2*1):5? Why is there a difference? (c) If you wanted to enter the odd numbers from 1 to 19...
Hey anyone good with R studio? How do you create a square shape with R code...
Hey anyone good with R studio? How do you create a square shape with R code by using plot() and lines() please show your code !
how do you insert R input into a word document?
how do you insert R input into a word document?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT