library(mosaic)
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
library(mosaicCalc)
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
បំរេាប
p <- function(q) {(10 + 0.5 * q)~q}
C <- function(q) {(100 + 10 * q + 0.5 * q^2)~q}
1. រកអនុគមន៍ចំណូល
R <- makeFun((10 + 0.5 * q) ~ q)
R
## function (q)
## (10 + 0.5 * q)
2. រកអនុគមន៌ប្រាក់ចំណេញ
P <- makeFun ((10 + 0.5 * q)-(100 + 10 * q + 0.5 * q^2)~q)
P
## function (q)
## (10 + 0.5 * q) - (100 + 10 * q + 0.5 * q^2)
3. សង់ក្រាប
library(ggplot2)
q_vals <- seq(-10, 10, length.out = 100)
C_vals <- 100 + 10 * q_vals + 0.5 * q_vals^2
R_vals <- 10 + 0.5 * q_vals
df <- data.frame(q = q_vals, Cq = C_vals, Rq = R_vals)
ggplot(df, aes(x = q)) +
geom_line(aes(y = Cq, color = "C(q)"), size = 1) +
geom_line(aes(y = Rq, color = "R(q)"), size = 1) +
geom_hline(yintercept = 0, linetype = "dashed", color = "black") +
geom_vline(xintercept = 0, linetype = "dashed", color = "yellow") +
labs(title = "Graphs of C(q) and R(q)", x = "q", y = "Function Values") +
scale_color_manual(values = c("C(q)" = "blue", "R(q)" = "red")) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
