R Programming Essentials: Data Manipulation & Visualization
R Data Handling Essentials
Importing Data
Importing CSV Files
Use
read.csv()to import a Comma Separated Values file:df <- read.csv("filename.csv")
Importing Stata .dta Files
Requires the
havenpackage:library(haven) df <- read_dta("stata_file.dta")
Managing Your Environment
Setting and Checking the Working Directory
Set:
setwd("your/path/here")Get:
getwd()
Data Frame Basics
Accessing a Column
Access a column using the
$operator:df$column_name
Calculating Column Mean
Calculate the mean of a numeric column:
Market Structures: Competition, Monopoly, and Monopolistic Forms
Perfect Competition: Characteristics & Output
Characteristics of Perfect Competition
- Many Buyers and Sellers: No single firm or consumer can influence the market price.
- Homogeneous Products: All firms sell identical goods, making them perfect substitutes.
- Free Entry and Exit: No barriers prevent firms from entering or exiting the market.
- Perfect Information: Buyers and sellers have full knowledge of prices and product quality.
- Price Takers: Firms accept the market price determined by industry supply
Economic Production Functions and Cost Relationships
Key Relationships in Production and Costs
APL and AVC Relationship
If APL (Average Product of Labor) is growing, AVC (Average Variable Cost) and ATC (Average Total Cost) are decreasing. There is an inverse relationship between APL and AVC (and ATC). Specifically, you can check that:
AVC = w / APL
MC = w / MPL
Example Calculation: AVC = 2 / (0.25L) = 2 / (0.25 ยท 2Q0.5) = 4 / Q0.5
MPL and MC Relationship
If MPL (Marginal Product of Labor) is growing, MC (Marginal Cost) is decreasing. There is an inverse
Read MoreCore Economic Concepts: Systems, Models, Production, and Demand
Economic Systems and Resource Allocation
- An allocation of resources answers three fundamental economic questions: what to produce, how to produce, and for whom to produce.
- Societies employ different processes to answer these questions, varying in the degree of centralized decision-making.
- The optimal process for allocating resources depends on a society’s specific goals.
- The method a society uses to answer these three economic questions defines its economic system. Economic systems are identified by
Mastering Elasticity: Demand, Supply, and Market Dynamics
Test your understanding of economic elasticity concepts with these practice questions and answers. This section covers various aspects of price, income, and cross elasticity, along with their implications for market behavior and total revenue.
Price and Income Elasticity Fundamentals
Which of the following is not characteristic of the demand for a commodity that is elastic?
D. The elasticity coefficient is less than one.
The price elasticity of demand for widgets is 0.80. Assuming no change in the demand
Key Economic Concepts and Market Principles
Economic Profit Calculation
Economic Profit: This is the difference between total revenue and both explicit and implicit costs.
Formula: Economic Profit = Revenue – Explicit Costs – Implicit Costs
Example: A firm earns $500,000 in revenue, incurs explicit costs of $300,000, and implicit costs of $50,000.
Economic Profit = $500,000 – $300,000 – $50,000 = $150,000 (positive economic profit).
Present Value (PV) Explained
Present Value (PV): The current value of a future sum of money or stream of cash flows,
Read More