jeudi 21 septembre 2017

R: If statement for multiple conditions based on list/vector

Say I have an n-vector that I want to apply an if-condition based on multiple conditions stored in another vector/list, how can I loop and assign the names to my original vector?

set.seed(1234)

# Data
b <- rpois(100, 4)

# Condition
a <- 1:10
names(a) <- paste0(seq(10,100, by = 10),'%')

Aucun commentaire:

Enregistrer un commentaire