<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Pode ser que não seja o mais rápido, mas resolve<div class=""><br class=""></div><div class=""><div class="">ID <- c(1, 1, 1, 1, 2, 2, 3, 3, 3)</div><div class="">NOME <- c("xpto", "xpto", "xpto", "xpto", "tpzo", "tpzo", "capr", "capr", "capr")</div><div class="">IDADE <- c(1, 1, 1, 1, 57, 57, 81, 81, 81)</div><div class="">SEXO <- c("M", "M", "M", "M", "M", "M", "F", "F", "F")</div><div class="">CAUSA <- c("A", "B", "C", "D", "E", "F","G","H","I")</div><div class=""><br class=""></div><div class="">df <- data.frame(ID, NOME, IDADE, SEXO, CAUSA)</div><div class=""><br class=""></div><div class="">df</div><div class=""><br class=""></div><div class="">names <- unique(df$NOME)</div><div class="">id_l = list()</div><div class="">nome_l = list()</div><div class="">idade_l = list()</div><div class="">sexo_l = list()</div><div class="">causa_l = list()</div><div class=""><br class=""></div><div class="">for (i in 1:length(names)) {</div><div class=""> name = names[i]</div><div class=""> block = as.data.frame(df[df$NOME == name, ])</div><div class=""> id = block$ID[1]</div><div class=""> nome = block$NOME[1]</div><div class=""> idade = block$IDADE[1]</div><div class=""> sexo = block$SEXO[1]</div><div class=""> causa = vector()</div><div class=""> for (j in 1:nrow(block)) {</div><div class=""> causa = paste0(causa,block$CAUSA[j], sep = ',')</div><div class=""> }</div><div class=""> print(causa)</div><div class=""> id_l[[paste0(i)]] <- id</div><div class=""> nome_l[[paste0(i)]] <- nome</div><div class=""> idade_l[[paste0(i)]] <- idade</div><div class=""> sexo_l[[paste0(i)]] <- sexo</div><div class=""> causa_l[[paste0(i)]] <- causa</div><div class="">}</div><div class=""><br class=""></div><div class="">unlist(causa_l)</div><div class=""><br class=""></div><div class="">dfNew <- data.frame(ID = unlist(id_l), NOME= unlist(nome_l), IDADE= unlist(idade_l), SEXO= unlist(sexo_l), CAUSA= unlist(causa_l))</div><div class="">print(dfNew)</div><div class=""><br class=""></div><div class="">Abraço</div><div class=""><br class=""></div><div class="">daniel</div><div class=""><br class=""></div><div class=""><div style="orphans: 2; widows: 2;" class="">Daniel Tiezzi, MD, PhD</div><div style="orphans: 2; widows: 2;" class="">Professor Associado</div><div style="orphans: 2; widows: 2;" class="">Departamento de Ginecologia e Obstetrícia</div><div style="orphans: 2; widows: 2;" class="">Setor de Mastologia e Oncologia Ginecológica</div><div style="orphans: 2; widows: 2;" class="">Faculdade de Medicina de Ribeirão Preto - USP</div><div style="orphans: 2; widows: 2;" class="">Tel.: 16 3602-2488</div><div style="orphans: 2; widows: 2;" class=""><a href="mailto:dtiezzi@fmrp.usp.br" class="">e-mail: dtiezzi@fmrp.usp.br</a></div></div><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 29, 2018, at 10:30 AM, Paulo Eduardo de Mesquita por (R-br) <<a href="mailto:r-br@listas.c3sl.ufpr.br" class="">r-br@listas.c3sl.ufpr.br</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">ID <- c(1, 1, 1, 1, 2, 2, 3, 3, 3)</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">NOME <- c("xpto", "xpto", "xpto", "xpto", "tpzo", "tpzo", "capr", "capr", "capr")</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">IDADE <- c(1, 1, 1, 1, 57, 57, 81, 81, 81)</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">SEXO <- c("M", "M", "M", "M", "M", "M", "F", "F", "F")</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">CAUSA <- c("A", "B", "C", "D", "E", "F","G","H","I")</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">df <- data.frame(ID, NOME, IDADE, SEXO, CAUSA)</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">df</div></div></blockquote></div><br class=""></div></body></html>