PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in R data manipulation with dplyr, specifically sampling, left joins, conditional price transformations and running simple simulations to estimate average prices.

  • Medium
  • Google
  • Data Manipulation (SQL/Python)
  • Data Scientist

Sample and Simulate Price Adjustments in R with dplyr

Company: Google

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Products +----+-----------+-------+ | id | product | price | | 1 | phone | 500 | | 2 | tablet | 300 | | 3 | laptop | 1000 | | 4 | headset | 80 | | 5 | charger | 20 | +----+-----------+-------+ ​ Discounts +----+----------+ | id | discount | | 1 | 0.05 | | 3 | 0.10 | | 4 | 0.02 | +----+----------+ ##### Scenario Data-wrangling and simulation tasks in R (dplyr) involving sampling, joins and price adjustments. ##### Question Using dplyr, show how to randomly sample exactly 50% of a data frame. Perform a left join between a product table and a discount table on product id. Write a simulation that, for each run, keeps half the products at the same price, increases the rest by 10%, and returns the average simulated price. ##### Hints slice_sample(), left_join(), mutate with runif() or sample() inside replicate().

Quick Answer: This question evaluates proficiency in R data manipulation with dplyr, specifically sampling, left joins, conditional price transformations and running simple simulations to estimate average prices.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Generate binomial matrix and column-normalize - Google (Medium)
  • Analyze video flags and reviews with SQL - Google (Medium)
  • Write SQL/Python for messy event data - Google (Medium)
  • Add a conditional column in Python - Google (Medium)
  • Find most co‑purchased product pairs in SQL - Google (Medium)