Question

In: Computer Science

Please do this operation in "R studio" Please recall the vectors that we created for the...

Please do this operation in "R studio"

Please recall the vectors that we created for the topic "Data Frames".

name = c('Nikola','Albert', 'Marie','Isaac','Graham','Lise', 'Rosalind')
surname = c('Tesla','Einstein','Curie', 'Newton', 'Bell', 'Meitner', 'Franklin')
gender = c('Male','Male','Female','Male','Male','Female','Female')
years = c(87,76,75,84,77,89,81)
field_of_study = c('Engineering','Physics','Chemistry','Physics','Engineering','Physics','Chemistry')

Please check for the function "cut" and use it to create a data frame named "scientists" which has the values

name surname gender years field_of_study years_bin
1 Nikola Tesla Male 87 Engineering (80,90]
2 Albert Einstein Male 76 Physics (70,80]
3 Marie Curie Female 75 Chemistry (70,80]
4 Isaac Newton Male 84 Physics (80,90]
5 Graham Bell Male 77 Engineering (70,80]
6 Lise Meitner Female 89 Physics (80,90]
7 Rosalind Franklin Female 81 Chemistry (80,90]

where "years_bin" attribute is the bin of "years", either "70 to 80" or "80 to 90".

Then please check the function "tapply" to get the averages of the bins like

(70,80] (80,90]
76.00 85.25

Note : Use of functions and methods (such as loops, conditionals) that are not covered yet is forbidden

Solutions

Expert Solution

R CODE:
name = c('Nikola','Albert', 'Marie','Isaac','Graham','Lise', 'Rosalind')
surname = c('Tesla','Einstein','Curie', 'Newton', 'Bell', 'Meitner', 'Franklin')
gender = c('Male','Male','Female','Male','Male','Female','Female')
years = c(87,76,75,84,77,89,81)
field_of_study = c('Engineering','Physics','Chemistry','Physics','Engineering','Physics','Chemistry')
scientists<- data.frame(name,surname,gender,years,field_of_study)
scientists

yearsbin <- cut(scientists$years, breaks = 2, labels = c("70-80", "80-90"))


scientists$years_bin <- yearsbin
scientists

tapply(scientists$years,scientists$years_bin, FUN = mean)

Here the code image

OUTPUT IMAGE:


Related Solutions

Let (R 3 , ×) be the set of 3d vectors equipped with the operation of...
Let (R 3 , ×) be the set of 3d vectors equipped with the operation of vector crossproduct. Which of the following properties does this operation satisfy (give proofs in all cases)? (a) has identity element(s)? (If so, determine all identity elements.) (b) has idempotent element(s)? (If so, determine all idempotent elements.) (c) commutative? (d) associative?
I want this to be solved using R studio or R software, please. Here is the...
I want this to be solved using R studio or R software, please. Here is the example: The data in stat4_prob5 present the performance of a chemical process as a function of sever controllable process variables. (a) Fit a multiple regression modelrelating CO2product (y) to total solvent (x1) and hydrogen consumption (x2) and report the fitted regression line. (b) Find a point estimatefor the variance term σ2. (c) Construct the ANOVA tableand test for the significance of the regression using...
Please use R and R studio A sample of 15 female collegiate golfers was selected and...
Please use R and R studio A sample of 15 female collegiate golfers was selected and the clubhead velocity (km/hr) while swinging a driver was determined for each one, resulting in the following data (“Hip Rotational Velocities During the Full Golf Swing,” J.of Sports Science and Medicine, 2009: 296–299): 69.0 69.7 72.7 80.3 81.0 85.0 86.0 86.3 86.7 87.7 89.3 90.7 91.0 92.5 93.0 The corresponding z percentiles are -1.83 -1.28 -0.97 -0.73 -0.52 -0.34 -0.17 0.0 0.17 0.34 0.52...
Using R Studio/R programming... Usually, we will use a random sample to estimate the statistics of...
Using R Studio/R programming... Usually, we will use a random sample to estimate the statistics of the underlying population. If we assume a given population is a standard normal distribution and we want to estimate its mean, which is the better technique to estimate that mean from a sample: Use the mean of one random sample of size 500 Use the mean of 300 random samples of size 10 Run your own experiment and use your results as a supporting...
Please use R and R studio The accompanying observations are precipitation values during March over a...
Please use R and R studio The accompanying observations are precipitation values during March over a 30-year period in Minneapolis-St. Paul. .77 1.20 3.00 1.62 2.81 2.48 1.74 .47 3.09 1.31 1.87 .96 .81 1.43 1.51 .32 1.18 1.89 1.20 3.37 2.10 .59 1.35 .90 1.95 2.20 .52 .81 4.75 2.05 a. Construct and interpret a normal probability plot for this data set. b. Calculate the square root of each value and then construct a normal probability plot based on...
Can You please Answer the question using R studio and R cloud Telomeres are complexes of...
Can You please Answer the question using R studio and R cloud Telomeres are complexes of DNA and protein that cap chromosomal ends. They consist of the same short DNA sequence TTAGGG repeated over and over again. They tend to shorted with cell divisions and with advancing cellular age, which will lead to chromosome instability or apoptosis (programmed cell death). Eukaryotic cells have the ability to reverse telomere shortening by expressing telomerase, an enzyme that extends the telomeres of chromosomes....
How do you plot continuous versus category in r studio
How do you plot continuous versus category in r studio
Show how Rotation Matrix R transforms vectors to vectors
Show how Rotation Matrix R transforms vectors to vectors
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 !
The Cauchy-Schwarz Inequality Let u and v be vectors in R 2 . We wish to...
The Cauchy-Schwarz Inequality Let u and v be vectors in R 2 . We wish to prove that ->    (u · v)^ 2 ≤ |u|^ 2 |v|^2 . This inequality is called the Cauchy-Schwarz inequality and is one of the most important inequalities in linear algebra. One way to do this to use the angle relation of the dot product (do it!). Another way is a bit longer, but can be considered an application of optimization. First, assume that the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT