loops

In R how do I find whether an integer is divisible by a number?

心已入冬 提交于 2020-03-15 06:35:31
问题 Sorry for the inexperience, I'm a beginning coder in R For example: If I were to make a FOR loop by chance and I have a collection of integers 1 to 100 (1:100), what would be the proper format to ensure that would print the numbers that are divisible by another number. In this case, 5 being the number divisible. I hear that using modulo would help in this instance %% This is what I think I should have. For (x in 1:100) { x%%5 == y } print(y) 回答1: for (x in 1:100) { if (x%%5 == 0) { print(x) }

PHPExcel: Dynamic Row and Column incrementing is not working for Array in phpexcel?

这一生的挚爱 提交于 2020-03-06 09:30:22
问题 While printing column and row from an array it's showing blank not exporting any data $inn_table = ""; if ($result['qualification']['dd1'] != "") { $dd1 = explode(",", $result['qualification']['dd1']); } if ($result['qualification']['dd2'] != "") { $dd2 = explode(",", $result['qualification']['dd2']); } for ($i = 0; $i < count($labels); $i++) { if ($result['qualification']['dd1'] != "") { echo '<pre>First'; print_r($dd1); ** //echo arrays** for ($j = 0; $j < count($dd1); $j++) { $temp =

find value in array according to the row and column number

风流意气都作罢 提交于 2020-03-06 04:54:28
问题 I have two matrix A and B,the first row of matrix A(1,:)=[1 2] refer to the number of row and column matrix B(1,2)=21,now I want to do this work for another rows of matrix A without loops? A=[1 2;2 3;1 3;3 3]; B=[1 21 34;45 65 87;4 55 66]; for i=1:4 d(i,:)=B(A(i,1),A(i,2)) end d =[21; 87;34;66] 回答1: An alternative to sub2ind is d = B(A(:,1)+ (A(:,2)-1)*size(B,1)); 回答2: Use sub2ind to get linear indices of the required values of B and then use these indices to retrieve those values. d = B

Loop function to add large numbers of predictors in regression function

会有一股神秘感。 提交于 2020-03-05 07:27:05
问题 I want to improve the way to insert predictors in a regression function: fm <- lm(formula= df$dependent_variable ~ df[,2] + df[,3]+ df[,4], data = df) df = data.frame In this example I put only 4 predictors and 1 dependent_variable. Actually I have 191 predictors. I think I need to a loop script to put all these predictors. Suggestions? 回答1: Here is one possible solution: yname<-"DVnamehere" xnames<-colnames(dat) xnames<-xnames[-which(xnames==yname)] formula<-as.formula(paste(yname,"~",paste

JavaScript iterate through NodeList [duplicate]

别说谁变了你拦得住时间么 提交于 2020-03-05 04:18:27
问题 This question already has answers here : Why doesn't nodelist have forEach? (10 answers) Looping through a nodelist JS (1 answer) Closed 8 months ago . I am looking for a best way to iterate through NodeList excluding length. I am using: var foo = document.querySelectorAll('[id^=foo_id]') console.log(foo) Returned NodeList has all the required elements + the last entry of length:. 0: input#foo_id_... 1: input#foo_id_... .................. n: input#foo_id_... length: n+1 I wonder what the most

VBA Loop Through a File Path and Run a Code

谁说我不能喝 提交于 2020-03-05 00:24:50
问题 I have the code below that I would like to run to all of the available excel files in a folder. Ideally, I would like to input the path of the folder into cell C3 in Sheet1 and the macro to apply the code to all of the existing files. The code will simply save the second sheet of each file into a PDF version, it works perfectly standalone. Sample Folder Path: C:\Users\MMMM\Desktop\Project X\ Project II Suggestions on how to approach this? Private Sub CommandButton1_Click() Dim MyFolder As

How to mapping a folder name using PowerShell?

佐手、 提交于 2020-03-05 00:24:14
问题 I want to mapping an a folder to download and extract the folder. This is the way I need to download the folder. DownloadF.exe --net 10.0.0.1 --user XX --id 00 --ver A00X-F1A >> result.txt I have 26 version to mapping, which are A00X-F1A ... A00X-F1Z (the last character is A - Z) If the result.txt contain of this string "folder available". It means the version is correct, then stop the looping or checking other version. I must check the version start from A00X-F1Z, A00X-F1Y, A00X-F1X, ...

How to mapping a folder name using PowerShell?

那年仲夏 提交于 2020-03-05 00:23:13
问题 I want to mapping an a folder to download and extract the folder. This is the way I need to download the folder. DownloadF.exe --net 10.0.0.1 --user XX --id 00 --ver A00X-F1A >> result.txt I have 26 version to mapping, which are A00X-F1A ... A00X-F1Z (the last character is A - Z) If the result.txt contain of this string "folder available". It means the version is correct, then stop the looping or checking other version. I must check the version start from A00X-F1Z, A00X-F1Y, A00X-F1X, ...

Move functions for Mesh grid

让人想犯罪 __ 提交于 2020-03-04 18:21:24
问题 Our assignment is to create a mesh grid, with a cursor(+) that moves(up, down, right, left) apon command. I have the grid and the fuctions done, but i'm having trouble getting my move function's to work, along with the updated grid to show. Example of what I need the code to look like. This is my code: x = y = 0 size = int(input('Enter grid size: ')) print(f'Current location: ({x},{y})') def show_grid(x, y): for i in range(size): for j in range(size): if i == y and j == x: print('+', end=' ')

Move functions for Mesh grid

混江龙づ霸主 提交于 2020-03-04 18:19:38
问题 Our assignment is to create a mesh grid, with a cursor(+) that moves(up, down, right, left) apon command. I have the grid and the fuctions done, but i'm having trouble getting my move function's to work, along with the updated grid to show. Example of what I need the code to look like. This is my code: x = y = 0 size = int(input('Enter grid size: ')) print(f'Current location: ({x},{y})') def show_grid(x, y): for i in range(size): for j in range(size): if i == y and j == x: print('+', end=' ')