Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

R Maximum and Minimum:


Certainly! In R, you can find the maximum and minimum values in a dataset or a vector using the max() and min() functions, respectively.

Example: Suppose we have a vector of numbers representing daily temperatures in Celsius for a week:

Example

# Daily temperatures in Celsius
temperatures <- c(20, 22, 25, 18, 23, 21, 24)

# Find the maximum temperature
max_temp <- max(temperatures)
print(paste("Maximum temperature:", max_temp, "Celsius"))

# Find the minimum temperature
min_temp <- min(temperatures)
print(paste("Minimum temperature:", min_temp, "Celsius"))

In this example:

When you run this code, it will print the maximum and minimum temperatures for the week.


Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java