0

I am trying to create 200 samples with mean = 3.5 and SD of 0.25 I do this with the following R Command :

set.seed(9)
data1 <- replicate(200, rnorm(10,3.5,0.25), simplify=FALSE)

I got data1 having 200 samples of size 10.

Now I want to find the minimum value in each sample. I am not able to figure out how do I do it in R. Please Help

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
dper
  • 884
  • 1
  • 8
  • 31

2 Answers2

0

Here's is a tidyverse solution that returns a data frame with the sample ID and minimum value of each sample:

library(tidyverse)

maximum.value <- map(data1, min) %>% 
    unlist(recursive = FALSE) %>% 
    enframe()
  • map applies the min function to each element of the data1 list
  • unlist simplifies the list structure to a vectors
  • enframe converts the atomic vectures into a two-column data frame
CFB
  • 109
  • 6
0

You could turn the list into a data.frame using

df <- data.frame(matrix(unlist(data1), nrow=200, byrow=T),stringsAsFactors=FALSE)

and then calculate the minimum value for each row using the apply function

MinumumValues <- apply(df, 1, FUN=min)

It returns is a data.frame in which each row is the minimum value of the samples created.