R Programming I need to this Loop through columns (i) Identify values in minimal_2dr[[i]] that are less than -0.1 [using logical indexing] Select only those values (e.g. 2 values) Select corresponding values of minimal_indices[[i]] (corresponding 2 values) How would i do this?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

R Programming

I need to this

Loop through columns (i)
Identify values in minimal_2dr[[i]] that are less than -0.1 [using logical indexing]
Select only those values (e.g. 2 values)
Select corresponding values of minimal_indices[[i]] (corresponding 2 values)

How would i do this?

File Edit Code View Plots Session Build Debug Profile Tools Help
Go to file/function
lool Addins
Sec_Deri_experiments.R* *
103 # }
104
110
111
105 # Store the minimum values in a list of arrays (list size = nr)
106 # store the minimum indices in a list of arrays (list size = nr)
107 minima_values <- list()
108 minima indices <- list ()
109 #minima_1der <- list() #@@@ may need this later
minima_2der <- list()
115
116
a minimal 2 x
112 # Loop through the columns of the array
113 for (i in 1:nc) {
114
117
118
Source on Save
119
120
# Find second derivative of the data
Run
second_derivative <- smoothData [1: (nc-2),i] - 2*smoothData [2: (nc-1),i] + smoothData [3:nc,i]
sec_der <- as. vector (second_derivative)
locMin = localMinima(sec_der)
minima_indices [[i]]<- 1oCMin+1
minima_values [[i]] <- smoothData [locMin+1]
minima_2der [[i]] <- sec_der [locMin]
121. }
122
# Next step: use the results to obtain an initial guess
123
124 #Loop through columns (i)
125 #Identify values in minimal_2der [[i]] that are less than -0.1
126
# Select only those values (e. g. 2 values)
127
# Select corresponding values of minimal_indices [[i]] (corresponding 2 values)
Soure
Transcribed Image Text:File Edit Code View Plots Session Build Debug Profile Tools Help Go to file/function lool Addins Sec_Deri_experiments.R* * 103 # } 104 110 111 105 # Store the minimum values in a list of arrays (list size = nr) 106 # store the minimum indices in a list of arrays (list size = nr) 107 minima_values <- list() 108 minima indices <- list () 109 #minima_1der <- list() #@@@ may need this later minima_2der <- list() 115 116 a minimal 2 x 112 # Loop through the columns of the array 113 for (i in 1:nc) { 114 117 118 Source on Save 119 120 # Find second derivative of the data Run second_derivative <- smoothData [1: (nc-2),i] - 2*smoothData [2: (nc-1),i] + smoothData [3:nc,i] sec_der <- as. vector (second_derivative) locMin = localMinima(sec_der) minima_indices [[i]]<- 1oCMin+1 minima_values [[i]] <- smoothData [locMin+1] minima_2der [[i]] <- sec_der [locMin] 121. } 122 # Next step: use the results to obtain an initial guess 123 124 #Loop through columns (i) 125 #Identify values in minimal_2der [[i]] that are less than -0.1 126 # Select only those values (e. g. 2 values) 127 # Select corresponding values of minimal_indices [[i]] (corresponding 2 values) Soure
Expert Solution
Step 1

Algorithm that describes the steps in the code:

1. Initialize minimal_2dr and minimal_indices data structures with appropriate data
2. Loop through each column of minimal_2dr using a for loop:
   a. Identify the values in the current column that are less than -0.1 using logical indexing
   b. Select only those values using the identified indices from step a
   c. Select corresponding values of minimal_indices for the selected values from step b
   d. Print the selected values and corresponding indices for the current column using cat() function.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY