graph.edgelist出错

时间:2016-02-06 21:59:14

标签: social-networking igraph

您好我一直在尝试使用igraph包将我的数据帧转换为图形对象。

g = as.matrix(votings[,1:2])
g = graph.edgelist(votings, directed = TRUE)
Error in graph.edgelist(votings) :    graph_from_edgelist expects a matrix with two columns

我也试过drop = FALSE,就像其他帖子所说的那样。

g = graph.edgelist(votings[,1:2, drop = FALSE))
Error in graph.edgelist(votings) :    graph_from_edgelist expects a matrix with two columns

任何想法我的代码可能出错?前两列投票包含字符串(名称)。

1 个答案:

答案 0 :(得分:0)

所以我尝试了graph_from_data_frame,就像Gabor Casardi建议的那样。谢谢!但是如果你想使用graph.edgelist,那就行了。

function onEdit(e) {
  var s = SpreadsheetApp.getActiveSheet(), r, colCell;
  if(s.getName() === 'SkapOversikt') { //checks that we're on the correct sheet
    r = s.getActiveCell();
    colCell = r.getColumn();
    if(colCell === 1 || colCell === 6) { //checks the column
      nextCell = r.offset(0, 0);
      if(nextCell.getValue() === 'Send Melding') { //Inneholder "Send Melding", kjør script

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var cell = ss.getActiveCell().getA1Notation();
  var row = sheet.getActiveRange().getRow();
  var cellvalue = ss.getActiveCell().getValue().toString();
  var recipients = sheet.getRange(7, 7).getValue();      
  var subject = 'Skapoversikt har blitt oppdatert på : '+sheet.getRange(4, 2).getValue();
  var body = 'Blåse info på ' + sheet.getRange(4, 2).getValue() + ' har blitt oppdatert. ' + '\n' + '\nFølg link for å se endringer : ' + ss.getUrl() + '\n' + '\n' + 'Melding fra melder : ' + '\n' + '" ' + sheet.getRange(6, 7).getValue() + ' " ' + '\n ' + '\n (Dette er en generert mail fra Google Sheets og vil ikke kunne besvares) ' + '\n' + '\n - AK AS ';
        MailApp.sendEmail(recipients, subject, body);

  var sheet = SpreadsheetApp.getActive().getSheetByName('SkapOversikt');
  sheet.getRange('G6').setValue('Ingen Melding');
  sheet.getRange('A6').setValue('Velg');
  Browser.msgBox('Takk for det - Meldingen er sendt!' , 'Meldingen er sendt til : '+sheet.getRange(7, 7).getValue()+ '\n' + '  - (Fra epost : )', Browser.Buttons.OK);
  }
  }
  }
}