Expt1.ipynb - JupyterLab
Expt1.ipynb - JupyterLab
Warning message:
"package 'ggplot2' is in use and will not be installed"
# Creating Variables
x <- 10 # Assign value 10 to x
y <- 5
z <- x + y # Add two variables
# Data Types
a <- 10L # Integer
b <- 3.14 # Numeric (Double)
c <- TRUE # Logical (Boolean)
d <- "R Programming" # Character string
# Built-in Help
?mean # View documentation for 'mean' function
8
2
15
1.66666666666667
25
'integer'
'character'
localhost:8888/lab/tree/expt1.ipynb 1/5
10/20/24, 12:13 PM expt1
Arithmetic Mean
Description
Generic function for the (trimmed) arithmetic mean.
Usage
mean(x, ...)
## Default S3 method:
mean(x, trim = 0, na.rm = FALSE, ...)
Arguments
an R object. Currently there are methods for numeric/logical vectors and date, date-
x time and time interval objects. Complex vectors are allowed for trim = 0 , only.
the fraction (0 to 0.5) of observations to be trimmed from each end of x before the
trim mean is computed. Values of trim outside that range are taken as the nearest
endpoint.
Value
If trim is zero (the default), the arithmetic mean of the values in x is computed, as a
numeric or complex vector of length one. If x is not logical (coerced to numeric), numeric
(including integer) or complex, NA_real_ is returned, with a warning.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth &
Brooks/Cole.
See Also
weighted.mean , mean.POSIXct , colMeans for row and column means.
localhost:8888/lab/tree/expt1.ipynb 2/5
10/20/24, 12:13 PM expt1
Examples
x <- c(0:10, 50)
xm <- mean(x)
c(xm, mean(x, trim = 0.10))
In [20]: #Graphics in R
# Scatter plot using the built-in 'mtcars' dataset
plot(mtcars$wt, mtcars$mpg,
main = "Scatter Plot of Weight vs MPG",
xlab = "Weight", ylab = "Miles Per Gallon",
col = "blue", pch = 19) # pch: point shape
# Access elements
v[1] # First element
v[2:4] # Elements from 2 to 4
v[c(1, 5)] # Elements at positions 1 and 5
10
20 · 30 · 40
10 · 50
localhost:8888/lab/tree/expt1.ipynb 3/5
10/20/24, 12:13 PM expt1
# Access columns
df$Name # Get the 'Name' column
90
A data.frame: 2 × 3
2 Bob 30 90
3 Charlie 35 88
A data.frame: 6 × 11
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
Mazda RX4
21.0 6 160 110 3.90 2.875 17.02 0 1 4
Wag
Hornet 4
21.4 6 258 110 3.08 3.215 19.44 1 0 3
Drive
Hornet
18.7 8 360 175 3.15 3.440 17.02 0 0 3
Sportabout
localhost:8888/lab/tree/expt1.ipynb 4/5
10/20/24, 12:13 PM expt1
localhost:8888/lab/tree/expt1.ipynb 5/5