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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:11:58+00:00 2026-06-14T18:11:58+00:00

I have the following two data frames: d <- data.frame(c1 = c(A,A,B,C,A,C,D,D)) map <-

  • 0

I have the following two data frames:

d <- data.frame(c1 = c("A","A","B","C","A","C","D","D"))

map <- data.frame(c1 = c("A","B","C","D"), c2 = c(12,14,16,25))

How can I add another column called “match” to data frame d that contains corresponding values found in data frame map? So data frame d should look like:

A 12
A 12
B 14
C 16
A 12
C 16
D 25
D 25

Many thanks in advance!

  • 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-14T18:11:59+00:00Added an answer on June 14, 2026 at 6:11 pm

    Using the function called match:

    d$match <- map$c2[match(d$c1,map$c1)]
    

    And because of the way these levels are specified, you could also do:

    d$match <- map$c2[d$c1]
    

    But this only works if each row in match exactly matches the levels of the c1 factor in order.

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

Sidebar

Related Questions

I have two data frames that look like something like the following: df1 <-
I have the following dataframe: sp <- combn(c(sp1,sp2,sp3,sp4),2) d <- data.frame(t(sp),freq=sample(0:100,6)) and two factors
I have data.frame that contains several factors and i want to rename factor levels
I have the following matching problem: I have two data.frames, one with an observation
I have the following data. df = data.frame(email_one=c(one@gkn.com,two@wern.com,three@fu.cin, four@huo.com,five@hoi.com), email_two=c(ten@hoinse.com, four@huo.com,two@wern.com,five@hoi.com,six@ihoio.com)) I'm wondering if
Let's say I have the following dataset bodysize=rnorm(20,30,2) bodysize=sort(bodysize) survive=c(0,0,0,0,0,1,0,1,0,0,1,1,0,1,1,1,0,1,1,1) dat=as.data.frame(cbind(bodysize,survive)) I'm aware that
I have a data frame that has a format like the following: Month Frequency
I have a data frame with two columns. The first column defines subsets of
I have data frame with two column say a and b now I want
1I have the following two tables (sample data) and need to be able to

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.