Skip to content

Instantly share code, notes, and snippets.

@Diegow3b
Created September 20, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Diegow3b/43743af3f6a685870732a94d99450d55 to your computer and use it in GitHub Desktop.
Save Diegow3b/43743af3f6a685870732a94d99450d55 to your computer and use it in GitHub Desktop.
#Pequeno script para pegar 100 valores aleatorios entre as strings"HAS","Has","has","DM","Dm"
pool <- c("HAS","Has","has","DM","Dm")
index <- sample(1:5,100,replace=T) #Amostra de 100 valores entre 1 e 5
comorb <- character(length=100) #Declara variavel comorb
#For loop para selecionar um item da lista conforme numero aleatorio sorteado
for (i in 1:100){
comorb[i] <- pool[index[i]]
}
id <- seq(1:100) #Identificacao para cada caso
comorb.data <- as.data.frame(cbind(comorb,id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment