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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:22:07+00:00 2026-06-15T23:22:07+00:00

I have a dataframe a , with A, B, C are separate entries Source

  • 0

I have a dataframe a, with A, B, C are separate entries

Source Target N
A B 100
A D 200

I have another dataframe b for entries’ attributes

Name Rate1 Rate2
A  0.1 0.2
B  0.2 0.3

I want to calculate a new column Flow in a, as it is calculated row based by Flow = a$N * b[Name == a$Source]$Rate1. I tried to use apply by row, but I felt it’s slow. Is there a faster way?

  • 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-15T23:22:08+00:00Added an answer on June 15, 2026 at 11:22 pm

    Here’s a fairly expressive solution, fairly similar to the code you tried:

    >  a$Flow <- a$N*b$Rate1[ match(a$Source, b$Name) ]
    > a
      Source Target   N Flow
    1      A      B 100   10
    2      A      D 200   20
    

    The match function is the basis for merge and %in%. It is particularly useful for constructing index vectors to pick from alternatives.

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

Sidebar

Related Questions

I have 2 separate dataframes df1 ID Name loq 1 a 1.2 1 b
I have a dataframe with over 200 columns. The issue is as they were
I have a dataframe with numeric entries like this one test <- data.frame(x =
Suppose I have a DataFrame with 100k rows and a column name . I
I have a large Pandas DataFrame <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 3425100 entries, 2011-12-01 00:00:00 to
I have a dataframe that looks like this: <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 2016910 entries, 2009-01-02
I have a dataframe with distances df<-data.frame(site.x=c(A,A,A,B,B,C), site.y=c(B,C,D,C,D,D),Distance=c(67,57,64,60,67,60)) I need to convert this to
I have a dataframe x with this values: x1 x2 x3 1 NA 4
I have a dataframe with some numeric columns. Some row has a 0 value
I have a dataframe called split2_data (actually a drop-leveled subset of a bigger data

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.