Create an R script that: Reads in the data as an array from a .txt file (make the txt file name be a variable) • Extract the first row as the set of wavelengths (store as a vector) and remove first row from data. Loop through the rows of the array. Find minima of second derivative as described above Store the minimum values and their indices (n) in two different arrays.
Create an R script that: Reads in the data as an array from a .txt file (make the txt file name be a variable) • Extract the first row as the set of wavelengths (store as a vector) and remove first row from data. Loop through the rows of the array. Find minima of second derivative as described above Store the minimum values and their indices (n) in two different arrays.
Related questions
Question
PLEASE DO IN RSTUDIO (R PROGRAMMING) Please show each step in the code.
Data Set
890.776 | 890.519 | 890.263 | 890.006 | 889.749 | 889.493 | 889.236 | 888.979 | 888.722 | 888.466 | 888.209 | 887.952 | 887.696 | 887.439 | 887.182 | 886.925 | 886.669 | 886.412 | 886.155 | 885.898 | 885.641 | 885.385 | ||
-4.25909 | -6.9024 | 9845 | 9608 | 9782 | 9708 | 9661 | 9609 | 9832 | 9753 | 9564 | 9579 | 9727 | 9744 | 9638 | 9430 | 9607 | 9760 | 9840 | 9695 | 9749 | 9866 | 9786 | 9826 |
-4.25909 | -6.4544 | 9507 | 9340 | 9337 | 9325 | 9441 | 9300 | 9470 | 9143 | 9421 | 9345 | 9372 | 9407 | 9251 | 9085 | 9292 | 9402 | 9560 | 9443 | 9349 | 9306 | 9339 | 9430 |
-4.25909 | -6.0064 | 9576 | 9201 | 9252 | 9238 | 9217 | 9298 | 9217 | 9224 | 9255 | 9055 | 9199 | 9364 | 9218 | 9204 | 9503 | 9374 | 9482 | 9337 | 9290 | 9318 | 9395 | 9361 |
-4.25909 | -5.5584 | 9604 | 9301 | 9467 | 9279 | 9457 | 9438 | 9395 | 9310 | 9310 | 9237 | 9281 | 9333 | 9447 | 9187 | 9644 | 9589 | 9541 | 9267 | 9402 | 9518 | 9354 | 9633 |

Transcribed Image Text:ƒ(x−8)−2ƒ(x)+ƒ(x+6)
Second derivative of f(x)
Computationally, the function is represented as an array f(n), n = 1,2,3,...
To numerically locate the minima of the second derivative, look at f(n-1) − 2ƒ(n) + f(n + 1) and
find the values of n where it's most negative.
Do this as an array function (avoid loops)
Second derivative is minimized (most negative) when x = μ.
Create a vector that represents f(n-1) − 2f(n) + f(n + 1) and loop through values to find local
minima. Those local minima will be the means for our Gaussians. We can also use the value of the
second derivative to estimate the standard deviations.

Transcribed Image Text:Create an R script that:
•
Reads in the data as an array from a .txt file (make the txt file name be a variable)
Extract the first row as the set of wavelengths (store as a vector) and remove first row
from data.
Loop through the rows of the array. Find minima of second derivative as described
above
Store the minimum values and their indices (n) in two different arrays.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 2 images
