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.

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.

Loading coding console...