1. Home
  2. /
  3. R
  4. /
  5. Shopping Cart

Shopping Cart - R Typing CST Test

Loading…

Shopping Cart — R Code

Adds and removes items in a shopping cart with total cost.

cart <- data.frame(Item=character(), Price=numeric())
addItem <- function(item, price) { cart <<- rbind(cart, data.frame(Item=item, Price=price)); print(cart) }
removeItem <- function(index) { cart <<- cart[-index,]; print(cart) }

# Simulate actions
addItem('Apple', 2)
addItem('Banana', 3)
removeItem(1)

R Language Guide

R is a high-level, interpreted programming language and environment specifically designed for statistical computing, data analysis, and graphical representation. It provides a rich ecosystem of packages and functions for statistical modeling, data visualization, and reproducible research.

Primary Use Cases

  • ▸Statistical modeling and hypothesis testing
  • ▸Data visualization and reporting
  • ▸Machine learning and predictive analytics
  • ▸Bioinformatics and genomic data analysis
  • ▸Financial and econometric analysis

Notable Features

  • ▸Extensive statistical functions and packages
  • ▸High-quality graphics with ggplot2 and base plotting
  • ▸Vectorized operations for efficient computation
  • ▸Data frame and tibble structures for data manipulation
  • ▸CRAN repository with thousands of contributed packages

Origin & Creator

Created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, in 1993 as an open-source alternative to S and S-PLUS.

Industrial Note

R is heavily used in statistical research, data science, machine learning experiments, and academic publications where reproducible data analysis is critical.

More R Typing Exercises

R Counter and Theme ToggleR Random Number GeneratorR Todo ListR Dice RollerR Countdown TimerR Prime CheckerR Temperature ConverterR Name GreetingR Stopwatch

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher