create random Number

Hello,

How can you create random numbers in the software and calculate a mean value in pairs from these random numbers and create a histogram?

I already tried it this way but i am not very expirienced in the use of R.

runif (1000, min=-1, max=1)
a <- runif (1000, min=-1, max=1)
hist (a)
fivenum (a, na.rn= True)
sd (a, na.rn= True)

runif (1000, min=-0.1, max=1)
b <- runif (1000, min=-0.1, max=1)

hist (b)
data.frame(a, b)
x <- data.frame (a, b)

many thanks

set.seed(42)
library(tidyverse)

(d1 <-  tibble(
  a = runif(1000,min=-1,max=1),
  b = runif(1000,min=-1,max=1))
)

(d2 <- mutate(d1,
              pair_mean =(a+b)/2))

ggplot(d2,aes(x=pair_mean)) +
  geom_histogram(bins=25)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.