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

  • Home
  • SEARCH
  • 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 8225489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:26:05+00:00 2026-06-07T15:26:05+00:00

I am trying to create a structure diagram from the data like the following:

  • 0

I am trying to create a structure diagram from the data like the following:

mydf <- data.frame ( group = rep (1:5, each = 20), z = rnorm (20, 10, 1),
                  x = c(rnorm (20, 2, 0.5), rnorm (20, 2, 0.5),
          rnorm (20, 9, 0.5), rnorm (20, 9, 0.5),rnorm (20, 5, 0.5)),
       y = c(rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 2, 0.5),
      rnorm (20, 9, 0.5), rnorm (20, 2, 0.5)))

means <- aggregate(. ~ group, data = mydf, mean)
gmx <-mean (mydf$x)
gmy <- mean (mydf$y)

library(ggplot2)
ggplot(mydf, aes(x, y)) +
geom_point(aes(colour= factor (group), size=z)) + theme_bw()

I want make connect every points within each cluster to its center and then the cluster center to grad mean. This will be produce a plot like the following (just rough sketch where two cluster are connected to the center, in real all cluster have the same):………

(I would like to use the line segments of same color as of cluster if possible)

enter image description here

  • 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-07T15:26:06+00:00Added an answer on June 7, 2026 at 3:26 pm

    Here is an example:

    library(plyr)
    ms <- ddply(mydf, .(group), colwise(mean))
    mydf2ms <- merge(mydf, ms, by = "group")
    gm <- ddply(mydf, NULL, colwise(mean))
    ms2gm <- data.frame(ms, gm)
    
    ci <- expand.grid(1:3*2, seq(0, 2*pi, length = 180))
    ci <- transform(ci, x = cos(Var2) * Var1 + gm$x, y = sin(Var2) * Var1 + gm$y)
    
    library(ggplot2)
    ggplot(mydf, aes(x, y)) +
      geom_point(aes(colour= factor (group), size=z)) +
      geom_segment(data = mydf2ms, mapping = aes(x = x.x, y = y.x, xend = x.y, yend = y.y, colour = factor(group))) +
      geom_segment(data = ms2gm, mapping = aes(x = x, y = y, xend = x.1, yend = y.1)) +
      geom_point(data = ms, colour = "black", size = 10, shape = 4) +
      geom_point(data = gm, colour = "red", size = 10, shape = 4) +
      geom_path(data = ci, mapping = aes(group = Var1), colour = "pink")
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a treeview like structure from JSON data . Structure
We are trying to create/query information from a CF based on the following structure
I'm trying to create a file which has the following structure: - Each line
I'm trying to create the following data structure in Qt 4.5 in C++: QMap<int,
I am trying to create a wizard like structure using dialog boxes...So I replaced
I trying to create grid that contains rows with the following structure: item name,
I'm trying to create a matrix data structure in C. I have a struct
I've been trying to create a directory following a specific structure, yet nothing appears
In VB.NET I would like to create a complicated data structure with multiple types
I am trying to create a deep copy of my binary tree data structure

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.