Adjacency matrix from dataframe with igraph R2019 Community Moderator ElectionHow to sort a dataframe by multiple column(s)?How do I replace NA values with zeros in an R dataframe?igraph creating a weighted adjacency matrixPlotting graph from adjacency matrixigraph generate adjacency matrix from adjacency listWeighted Adjacency matrix igraph and Rigraph Graph from numpy or pandas adjacency matrixr creating an adjacency matrix from columns in a dataframeCreate adjacency matrix for SNA from dataframeAdjacency matrix using igraph package

When to use mean vs median

How do you say “my friend is throwing a party, do you wanna come?” in german

How to kill a localhost:8080

How can I handle a player who pre-plans arguments about my rulings on RAW?

Where is this quote about overcoming the impossible said in "Interstellar"?

A bug in Excel? Conditional formatting for marking duplicates also highlights unique value

Lock enemy's y-axis when using Vector3.MoveTowards to follow the player

Split a number into equal parts given the number of parts

Plagiarism of code by other PhD student

How to merge row in the first column in LaTeX

Are small insurances worth it

Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?

How can I be pwned if I'm not registered on the compromised site?

Where is the fallacy here?

Why doesn't "adolescent" take any articles in "listen to adolescent agonising"?

Giving a talk in my old university, how prominently should I tell students my salary?

3.5% Interest Student Loan or use all of my savings on Tuition?

Is there a full canon version of Tyrion's jackass/honeycomb joke?

Was it really inappropriate to write a pull request for the company I interviewed with?

How can I highlight parts in a screenshot

PTIJ: Aharon, King of Egypt

What is better: yes / no radio, or simple checkbox?

How to roleplay my character's ethics according to the DM when I don't understand those ethics?

Understanding the template



Adjacency matrix from dataframe with igraph R



2019 Community Moderator ElectionHow to sort a dataframe by multiple column(s)?How do I replace NA values with zeros in an R dataframe?igraph creating a weighted adjacency matrixPlotting graph from adjacency matrixigraph generate adjacency matrix from adjacency listWeighted Adjacency matrix igraph and Rigraph Graph from numpy or pandas adjacency matrixr creating an adjacency matrix from columns in a dataframeCreate adjacency matrix for SNA from dataframeAdjacency matrix using igraph package










2















I am new at R and graphs, and I am trying to practice with a social signed network using the library igraph.



I have a dataframe (df) which contains three columns. The first one is the voter, the second one the user who receives the vote, and the third one is the vote (-1 or 1 depending of the negative or positive vote, respectively).



> head(df)

voter user vote
1 ludraman cjcurrie 1
2 blankfaze olivo -1
3 gzornenplatz cjcurrie 1
4 orthogonal olvion 1
5 andrevan cerviz 1
6 texture cjcurrie 1


I want to create a graph with igraph but firstly I need to obtain the adjacency matrix from df.



I tried with the library sharpshootR



A <- component.adj.matrix(df[, c(1,2)], mu=df[, 1], co=df[, 2], wt=df[, 3])


Is there a simple way to obtain that adjacency matrix using the library igraph?



Thanks.










share|improve this question
























  • Please post your answer below, not inside the question.

    – zx8754
    13 hours ago















2















I am new at R and graphs, and I am trying to practice with a social signed network using the library igraph.



I have a dataframe (df) which contains three columns. The first one is the voter, the second one the user who receives the vote, and the third one is the vote (-1 or 1 depending of the negative or positive vote, respectively).



> head(df)

voter user vote
1 ludraman cjcurrie 1
2 blankfaze olivo -1
3 gzornenplatz cjcurrie 1
4 orthogonal olvion 1
5 andrevan cerviz 1
6 texture cjcurrie 1


I want to create a graph with igraph but firstly I need to obtain the adjacency matrix from df.



I tried with the library sharpshootR



A <- component.adj.matrix(df[, c(1,2)], mu=df[, 1], co=df[, 2], wt=df[, 3])


Is there a simple way to obtain that adjacency matrix using the library igraph?



Thanks.










share|improve this question
























  • Please post your answer below, not inside the question.

    – zx8754
    13 hours ago













2












2








2








I am new at R and graphs, and I am trying to practice with a social signed network using the library igraph.



I have a dataframe (df) which contains three columns. The first one is the voter, the second one the user who receives the vote, and the third one is the vote (-1 or 1 depending of the negative or positive vote, respectively).



> head(df)

voter user vote
1 ludraman cjcurrie 1
2 blankfaze olivo -1
3 gzornenplatz cjcurrie 1
4 orthogonal olvion 1
5 andrevan cerviz 1
6 texture cjcurrie 1


I want to create a graph with igraph but firstly I need to obtain the adjacency matrix from df.



I tried with the library sharpshootR



A <- component.adj.matrix(df[, c(1,2)], mu=df[, 1], co=df[, 2], wt=df[, 3])


Is there a simple way to obtain that adjacency matrix using the library igraph?



Thanks.










share|improve this question
















I am new at R and graphs, and I am trying to practice with a social signed network using the library igraph.



I have a dataframe (df) which contains three columns. The first one is the voter, the second one the user who receives the vote, and the third one is the vote (-1 or 1 depending of the negative or positive vote, respectively).



> head(df)

voter user vote
1 ludraman cjcurrie 1
2 blankfaze olivo -1
3 gzornenplatz cjcurrie 1
4 orthogonal olvion 1
5 andrevan cerviz 1
6 texture cjcurrie 1


I want to create a graph with igraph but firstly I need to obtain the adjacency matrix from df.



I tried with the library sharpshootR



A <- component.adj.matrix(df[, c(1,2)], mu=df[, 1], co=df[, 2], wt=df[, 3])


Is there a simple way to obtain that adjacency matrix using the library igraph?



Thanks.







r networking graph igraph






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 13 hours ago







DiegoDZ

















asked 16 hours ago









DiegoDZDiegoDZ

896




896












  • Please post your answer below, not inside the question.

    – zx8754
    13 hours ago

















  • Please post your answer below, not inside the question.

    – zx8754
    13 hours ago
















Please post your answer below, not inside the question.

– zx8754
13 hours ago





Please post your answer below, not inside the question.

– zx8754
13 hours ago












2 Answers
2






active

oldest

votes


















0














If I got your problem right, you can use graph_from_data_frame from igraph itself:



Data



d <- structure(list(voter = c("ludraman", "blankfaze", "gzornenplatz", "orthogonal", 
"andrevan", "texture"),
user = c("cjcurrie", "olivo", "cjcurrie", "olvion", "cerviz", "cjcurrie"),
vote = c(1L, -1L, 1L, 1L, 1L, 1L)),
row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")


igraph



library(igraph)
g <- graph_from_data_frame(d)
plot(g)


igraph of relations



You can probably work from tehre (given your full data) to use other parts of the data in the visualization (like the score).






share|improve this answer























  • Thank you! But my database is so long. I can't write by hand all the names and votes.

    – DiegoDZ
    14 hours ago


















0














This solution works for my problem:



edge_list <- training_edges[df]. # create a edge list
G <- graph.data.frame(edge_list, directed=TRUE) # create the graph

A <- as_adjacency_matrix(G,type="both",names=TRUE,
sparse=FALSE, attr = "vote") # create the adjacency matrix


Where A is the adjacency matrix.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55018186%2fadjacency-matrix-from-dataframe-with-igraph-r%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If I got your problem right, you can use graph_from_data_frame from igraph itself:



    Data



    d <- structure(list(voter = c("ludraman", "blankfaze", "gzornenplatz", "orthogonal", 
    "andrevan", "texture"),
    user = c("cjcurrie", "olivo", "cjcurrie", "olvion", "cerviz", "cjcurrie"),
    vote = c(1L, -1L, 1L, 1L, 1L, 1L)),
    row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")


    igraph



    library(igraph)
    g <- graph_from_data_frame(d)
    plot(g)


    igraph of relations



    You can probably work from tehre (given your full data) to use other parts of the data in the visualization (like the score).






    share|improve this answer























    • Thank you! But my database is so long. I can't write by hand all the names and votes.

      – DiegoDZ
      14 hours ago















    0














    If I got your problem right, you can use graph_from_data_frame from igraph itself:



    Data



    d <- structure(list(voter = c("ludraman", "blankfaze", "gzornenplatz", "orthogonal", 
    "andrevan", "texture"),
    user = c("cjcurrie", "olivo", "cjcurrie", "olvion", "cerviz", "cjcurrie"),
    vote = c(1L, -1L, 1L, 1L, 1L, 1L)),
    row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")


    igraph



    library(igraph)
    g <- graph_from_data_frame(d)
    plot(g)


    igraph of relations



    You can probably work from tehre (given your full data) to use other parts of the data in the visualization (like the score).






    share|improve this answer























    • Thank you! But my database is so long. I can't write by hand all the names and votes.

      – DiegoDZ
      14 hours ago













    0












    0








    0







    If I got your problem right, you can use graph_from_data_frame from igraph itself:



    Data



    d <- structure(list(voter = c("ludraman", "blankfaze", "gzornenplatz", "orthogonal", 
    "andrevan", "texture"),
    user = c("cjcurrie", "olivo", "cjcurrie", "olvion", "cerviz", "cjcurrie"),
    vote = c(1L, -1L, 1L, 1L, 1L, 1L)),
    row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")


    igraph



    library(igraph)
    g <- graph_from_data_frame(d)
    plot(g)


    igraph of relations



    You can probably work from tehre (given your full data) to use other parts of the data in the visualization (like the score).






    share|improve this answer













    If I got your problem right, you can use graph_from_data_frame from igraph itself:



    Data



    d <- structure(list(voter = c("ludraman", "blankfaze", "gzornenplatz", "orthogonal", 
    "andrevan", "texture"),
    user = c("cjcurrie", "olivo", "cjcurrie", "olvion", "cerviz", "cjcurrie"),
    vote = c(1L, -1L, 1L, 1L, 1L, 1L)),
    row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")


    igraph



    library(igraph)
    g <- graph_from_data_frame(d)
    plot(g)


    igraph of relations



    You can probably work from tehre (given your full data) to use other parts of the data in the visualization (like the score).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 15 hours ago









    thothalthothal

    4,0391236




    4,0391236












    • Thank you! But my database is so long. I can't write by hand all the names and votes.

      – DiegoDZ
      14 hours ago

















    • Thank you! But my database is so long. I can't write by hand all the names and votes.

      – DiegoDZ
      14 hours ago
















    Thank you! But my database is so long. I can't write by hand all the names and votes.

    – DiegoDZ
    14 hours ago





    Thank you! But my database is so long. I can't write by hand all the names and votes.

    – DiegoDZ
    14 hours ago













    0














    This solution works for my problem:



    edge_list <- training_edges[df]. # create a edge list
    G <- graph.data.frame(edge_list, directed=TRUE) # create the graph

    A <- as_adjacency_matrix(G,type="both",names=TRUE,
    sparse=FALSE, attr = "vote") # create the adjacency matrix


    Where A is the adjacency matrix.






    share|improve this answer



























      0














      This solution works for my problem:



      edge_list <- training_edges[df]. # create a edge list
      G <- graph.data.frame(edge_list, directed=TRUE) # create the graph

      A <- as_adjacency_matrix(G,type="both",names=TRUE,
      sparse=FALSE, attr = "vote") # create the adjacency matrix


      Where A is the adjacency matrix.






      share|improve this answer

























        0












        0








        0







        This solution works for my problem:



        edge_list <- training_edges[df]. # create a edge list
        G <- graph.data.frame(edge_list, directed=TRUE) # create the graph

        A <- as_adjacency_matrix(G,type="both",names=TRUE,
        sparse=FALSE, attr = "vote") # create the adjacency matrix


        Where A is the adjacency matrix.






        share|improve this answer













        This solution works for my problem:



        edge_list <- training_edges[df]. # create a edge list
        G <- graph.data.frame(edge_list, directed=TRUE) # create the graph

        A <- as_adjacency_matrix(G,type="both",names=TRUE,
        sparse=FALSE, attr = "vote") # create the adjacency matrix


        Where A is the adjacency matrix.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 hours ago









        DiegoDZDiegoDZ

        896




        896



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55018186%2fadjacency-matrix-from-dataframe-with-igraph-r%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved