Tuesday, 15 September 2015

How to show please wait while ajax request process in complete -



How to show please wait while ajax request process in complete -

this code working fine, want create ajax please wait while still requesting information: here code.

function products(){ if (document.getelementbyid('date').value.length == 0) { alert("please pick date"); document.getelementbyid('date').focus(); homecoming false; } var ajaxrequest; // variable makes ajax possible! try{ // opera 8.0+, firefox, safari ajaxrequest = new xmlhttprequest(); } grab (e){ // net explorer browsers try{ ajaxrequest = new activexobject("msxml2.xmlhttp"); } grab (e) { try{ ajaxrequest = new activexobject("microsoft.xmlhttp"); } grab (e){ // went wrong alert("your browser broke!"); homecoming false; } } } // create function receive info sent server ajaxrequest.onreadystatechange = function(){ if(ajaxrequest.readystate == 4){ var ajaxdisplay = document.getelementbyid('sum'); ajaxdisplay.innerhtml = ajaxrequest.responsetext; } } var usr = document.getelementbyid('usr').value; var date = document.getelementbyid('date').value; var querystring = "?usr=" + usr + "&date=" + date; ajaxrequest.open("get", "ajax_prom.php" + querystring, true); ajaxrequest.send(null); }

in page, add together div id - divajaxrequestinprogress. add together text want show while ajax request in progress div. have animated gif well. now, show when start ajax processing , hide 1 time request complete. function products(){ if (document.getelementbyid('date').value.length == 0) { alert("please pick date"); document.getelementbyid('date').focus(); homecoming false; } $("#divajaxrequestinprogress").show(); var ajaxrequest; // variable makes ajax possible! try{ // opera 8.0+, firefox, safari ajaxrequest = new xmlhttprequest(); } grab (e){ // net explorer browsers try{ ajaxrequest = new activexobject("msxml2.xmlhttp"); } grab (e) { try{ ajaxrequest = new activexobject("microsoft.xmlhttp"); } grab (e){ // went wrong alert("your browser broke!"); homecoming false; } } } // create function receive info sent server ajaxrequest.onreadystatechange = function(){ if(ajaxrequest.readystate == 4){ var ajaxdisplay = document.getelementbyid('sum'); ajaxdisplay.innerhtml = ajaxrequest.responsetext; } $("#divajaxrequestinprogress").hide(); } var usr = document.getelementbyid('usr').value; var date = document.getelementbyid('date').value; var querystring = "?usr=" + usr + "&date=" + date; ajaxrequest.open("get", "ajax_prom.php" + querystring, true); ajaxrequest.send(null); }

i have added 2 lines code - 1 show , 1 hide div.

ajax

android - Create SOS signal using Java.Util.Timer -



android - Create SOS signal using Java.Util.Timer -

i want create android app performs sos signal using flashlight on phone , know how command flash light.

this want flash lite do:

1) flash lite on 1 sec 2) flash lite off 1 sec 3) flash lite on 1 sec 4) flash lite off 1 sec 5) flash lite on 1 sec 6) flash lite off 1 sec 7) flash lite on 3 seconds 8) flash lite off 1 sec 9) flash lite on 3 seconds 10) flash lite off 1 sec 11) flash lite on 3 seconds 12) flash lite off 1 sec 13) flash lite on 1 sec 14) flash lite off 1 sec 15) flash lite on 1 sec 16) flash lite off 1 sec 17) flash lite on 1 sec 18) flash lite off 1 sec

how can accomplish using timer class in java?

the best approach create class definitions of alphabet , equivalent in morse code. numbers can added well. way can come in text, not sos.

if sos goal, creating class might overkill still practice.

have @ docs timer class

http://docs.oracle.com/javase/7/docs/api/java/util/timer.html << updated link

this method used timer class in illustration below. sos quite possible add together forloop run sequence many seconds, , command led light.

public void schedule(timertask task, long delay, long period)

//usage of timer

import java.util.*;

public class timerdemo {

public static void main(string[] args) { // declare , create task timertask tasknew = new timertask() { // runs our task @override public void run() { system.out.println("timer running..."); } }; // declare , create timer timer mytimer = new timer(); /* schedule timer (task scheduled, delay in ms before task * execution, period in ms between successive tasks executions */ mytimer.schedule(tasknew, 500, 1000); }

}

i hope gives improve example.

java android timer led

How to configure Apache Hadoop Vaidya -



How to configure Apache Hadoop Vaidya -

as i'm looking tuning hadoop map-reduce jobs improve performance optimal resource utilization, i'm unable start can 1 tell me how configure apache hadoop vaidya. next apache blog hadoop vaidya, has described how utilize it. in blog found path

$hadoop_home/contrib/vaidya/bin/

which not nowadays in machine i'm assuming have install/configure apache hadoop vaidya.

any help appreciated!!

apache hadoop

objective c - How to create UICollectionView with alternating cell amount layout? -



objective c - How to create UICollectionView with alternating cell amount layout? -

i developing ipad app uses uicollectionview display list of products company. cells layout want utilize alternating between rows 1 image , 2 images, first row 1 image, sec row 2 images, 3rd row 1 image... , on, can't figure out how in code.

so can help me one?

hey guys manage working code:

- (nsinteger)collectionview:(uicollectionview *)view numberofitemsinsection:(nsinteger)section { homecoming 2; } - (nsinteger)numberofsectionsincollectionview: (uicollectionview *)collectionview { homecoming 30; } - (uicollectionviewcell *)collectionview:(uicollectionview *)cv cellforitematindexpath:(nsindexpath *)indexpath { cells *cell; if (indexpath.row %2) { nslog(@"%li", indexpath.row); cell = [cv dequeuereusablecellwithreuseidentifier:@"one" forindexpath:indexpath]; cell.label.text = @"one"; cell.backgroundcolor = [uicolor bluecolor]; homecoming cell; } else { nslog(@"%li", indexpath.row); cell = [cv dequeuereusablecellwithreuseidentifier:@"two" forindexpath:indexpath]; cell.labela.text = @"two"; cell.labelb.text = @"two"; cell.backgroundcolor = [uicolor redcolor]; homecoming cell; } }

objective-c ios7 uicollectionview uicollectionviewcell

Execute java class in PHP -



Execute java class in PHP -

i want phone call java programme , fetch it's output in stdout. followed suggestions in stackoverflow. doesn't work.

i have add together class file classpath. , can execute command in cmd correctly follows:

in php file phone call programme

exec("java hello", $output); print_r($output);

it yields nil but:

array()

what problem? how can prepare this?

ps: hello demo program, programme want phone call much more complicated might take 2 or more seconds in machine(i5 4g).

i recommend using java/php bridge found here: http://php-java-bridge.sourceforge.net/pjb/ it's quite easy install , works well.

also, recommend using next link download it. (it's same 1 link in downloads->documentation)

http://sourceforge.net/projects/php-java-bridge/files/binary%20package/php-java-bridge_6.2.1/php-java-bridge_6.2.1_documentation.zip/download

the file javabridge.war. you'll want utilize tomcat java ee container. 1 time tomcat set up, set file in webapps folder , it's installed.

if want regularly utilize java classes in php best method know of , have tried lot of them. resin worked, didn't play nice mail service server.

java php

Inno Download Plugin - Compiler error -



Inno Download Plugin - Compiler error -

i have been using idp plugin quite time now, after installing latest v1.4.0 next compiler error.

compiling [code] section compiler error! file: c:\program files (x86)\inno download plugin\idp.iss line 54: column 55: unknown type 'int64'

i using inno setup 5.5.2 (u). can please assist? thanks.

the int64 info type introduced in unicode version 5.5.3 must download more recent version of unicode inno setup. what's new list mentions (emphasized me):

5.5.3 (2013-01-30)

unicode inno setup: has int64 type, supported inttostr. added new strtoint64, strtoint64def, , getspaceondisk64 back upwards functions.

plugins inno-setup inno-download-plugin

c# - Trying to change BorderThickness in DataGrid ColumnHeader -



c# - Trying to change BorderThickness in DataGrid ColumnHeader -

im using bundle called mahapps metro, i'm trying alter style of datagrid alter default borderthickness of columnheader.

the mahapps metro datagrid command can found here: https://github.com/mahapps/mahapps.metro/blob/master/mahapps.metro/styles/controls.datagrid.xaml

the part i'm trying access custom style is:

<border x:name="backgroundborder" borderthickness="0,0,0,3" grid.columnspan="2" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" />

currently have:

<style targettype="datagridcolumnheader" x:key="geledigdheader" basedon="{staticresource metrodatagridcolumnheader}"> <setter property="horizontalcontentalignment" value="right"/> <setter property="borderbrush" value="#953735"/> </style>

this changes color want alter thickness, using property="borderthickness" not work, obviously..

well if @ style there given no explicit access borderthickness via binding. since have style can add together line

<border x:name="backgroundborder" borderthickness="0,0,0,3" grid.columnspan="2" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}"/>

c# wpf xaml datagrid

java - anonymous class extending an abstract class -



java - anonymous class extending an abstract class -

i'm looking schedule task @ specified time starttime, , when time comes, want run method rrun(boolean param1, object someobj).

rrun() method in class, someclass.

and, within someclass again, have method m1() part of code:

timer starttimer = new timer(); starttimer.schedule(new timertask() { public void run() {rrun(false, this);} }, starttime);

to this, i'm getting error

incompatible types: <anonymous timertask> cannot converted someclass

what's wrong i'm doing?

tia.

//===============================

edit:

i'm using jdk 8 -- latest one

inside anonymous inner class, this reference current timertask anonymous subclass, not enclosing class.

to refer enclosing class, qualify this:

public void run() {rrun(false, someclass.this);}

java anonymous-types

java - load a jsp in a dialog and div -



java - load a jsp in a dialog and div -

i know might duplication question, couldn't find reply simple question. want load new jsp file in dialog , div.

structure: -webcontent -jsp -viewfolder -helloworld.jsp -helloworldedit.jsp -newworld.jsp

let's have helloworld.jsp loaded request dispatcher. want load newworld.jsp in div tag in helloworld.jsp.

<div id="result"></div> $('#result').load('/jsp/viewfolder/newworld.jsp');

tried above code, didn't work.

i have tried load jsp page dialog , 1 has failed too.

<button id="button">button</button> <div id="dialog"></div> $('#button').on("click", function() { $('#dialog').load('/jsp/viewfolder/helloworldedit.jsp').dialog(); });

the question have is, right way phone call jsp page or have load page request dispatcher using ajax.

to test if path correct, tried set calendar.gif in same folder , able reach context.

http://localhost:port/.projectcontext/jsp/viewfolder/calendar.gif.

you have wait dom ready event:

$(document).ready(function() { $('#button').on("click", function() { $('#dialog').load('/.projectcontext/jsp/viewfolder/helloworldedit.jsp').dialog(); }); });

java javascript jquery jsp

html - Resize an image to take up all of a -



html - Resize an image to take up all of a <div> -

how can constrain image in container whole container filled much image possible?

for illustration (i not know size images be, example) - if have image container of 100x100 , image of 600x400, next conditions need met.

the image should displayed @ 150x100 the image should centred in container the overflow of image (25px left , right in example) should hidden.

please note - images of greater height width, solution needs work images of sizes, centreing both horizontally , vertically.

sadly, solution has work ie9 (as browser owners of intranet working on use), html5/css3 solutions not work.

here couple of visual examples -

i've tried various css styles -

if nest <img> within of <div> container image if absolutly place <img> on <div> unable centre vertically if wider tall (i.e. 600x400).

any suggestions gratefully received.

since mentioned has work ie9: background-size: cover that. can't utilize image img element have assign background image container.

i made jsfiddle here

html css

asp.net - SQL timeouts at 3 minutes past full hour -



asp.net - SQL timeouts at 3 minutes past full hour -

i have problem has puzzled me while now. 1 time in while, 4-5 times week timeouts database @ hh:03 (or hh:02 think). i've been digging scheduled tasks on server investigate if there puts server it's knees in performance without findings.

i've gone fas i've made watchdog application when query has 1 seconds left of it's max query time checks processlist database , emails me. process list contains 1 entry , that's entry timeout exception.

to farther add together complexity have many customers application it's 1 of customers timeout. customers run same code have different databases, different application pools different application pool identities.

the application asp.net application. database microsoft sql 2008 r2 express edition.

has heard of this? can give me pointers investigate in order resolve issue?

kind regards

sql asp.net .net sql-server sql-server-2008

c++ - Why would clang++ fail to compile on a Mac, under Mavericks, except with sudo? -



c++ - Why would clang++ fail to compile on a Mac, under Mavericks, except with sudo? -

after recent software update on mac, i'm not able compile , link c++ hello world programme without sudo.

the programme (helloworld.cpp):

#include <iostream> int main(){ std::cout << "hello world\n"; homecoming 0; }

the invocation:

clang++ helloworld.cpp

fails error:

ld: can't write output file: a.out architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation)

but if under sudo,

sudo clang++ helloworld.cpp

there's no problem.

what might causing this, , how might able resolve this?

edit, again: reply turned out not working directory permissions, couple of people suggested, permissions associated output file, a.out, of hello world program. credit petesh solution.

you must sitting in directory not writable user. @ pwd , ls -ld . see , permissions there. seek creating empty file touch foo.txt in same directory ran clang.

c++ osx clang xcode6

networking - ip rule does not seem to be invoked -



networking - ip rule does not seem to be invoked -

i have 2 connections on local machine, 1 via eth0 (has static ip, allow 10.10.10.10), via ppp0 (has dinamic ip, illustration 10.20.30.40). both have access internet. have remote server (let's assume has ip 1.2.3.4) want connect local machine in such way packets having source address 10.10.10.10 (eth0) should go through eth0, while having 10.20.30.40 (ppp0) source address should go through ppp0.

preliminary deleted ip rule main route table in order prevent packets beingness treated rule.

after that, created 2 route tables, 1 eth0 (named eth) , ppp0 (named ppp). added routes these tables follows:

ip route add together default dev ppp0 table ppp ip route add together default dev eth0 table eth

then added ip rules followings:

ip rule add together 10.10.10.10 lookup eth ip rule add together 10.20.30.40 lookup ppp

and doesn't work. however, when utilize ip rule add together all instead of pointing specific ip works (sure, packets go through 1 interface in case). so, seems ip rule not invoked when specify ip.

what reason of such unusual behavior?

does have ideas?

i found reason. cause of problem programme (written usage of qt qtcpsocket::bind()) binds socket appropriate interface, not routing settings. not unknown reason. tried using native linux socket functions , runs clockwork.

networking iptables

How to use Verdana Font in Stamper (iText PDF) -



How to use Verdana Font in Stamper (iText PDF) -

i want utilize verdana font while stamping pdf file itext pdf. original file uses verdana, isn't alternative in class basefont.

here function create font right now:

def standardstampfont() { homecoming basefont.createfont(basefont.helvetica, basefont.winansi, false) }

i'd alter verdana font, exchanging part basefont.helvetica "verdana" doesn't work.

any idea? in advance!

as documented, itext supports standard type 1 fonts, because itext ships afm file (adobe font metrics files). itext has no thought font metrics of other fonts (verdana isn't standard type 1 font). need provide path verdana font file.

basefont.createfont("c:/windows/fonts/verdana.ttf", basefont.winansi, basefont.embedded)

note alter false basefont.embedded because same problem have on side, occur on side of person looks @ file: pdf viewer can render standard type 1 fonts, may not able render other fonts such verdana.

caveat: hard coded path "c:/windows/fonts/verdana.ttf" works me on local machine because font file can found using path on local machine. code won't work on server host itext site, though (which linux server doesn't have c:/windows/fonts directory). using hard coded path way of example. should create sure font nowadays , available when deploy application.

pdf itext

MySQL dynamic loop through table and delete rows based on condition -



MySQL dynamic loop through table and delete rows based on condition -

is possible loop through tables , delete rows based on status can tables this:

select table_name information_schema.tables table_schema = 'mytables'

is possible loop through them , perform query similar this:

delete table now() > columnname

loop through statement selects tables , every table_name execute:

begin set @s = concat('delete from',table_name,' now() > columnname'); prepare stmt @s; execute stmt; deallocate prepare stmt; end

mysql

javascript - Improving code quality/organization of event-heavy riot applications -



javascript - Improving code quality/organization of event-heavy riot applications -

i building application using riot.js , jquery. works expected, code grows, worry triggering , handling events (.trigger/.on) in random/unexpected places in code doing nil maintain code organized , understandable.

my questions are:

(1) maintain code such application clean , streamlined (event namespaces 1 thing comes mind) ,

(2) maintain events on model separated events on dom in presenter. how can accomplish these goals in riot.js based application

thank you.

you @ functional reactive programming approach. here solutions may insterested in:

rx.js - reactive extensions javascript microsoft bacon.js - popular frp library kefir.js - less popular insteresting frp library

javascript jquery riot.js

character encoding - convert database from latin1_swedish_ci to utf8 -



character encoding - convert database from latin1_swedish_ci to utf8 -

i have vbulletin database , wont convert latin1_swedish_ci utf8_unicode_ci can 1 know command convert database or script or php file create charset utf8 give thanks u

there many ways this. here one: dump database , open suitable text editor , save encoding utf8.

character-encoding

java - JFreeChart Candlestick pointer -



java - JFreeChart Candlestick pointer -

i have jfreechart this:

and want add together mouse pointer chart similar highcharts uses:

here variation of code shown here creates jfreechart:

import org.jfree.data.xy.abstractxydataset; import org.jfree.data.xy.defaultohlcdataset; import org.jfree.data.xy.*; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.xyplot; import org.jfree.chart.renderer.xy.candlestickrenderer; import java.awt.*; import java.io.*; import java.net.url; import java.text.*; import java.util.*; public class chartohlc extends chartpanel { public chartohlc() { super(dajgraf()); setmaximumdrawheight(2000); setmaximumdrawwidth(3000); } public static jfreechart dajgraf() { // premenne string stocksymbol = "aapl"; final dateaxis domainaxis = new dateaxis("date"); numberaxis rangeaxis = new numberaxis("price"); candlestickrenderer renderer = new candlestickrenderer(); xydataset dataset = getdataset(stocksymbol); xyplot mainplot = new xyplot(dataset, domainaxis, rangeaxis, renderer); //do setting up, see api doc renderer.setseriespaint(0, color.black); renderer.setdrawvolume(false); rangeaxis.setautorangeincludeszero(false); //now create chart , chart panel jfreechart chart = new jfreechart(null, null, mainplot, false); mainplot.setdomainpannable(true); mainplot.setrangepannable(true); homecoming chart; } private static abstractxydataset getdataset(string stocksymbol) { //this dataset going create defaultohlcdataset result; //this info needed dataset ohlcdataitem[] data; //this go data, replace own info source info = getdata(stocksymbol); //create dataset, open, high, low, close dataset result = new defaultohlcdataset(stocksymbol, data); homecoming result; } private static ohlcdataitem[] getdata(string stocksymbol) { arraylist<ohlcdataitem> dataitems = new arraylist<ohlcdataitem>(); seek { string strurl = "http://ichart.yahoo.com/table.csv?s=" + stocksymbol + "&a=2&b=1&c=2014&d=3&e=1&f=2014&g=d&ignore=.csv"; system.out.println(strurl); url url = new url(strurl); bufferedreader in = new bufferedreader(new inputstreamreader(url.openstream())); dateformat df = new simpledateformat("y-m-d"); string inputline; in.readline(); while ((inputline = in.readline()) != null) { stringtokenizer st = new stringtokenizer(inputline, ","); date date = df.parse(st.nexttoken()); double open = double.parsedouble(st.nexttoken()); double high = double.parsedouble(st.nexttoken()); double low = double.parsedouble(st.nexttoken()); double close = double.parsedouble(st.nexttoken()); double volume = double.parsedouble(st.nexttoken()); double adjclose = double.parsedouble(st.nexttoken()); ohlcdataitem item = new ohlcdataitem(date, open, high, low, close, volume); dataitems.add(item); } in.close(); } grab (exception e) { e.printstacktrace(system.err); } //data yahoo newest oldest. reverse oldest newest collections.reverse(dataitems); //convert list array ohlcdataitem[] info = dataitems.toarray(new ohlcdataitem[dataitems.size()]); homecoming data; } }

is possible add together mouse pointer candlestick jfreechart?

java jfreechart candlestick-chart

php - Cpanel cron jobs not working using magento? -



php - Cpanel cron jobs not working using magento? -

anyone please help me

domain: godaddy

hosting: vps server

name server: mns01.domaincontrol.com

name server: mns02.domaincontrol.com

below test case scenarios did , got result

for cron.php file gave permission 777

minutes hr day month weekday set * * * * *

test 1:

/home/domain/public_html/cron.php

result: /home/domain/public_html/cron.php: line 1: ?php: no such file or directory /home/domain/public_html/cron.php: line 2: syntax error near unexpected token `dirname' /home/domain/public_html/cron.php: line 2: `chdir(dirname(__file__));'

test 2:

/usr/bin/php -q /home/domain/public_html/cron.php

result: nil display

test 3:

php -q /home/domain/public_html/cron.php

result: nil display

test 4:

/usr/bin/php /home/domain/public_html/cron.php

result: x-powered-by: php/5.4.33 content-type: text/html

test 5:

get https://www.domain.com/cron.php

result: lwp back upwards https urls if lwp::protocol::https module installed.

test 6:

get http://www.domain.com/cron.php

result: nil display

test 7:

i replaced above test cron.php replaced cron.sh , tested. got same result.

test 8:

/home/domain/public_html/test.php

code: <?php echo "hello world";?> result: /home/domain/public_html/cron.php: line 1: ?php: no such file or directory hello world

you should using cron.sh file on command line (not get), , specify sh path

/bin/sh /home/domain/public_html/cron.sh

php magento cron cpanel magento-1.8

dataset - Converting cross-sectional data into an adjacency matrix in R -



dataset - Converting cross-sectional data into an adjacency matrix in R -

i trying convert cross-sectional info adjacency matrix, want analyze how variables nowadays social network analysis. in case empirical examples help logic, it's analogous presenting 4 people selection of 3 objects; can take 0 3 of objects. i'd analyze how commonly different objects chosen , visualize network of preferences.

the info set cross-sectional data, below:

id1 <- c(1,0,0) id2 <- c(1,0,1) id3 <- c(1,1,1) id4 <- c(0,0,0) ids <- c("1","2","3","4") df <- data.frame(rbind(id1, id2, id3, id4)) df <- cbind(ids, df) colnames(df) <- c("id", "var1", "var2", "var3")

i'd create weighted adjacency matrix var1, var2 , var3, each cell containing total number of times 2 variables occur among observations.

so basic procedure thinking create separate matrix each row (each id number) 1 or 0 each cell indicating whether or not both variables nowadays id. , add together these matrices together, final matrix gives total number of joint appearances.

i've been looking around , haven't quite gotten right. thought of using outer, it'd need work each column in sequence. reply pretty close, wasn't sure how adding values. ended list of matrices, values didn't correspond initial data- convert categorical info in info frame weighted adjacency matrix. , reply close, although seemed have different type of data. gave me adjacency matrix based on ids- http://r.789695.n4.nabble.com/conversion-to-adjacency-matrix-td794102.html

here messy code manually create matrix 1 observation, sense i'm going (using vector representing first id observation)

id1 <- c(1,0,0) var1 <- id1[[1]] var2 <- id1[[2]] var3 <- id1[[3]] onetwo <- var1 * var2 onethree <- var1 * var3 twothree <- var2 * var3 oneone <- var1 * var1 twotwo <- var2 * var2 threethree <- var3 * var3 rows1 <- rbind(oneone, onetwo, onethree) rows2 <- rbind(onetwo, twotwo, twothree) rows3 <- rbind(onethree, twothree, threethree) df2 <- cbind(rows1, rows2, rows3)

this not ideal, actual dataset has 198 observations , 33 variables, looping or utilize of apply functions inefficient.

i can't tell if i'm making more hard needs be, or if i'm trying forcefulness info wasn't meant do. if has run sort of task before, please allow me know. there way create desired adjacency matrix directly? should transfer border list first, , there way that? there code create first step(creating matrix each row of dataframe) more efficient?

thanks help,

i'm not sure if understand question, want?

nc=33 nr=198 m3<-matrix(sample(0:1,nc*nr,replace=true),nrow=nr) df3<-data.frame(m3) m3b <-matrix(0,nrow=nc,ncol=nc) for(i in seq(1,nc)) { (j in seq(1,nc)) { t3<-table(df3[,i],df3[,j]) m3b[i,j] = t3[2,2] # t3[2,2] contains count of df3[,i] = df3[,j] = 1 # or # t3 = sum(df3[,i]==df3[,j] & df3[,i] == 1) # m3b[i,j] = t3 } }

or, if want sum of product, gives same result if 1 or 0

m3c <-matrix(0,nrow=nc,ncol=nc) for(i in seq(1,nc)) { (j in seq(1,nc)) { sv=0 (k in seq(1,nr)) { vi = df3[k,i] vj = df3[k,j] sv=sv+vi*vj } m3c[i,j] = sv } }

r dataset adjacency-matrix