Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:22:18+00:00 2026-06-08T04:22:18+00:00

I have following type data for human family: indvidual <- c(John, Kris, Peter, King,

  • 0

I have following type data for human family:

indvidual <- c("John",  "Kris", "Peter",  "King",  "Marry",  "Renu", "Kim",    "Ken", "Lu")
Parent1 <- c(    NA,     NA,     "John",  "John",   "John",    NA,    "Peter",  NA,    NA)
Parent2 <- c(    NA,     NA,    "Kris",   "Kris",  "Renu",   NA,      "Lu",     NA,   NA)
X <-       c(    2,     3,       2,       3,           4,     5,        1.5,      1,    1)
Y <-       c(    3,     3,       2,       2,           2,     3,        1,      3,    2)
pchsize <- c( 4.5,      4.3,     9.2,     6.2,         3.2,   6.4,      2.1,    1.9,  8)
fillcol <- c( 8.5,      8.3,     1.2,     3.2,         8.2,   2.4,      2.6,    6.1,  3.2)
myd <- data.frame (indvidual, Parent1, Parent2, X, Y, pchsize,fillcol)

 indvidual Parent1 Parent2   X Y pchsize fillcol
1      John    <NA>    <NA> 2.0 3     4.5     8.5
2      Kris    <NA>    <NA> 3.0 3     4.3     8.3
3     Peter    John    Kris 2.0 2     9.2     1.2
4      King    John    Kris 3.0 2     6.2     3.2
5     Marry    John    Renu 4.0 2     3.2     8.2
6      Renu    <NA>    <NA> 5.0 3     6.4     2.4
7       Kim   Peter      Lu 1.5 1     2.1     2.6
8       Ken    <NA>    <NA> 1.0 3     1.9     6.1
9        Lu    <NA>    <NA> 1.0 2     8.0     3.2

I want plot something like the following, individuals points are connected to parents (Preferably different line color to Parent1 and Parent2 listed). Also pch size and pch fill is scaled to other variables pchsize and fillcol. Thus plot outline is:

enter image description here

Here is my progress in ggplot2:

require(ggplot2) 
ggplot(data=myd, aes(X, Y,fill = fillcol)) +
  geom_point(aes(size = pchsize, fill = fillcol), pch = "O") +
  geom_text(aes (label = indvidual, vjust=1.25))

enter image description here

Issues unsolved: connecting lines, making size of pch big and fill color at the sametime.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:22:19+00:00Added an answer on June 8, 2026 at 4:22 am

    One thing that jumped out to me was to treat this is a network – R has many packages to plot these.

    Here’s a very simple solution:
    First, I used your parent list to make a sociomatrix – you can generally input networks using edge lists as well – here I put 1 for the first parental relationship and 2 for the second.

    psmat <- rbind(c(0, 0, 1, 1, 1, 0, 0, 0, 0),
              c(0, 0, 2, 2, 0, 0, 0, 0, 0),
              c(0, 0, 0, 0, 0, 0, 1, 0, 0),
              rep(0, 9),
              rep(0, 9),
              c(0, 0, 0, 0, 2, 0, 0, 0, 0),
              rep(0, 9),
              rep(0, 9),
              c(0, 0, 0, 0, 0, 0, 2, 0, 0))
    

    Then, using the network package I just hit:

    require(network)
    plot(network(psmat), coord = cbind(X, Y), vertex.cex = pchsize, 
      vertex.col = fillcol, label = indvidual, edge.col = psmat)
    

    This isn’t terribly pretty in itself, but I think gives you all the basic elements you wanted.

    For the colors, I believe the decimal places are just rounded – I wasn’t sure what to do with those.

    I know I’ve seen people plot networks in ggplot, so that might give you a better result.

    example picture

    Edit:
    So here’s a really messy way of turning your data into a network object directly – someone else might be able to fix it. Additionally, I add an edge attribute (named ‘P’ for parental status) and give the first set a value of 1 and the second set a value of 2. This can be used when plotting to set the colors.

    P1 <- match(Parent1, indvidual)
    e1 <- cbind(P1, 1:9); e1 <- na.omit(e1); attr(e1, 'na.action') <- NULL
    P2 <- match(Parent2, indvidual)
    e2 <- cbind(P2, 1:9); e2 <- na.omit(e2); attr(e2, 'na.action') <- NULL
    
    en1 <- network.initialize(9)
    add.edges(en1, e1[,1], e1[,2])
    set.edge.attribute(en1, 'P', 1)
    add.edges(en1, e2[,1], e2[,2], names.eval = 'P', vals.eval = 2)
    
    plot(en1, coord = cbind(X, Y), vertex.cex = pchsize, 
      vertex.col = fillcol, label = indvidual, edge.col = 'P')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following type of data ntrt = paste (EL, 1:4, sep= ) repl
I have following webservice: [webmethod] public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
I have a table RDCAlerts with the following data in a column of type
I have following ajax call and response with json data type. Currently I write
I have following type of data, means combination of factors P1 <- c(a, a,
I have a text file with the following type of data in it below:
I have following type of data and I want to produce bar graph. Mark
I have the following sample xml in a column of xml data type: <diagnostics
I have the following cell which is used for my custom column data type
I have the following type of data: Person <- c(A, B, C, D, E,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.