r - Generate an interpolated string n times so I get n different answers -


i trying create dummy data list of options:

library('stringr') #generate load of strings line <- list(x1 = 10, x2 = 30,x3="there no intestinal metaplasia, dysplasia or malignancy",x4="no helicobacter seen",x5="there ulceration",x6="there no intercellular oedema in surface epithelium",x7="passtaining shows occasional spores, consistent candida",x8="no herpetic viral inclusions seen",x9="there no dysplasia , no invasive carcinoma",x10="there mild regenerative epithelial change, neither dysplasia nor malignancy seen",x11="the appearances consistent endoscopic diagnosis of barrett's oesophagus active chronic inflammation",x12="the biopsies of oesophageal squamous mucosa show surface erosion , active chronic inflammation",x13="numerous candida spores , hyphae present admixed ulcer slough",x14="there reactive basal cell hyperplasia , mild inflammatory epithelial atypia",x15="there no significant increase in intraepithelialeosinophils",x16="no granulomas or viral inclusions seen",x17="the appearances of candida oesophagitis",x18="neither dysplasia nor malignancy seen",x19="the appearances consistent with, not specific barrett's (columnar lined) oesophagus") listofresults<-unlist(sample(line,2,replace=t)) list.of.samples <- replicate(1000, paste(sample(1:10,1), "specimens collected largest measuring", sample(1:5,1) ,"x", sample(1:5,1) ,"x", sample(1:5,1), "mm , smallest", sample(1:5,1) ,"x", sample(1:5,1) ,"x", sample(1:5,1), "mm"), simplify=false) 

i want create 10 samples of data. if run:

#merge strings randomly histop<-paste (sample(list.of.samples,1,replace=t),str_c(sample(line,sample(3:10,1),replace=t),collapse='.'))    

then randomly constructed string fine, , expected changes every time run it. running

rep(histop,10) 

just results in same result 10 times. tried rep function

histop<-function(){   paste (sample(list.of.samples,1,replace=t),str_c(sample(line,sample(3:10,1),replace=t),collapse='.'))    } rep(histop(),10) 

but same result. how can 10 different strings?

ok figured out. need use replicate instead of rep. ill need read think replicate runs line whereas, rep runs once , copies result.

replicate(20,paste (sample(list.of.samples,1,replace=t),str_c(sample(line,sample(3:10,1),replace=t),collapse='.')))    

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -