loops

How to create and loop over an ArrayList of strings in Jenkins Groovy Pipeline

人盡茶涼 提交于 2021-01-29 10:19:08
问题 As stated in the title, I'm attempting to loop over an ArrayList of strings in a Jenkins Groovy Pipeline script (using scripted Pipeline syntax). Let me lay out the entire "problem" for you. I start with a string of filesystem locations separated by spaces: "/var/x /var/y /var/z ... " like so. I loop over this string adding each character to a temp string . And then when I reach a space, I add that temp string to the array and restart. Here's some code showing how I do this: def full_string =

R loop over multiple matrices

穿精又带淫゛_ 提交于 2021-01-29 10:16:41
问题 I have 472 matrices with 405 columns each (matrix1 , ... , matrix400) and want to have 472 new matrices with only the first 244 columns of that matrix. How can I do that? I tried: for (i in 1:472) { assign(paste("new_matrix",i,sep=""), matrix[[i]][,c(1:244)]) } I created the matrices by splitting one dataframe by one identifier (for the groups): for (i in 1:472){ assign(paste("matrix", i, sep=""), subset(data, ID==i)) } Somehow I cannot speak to each matrix but I have no clue how I can do

Is there an easy way to simplify this code using a loop?

最后都变了- 提交于 2021-01-29 09:50:44
问题 Is there a way to simplify this code using a loop? set.seed(100) AL_INDEX <- sample(1:nrow(AL_DF), 0.7*nrow(AL_DF)) AL_TRAIN <- AL_DF[AL_INDEX,] AL_TEST <- AL_DF[-AL_INDEX,] AR_INDEX <- sample(1:nrow(AR_DF), 0.7*nrow(AR_DF)) AR_TRAIN <- AR_DF[AR_INDEX,] AR_TEST <- AR_DF[-AR_INDEX,] AZ_INDEX <- sample(1:nrow(AZ_DF), 0.7*nrow(AZ_DF)) AZ_TRAIN <- AZ_DF[AZ_INDEX,] AZ_TEST <- AZ_DF[-AZ_INDEX,] AL_DF, AR_DF & AZ_DF are data frames that have the same field structure, but different number of records.

Processing a list in chunks and combining the result

限于喜欢 提交于 2021-01-29 09:26:14
问题 I have two lists of gene-lists for example gene_list_A $`STEARATE BIOSYNTHESIS I (ANIMALS)%HUMANCYC%PWY-5972` [1] "ELOVL1" "ACOT7" "ACSL1" "ACSL5" "ACSL4" "ELOVL6" "ACSL3" "ACOT2" "ACOT1" "ACSBG1" [11] "ACSBG2" "SLC27A2" "ACOT4" $`SUPERPATHWAY OF INOSITOL PHOSPHATE COMPOUNDS%HUMANCYC%PWY-6371` [1] "PI4K2B" "MTMR14" "PTEN" "INPPL1" "PIK3CD" "PIK3C2G" "PIK3CB" "PIK3C2A" "PIK3CG" "PIK3C2B" [11] "PLCZ1" "PPIP5K1" "PPIP5K2" "PIP5KL1" "PLCE1" "PIP4K2A" "PIP4K2B" "PIP4K2C" "SACM1L" "ITPK1" [21]

Check Neighbours in a String with Java

眉间皱痕 提交于 2021-01-29 09:18:37
问题 in a string like "phone" i want to know the neighbour of the character 'o' in this case 'h' and 'n' i tryed with a String Iterator but that gives me either before or after and with charAt() i will be out of range by -1 or endless loop String s = textArea.getText(); for( int i = 0; i < s.length(); i++) { char ch = s.charAt(i); char tz = s.charAt(i--); System.out.print(ch); if(ch == 'n') { System.out.print(tz); break; } } 回答1: you could try something like this. Of course, you can still do

How to run same code on multiple files, or all files in directory

旧街凉风 提交于 2021-01-29 09:14:50
问题 so I am very new to coding and recently wrote a little program that involved R and sox. It looked like this file <- "test.mp3" testSox = paste("sox ",file," -n spectrogram -o ",file,".png stats",sep='') sox = system(testSox, intern = TRUE) print(sox) Now, instead of assigning the one file manually within the code, I would just like to have this code read through all the mp3s in a folder automatically. Is this possible? Any help would be greatly appreciated. Thanks! EDIT: Actually, I should

Passing a variable in batch file to another batch file with FOR loop to process list of folders

不打扰是莪最后的温柔 提交于 2021-01-29 09:10:48
问题 I Have a list of folders on DVD that I would like to process one at a time. I am trying to use a FOR command to pass through information to set as the variable in a 2nd batch file. I am having the user input two variables, then I'd like a 3rd variable to come from my list of folders. Then run a 2nd batch file for each folder on the DVD: echo enter Drive letter set /p Drive= echo enter diskname set /p diskname= FOR /F %%i IN ('dir /ad /b e:\') DO set book=%%i call Load.bat %drive% %diskname%

Check Neighbours in a String with Java

自闭症网瘾萝莉.ら 提交于 2021-01-29 09:06:28
问题 in a string like "phone" i want to know the neighbour of the character 'o' in this case 'h' and 'n' i tryed with a String Iterator but that gives me either before or after and with charAt() i will be out of range by -1 or endless loop String s = textArea.getText(); for( int i = 0; i < s.length(); i++) { char ch = s.charAt(i); char tz = s.charAt(i--); System.out.print(ch); if(ch == 'n') { System.out.print(tz); break; } } 回答1: you could try something like this. Of course, you can still do

How to conduct an ANOVA of several variables taken on individuals separated by multiple grouping variables?

ぐ巨炮叔叔 提交于 2021-01-29 08:40:27
问题 I have a data frame similar to the one created by the code below. In this example, measurements of 5 variables are taken on are 30 individuals represented by ID . The individuals can be separated by any of three grouping variables: GroupVar1,GroupVar2,GroupVar3 . For each of the grouping variables, I need to conduct an ANOVA for each of the 5 variables, and return the results of each (possibly onto a pdf or separate document?). How can I write a function, or use iteration, to handle this

unique id for dynamic table

£可爱£侵袭症+ 提交于 2021-01-29 08:26:36
问题 I will be generating a HTML table with data pulled from MySQL.The number of rows in my MySQL table are not fixed. <?php while($row=mysql_fetch_assoc($result)) { ?> <tr> <td><?php echo $row['col1'];?></td> <td><?php echo $row['col2'];?></td> </tr> <?php } ?> Now how do I have the table rows and table data elements assigned unique id ?? Another loop to generate them won't work as I can't set an exit condition for the new loop as number of rows are not fixed. Please guide me as to how to go