홈>
옵션 목록에서 더미 데이터를 만들려고합니다 :
library('stringr')
#Generate a load of strings
line <- list(x1 = 10, x2 = 30,x3="There is no intestinal metaplasia, dysplasia or malignancy",x4="No Helicobacter are seen",x5="There is some ulceration",x6="There is no intercellular oedema in the surface epithelium",x7="PASstaining shows occasional spores, consistent with candida",x8="No herpetic viral inclusions are seen",x9="There is no dysplasia and no invasive carcinoma",x10="There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen",x11="The appearances are consistent with the endoscopic diagnosis of Barrett's oesophagus with active chronic inflammation",x12="The biopsies of oesophageal squamous mucosa show surface erosion and active chronic inflammation",x13="Numerous Candida spores and hyphae are present admixed with ulcer slough",x14="There is reactive basal cell hyperplasia and mild inflammatory epithelial atypia",x15="There is no significant increase in intraepithelialeosinophils",x16="No granulomas or viral inclusions are seen",x17="The appearances are those of Candida oesophagitis",x18="Neither dysplasia nor malignancy is seen",x19="The appearances are consistent with, but not specific for Barrett's (columnar lined) oesophagus")
listofResults<-unlist(sample(line,2,replace=T))
list.of.samples <- replicate(1000, paste(sample(1:10,1), "specimens collected the largest measuring", sample(1:5,1) ,"x", sample(1:5,1) ,"x", sample(1:5,1), "mm and the smallest", sample(1:5,1) ,"x", sample(1:5,1) ,"x", sample(1:5,1), "mm"), simplify=FALSE)
그런 다음 10 개의 데이터 샘플을 만들고 싶습니다. 내가 실행하면 :
#Merge the strings together randomly
histop<-paste (sample(list.of.samples,1,replace=T),str_c(sample(line,sample(3:10,1),replace=T),collapse='.'))
그런 다음 무작위로 생성 된 문자열을 잘 얻었으며 예상대로 문자열을 실행할 때마다 변경됩니다. 실행하지만
rep(histop,10)
동일한 결과는 10 번입니다. 그래서 나는 그것을 함수로 대답하려고 노력했다.
histop<-function(){
paste (sample(list.of.samples,1,replace=T),str_c(sample(line,sample(3:10,1),replace=T),collapse='.'))
}
rep(histop(),10)
그러나 같은 결과를 얻습니다. 10 개의 다른 줄을 어떻게 구할 수 있습니까?
-
답변 # 1
관련 자료
- Rust - 녹 - 메모리에서 'string'과 'str'은 어떻게 다릅니 까?
- Python Pandas에서 문자열을 다른 열로 분할하는 방법
- java - 문자열의 각 하위 문자열에 문자열이있는 횟수를 확인하는 방법은 무엇입니까?
- python - 두 개의 다른 데이터 프레임에서 동일한 문자열로 시작하는 행 곱하기
- flutter - 두 개의 다른 목록을 추가하여 세 번째 목록 생성
- mysql - 각 행에 다른 값이 첨부 된 행을 여러 번 선택하는 방법은 무엇입니까?
- Java의 정규식을 사용하여 문자열이 두 자리 숫자로 끝나는 지 확인하십시오
- typescript에서 보간 된 문자열 내부의 값 서식 지정
- android - 동일한 문자열에 대해 SQLite의 길이가 Java의 길이 방법과 다른 값을 반환합니까?
- python - 해당 문자열이 나타나는 횟수에 대한 새 열 만들기
- Java 15 및 Java 11에서 Java 문자열 비교가 다르게 작동하는 이유
- python - 다른 팬더 열의 값을 기반으로 문자열을 바꾸는 방법
- Angular Test에서 다른 매개 변수로 동일한 기능을 여러 번 감시
- 문자열에서 3 개의 다른 문자열을 검색하는 정규식
- python - pandas - 크기가 다른 두 데이터 프레임의 문자열 열 비교
- Dart에서 문자열을 다양한 런타임 유형 목록으로 변환하는 가장 좋은 방법은 무엇입니까?
- python - Pandas에서 총합계를 생성하기 위해 다른 열에서 Sum 및 Mean 수행
- python - 문자열 곱셈에서 바이트 코드가 다른 이유는 무엇입니까?
- command line - 동일한 문자열에 대해 두 가지 다른 md5 해시 결과를 얻는 방법은 무엇입니까?
- python - 이 두 개의 다른 목록을 생성하기 위해 한 줄 생성기 표현식을 어떻게 만들 수 있습니까?
트렌드
- OpenCv의 폴더에서 여러 이미지 읽기 (python)
- 파이썬 셀레늄 모든 "href"속성 가져 오기
- git commit - 자식 - 로컬 커밋 된 파일에 대한 변경을 취소하는 방법
- html - 자바 스크립트 - 클릭 후 변경 버튼 텍스트 변경
- JSP에 대한 클래스를 컴파일 할 수 없습니다
- javascript - 현재 URL에서 특정 div 만 새로 고침/새로 고침
- jquery - JavaScript로 현재 세션 값을 얻으시겠습니까?
- javascript - swiperjs에서 정지, 재생 버튼 추가
- vue.js - axios를 사용하여 서버에 이미지를 업로드하는 방법
- python - 문자열에서 특정 문자 제거
알았습니다. rep 대신 replicate을 사용해야합니다. 이것에 대해 읽어야하지만 replicate는 실제로 라인을 실행하는 반면 rep은 한 번 실행 한 다음 결과를 복사합니다.