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 6863679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:48:51+00:00 2026-05-27T02:48:51+00:00

I am trying to merge: to_graph <- structure(list(Teacher = c(BS, BS, FA ), Level

  • 0

I am trying to merge:

to_graph <- structure(list(Teacher = c("BS", "BS", "FA"
), Level = structure(c(2L, 1L, 1L), .Label = c("BE", "AE", "ME", 
"EE"), class = "factor"), Count = c(2L, 25L, 28L)), .Names = c("Teacher", 
"Level", "Count"), row.names = c(NA, 3L), class = "data.frame")

and

graph_avg <- structure(list(Teacher = structure(c(1L, 1L, 2L), .Label = c("BS", 
"FA"), class = "factor"), Count.Fraction = c(0.0740740740740741, 
0.925925925925926, 1)), .Names = c("Teacher", "Count.Fraction"
), row.names = c(NA, -3L), class = "data.frame")

with merge(to_graph, graph_avg, by="Teacher"), but instead of getting what I expect (3 rows), I get:

  Teacher Level Count Count.Fraction
1      BS    AE     2     0.07407407
2      BS    AE     2     0.92592593
3      BS    BE    25     0.07407407
4      BS    BE    25     0.92592593
5      FA    BE    28     1.00000000

Any ideas? Thank you!

  • 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-05-27T02:48:52+00:00Added an answer on May 27, 2026 at 2:48 am

    Not sure what you’re trying to accomplish. merge is doing what it’s supposed to here.

    Let’s look at all of the data.frames

    graph_avg
      Teacher Count.Fraction
    1      BS     0.07407407
    2      BS     0.92592593
    3      FA     1.00000000
    
    to_graph
      Teacher Level Count
    1      BS    AE     2
    2      BS    BE    25
    3      FA    BE    28
    
    merge(to_graph, graph_avg)
      Teacher Level Count Count.Fraction
    1      BS    AE     2     0.07407407
    2      BS    AE     2     0.92592593
    3      BS    BE    25     0.07407407
    4      BS    BE    25     0.92592593
    5      FA    BE    28     1.00000000
    

    Now, if I’m going to merge those I’ve got to look and see what’s common and what I’m going to get for an outcome. Teacher, you have that in both. But, if I try to merge on just Teacher what do I do? There’s no unique identifier for BS and it appears twice in both data.frames. If it appeared once in one of them it would be easy to solve. So, I go can check and say, OK, I’ve got a unique identifier in one data.frame, level… that would do it… and go and make something that doesn’t lose any of your data. merge is really handy for situations where you’ve got a small data.frame, say with each teacher in it once, and it has the teacher’s age, or sex there. You could merge that into your another data.frame with repeated measures on teacher and every time the teacher appears you’ll also know those. But for what you’re doing it’s not the right tool.

    merge is not what you want here. If these are really your data.frames use cbind instead.

    cbind(to_graph, graph_avg$Count.Fraction)
    
      Teacher Level Count Count.Fraction
    1      BS    AE     2     0.07407407
    2      BS    BE    25     0.92592593
    3      FA    BE    28     1.00000000
    

    That’s probably what you were looking for.

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

Sidebar

Related Questions

I am trying to merge two list in parallel. I have two sorted lists
I am trying to merge all the assemblies of an class library in a
I am trying to merge a property in an abstract parent class with the
I am trying to merge data between two identical schema databases using Linq-to-sql: List<Contact>
I'm trying to merge two main menus together, but am having problems getting the
I am trying to merge multiple excel files using DataTable.Merge() option For Each fileName
I'm trying to merge two arrays for the values of array1 that are set
I'm trying to merge these 2 arrays $arr1 = array('a' => 1, 'b' =>
I am trying to merge two data.frames together, based on a common column name
I'm trying to merge two docx-documents into one docx-document using OpenXML SDK 2.0. The

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.