loops

Increase for loop efficiency using vectorization in R

﹥>﹥吖頭↗ 提交于 2020-01-25 22:56:13
问题 I am still a relatively new user to R but am attempting to vectorize my for loops in order to increase computational speed. Currently, I need to perform two subsets on the data.frame/ data.table df (only named for this post): 1) subset by group id and 2) subset by each time interval interval for that particular id . I setup a nested for loop because I need to perform a homogeneity of variance test between each subset of data and a control using the levene.test in the lawstat package. The test

Looping using position absolute to form 9 boxes

大兔子大兔子 提交于 2020-01-25 20:37:10
问题 1 2 3 4 5 6 7 8 9 I want to achieve above boxes position using absolute positioning and looping in js. But I'm stuck at starting a second line. http://jsfiddle.net/k554x7vs/ var left = 0; for (var i = 1; i <= 10; i++) { $('<div class="box" id=box' + i + '></div>').appendTo('#holder'); if (i == 3) { //2nd line and so on.. left = 0; $('#box' + i).css({ 'top': 70 }) } $('#box' + i).css({ 'left': left }); left += 60; } There's a reason why I don't use float left. 回答1: You need to increment top

How do I run an encryption program multiple times to strengthen the encode?

蹲街弑〆低调 提交于 2020-01-25 13:17:08
问题 Here is my code so far. I need to run the encode part of the code 5 times and then decode the encode the same number of times. I figured out how to encode the message but now I can't figure out how to run the "encode" or "decode" variable back through the code to strengthen the ecryption. public class Codes { /** * Encode and decode a message using a key of values stored in * a queue. */ public static void main(String[] args) { int[] key = {7, 6, 5, 2, 8, 5, 8, 6, 4, 1}; Integer keyValue;

Count unique values per unique keys in python dictionary

早过忘川 提交于 2020-01-25 11:38:05
问题 I have dictionary like this: yahoo.com|98.136.48.100 yahoo.com|98.136.48.105 yahoo.com|98.136.48.110 yahoo.com|98.136.48.114 yahoo.com|98.136.48.66 yahoo.com|98.136.48.71 yahoo.com|98.136.48.73 yahoo.com|98.136.48.75 yahoo.net|98.136.48.100 g03.msg.vcs0|98.136.48.105 in which I have repetitive keys and values. And what I want is a final dictionary with unique keys (ips) and count of unique values (domains). I have laready below code: for dirpath, dirs, files in os.walk(path): for filename in

Loop through items and sum items in SPSS

断了今生、忘了曾经 提交于 2020-01-25 11:23:12
问题 I have two sets of variables called ITEM 1 to ITEM 47, and another called L1 to L47. What I want to do is to calculate the sum of Ls if any ITEM#i=1. What I wrote is as following: COMPUTE LSUM=0. LOOP #i=1 to 47. IF (ITEM(#i)=1) LSUM=LSUM+L(#i). END LOOP. But I got an error message saying the characters do not match any existing function or vector. What should I do then? Your inputs will be very appreciated. Thanks. Sincerely, Lucy 回答1: COMPUTE LSUM=0. exe. vector vitems = ITEM 1 to ITEM 47.

WP_Query headache

久未见 提交于 2020-01-25 11:17:49
问题 I am trying to use WP_Query to output the 3 latest posts with the tag featured. I asked about it here on stackoverflow and got at good tip from a kind person. This is what I have now: <?php $home_featured = new WP_Query(array( 'tag' => 'featured', 'posts_per_page' => 3, )); ?> <?php if ($home_featured->have_posts()): while ($home_featured->have_posts()) : $home_featured->the_post(); ?> <p>Got some</p> <?php endwhile; ?> <?php else: ?> <p>None found</p> <?php endif; ?> Now, I have 3 posts that

Excluding Dates from Print Loop

拟墨画扇 提交于 2020-01-25 10:29:05
问题 How would I go about excluding any day from my print outs that was a friday and the 13th day of the month. I'm attempting to write something along the lines of: if (dayofweek != 5 && dayofmonth != 13), then print. How could I implement that into the following code? public class LoopDate { public static void main(String[] args) { //Denotes that Tuesday is the first day of 2013 int startingDayOfWeek = 2; int year = 2013; int numDays = 0; for (int month = 1; month <= 12; month++) { switch (month

Webscrape Multiple Pages with python - output issue

孤者浪人 提交于 2020-01-25 09:03:20
问题 Happy new year python community, I am trying to extract a table from website using Python Beautifulsoup4 I am struggling to see the results in my output files. The code run smoothly but nothing is written the file. My code below from bs4 import BeautifulSoup as bsoup import requests as rq import re base_url = 'http://www.creationdentreprise.sn/rechercher-une-societe?field_rc_societe_value=&field_ninea_societe_value=&denomination=&field_localite_nid=All&field_siege_societe_value=&field_forme

Webscrape Multiple Pages with python - output issue

喜夏-厌秋 提交于 2020-01-25 09:03:08
问题 Happy new year python community, I am trying to extract a table from website using Python Beautifulsoup4 I am struggling to see the results in my output files. The code run smoothly but nothing is written the file. My code below from bs4 import BeautifulSoup as bsoup import requests as rq import re base_url = 'http://www.creationdentreprise.sn/rechercher-une-societe?field_rc_societe_value=&field_ninea_societe_value=&denomination=&field_localite_nid=All&field_siege_societe_value=&field_forme

How to store all Azure AD user group members in an array using a logic app

孤者浪人 提交于 2020-01-25 08:16:14
问题 I am working on a logic app that will create users in third party applications based on AAD group membership. To avoid issues when the group has more than 999 users I have implemented paging. I first get the first 50 users, and a NextLink that I call to get the next 50. This loop runs fine. Snippet of logic app When no more nextlink is found, the loop exits. During the loop iterations, I need to store the user information (first name, lastname, UPN etc) in an array so i can process everyone