<div dir="ltr">Corrigindo...<div><br></div><div>Tinha um erro no cálculo do nlink, que retornava sempre 4...</div><div><br></div><div>Segue a modificação.<br><div class="gmail_extra"><br><div class="gmail_extra"><font face="courier new, monospace"># <BEGIN></font></div>
<div class="gmail_extra"><font face="courier new, monospace">#install.packages('repmis') </font></div><div class="gmail_extra"><font face="courier new, monospace">library(repmis) </font></div><div class="gmail_extra">
<font face="courier new, monospace">FinURL <- paste0("<a href="https://dl.dropboxusercontent.com/u/61883020/2013-08-25-r-br.csv">https://dl.dropboxusercontent.com/u/61883020/2013-08-25-r-br.csv</a>") </font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">data <- repmis::source_data(FinURL, sep = ",", header = TRUE) </font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">dim(data); head(data)</font></div><div class="gmail_extra"><font face="courier new, monospace"><br>
</font></div><div class="gmail_extra"><font face="courier new, monospace">data$new = 0; data$prop = 0; data$medlnk= 0; data$nlink=0</font></div><div class="gmail_extra"><font face="courier new, monospace">str(data)</font></div>
<div class="gmail_extra"><font face="courier new, monospace">for (i in 1:length(data[,1])){ # para cada linha</font></div><div class="gmail_extra"><font face="courier new, monospace"> col = data[i,2]+2 # coluna do grupo dado</font></div>
<div class="gmail_extra"><font face="courier new, monospace"> dado = data[i,col] # dado para a coluna calculada</font></div><div class="gmail_extra"><font face="courier new, monospace"> nlink = length(which(data[i,3:6]>0)) # núm de grupos com valor (ligações)</font></div>
<div class="gmail_extra"><font face="courier new, monospace"> data[i,8] = dado # aloja o dado</font></div><div class="gmail_extra"><font face="courier new, monospace"> data[i,9] = dado/(data[i,7]-dado) # total - dado do grupo</font></div>
<div class="gmail_extra"><font face="courier new, monospace"> data[i,10] = data[i,7]/nlink # total/núm ligações</font></div><div class="gmail_extra"><font face="courier new, monospace"> data[i,11] = nlink</font></div>
<div class="gmail_extra"><font face="courier new, monospace">}</font></div><div class="gmail_extra"><font face="courier new, monospace">tail(data)</font></div><div class="gmail_extra"><font face="courier new, monospace">#<END></font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace"><div class="gmail_extra">> tail(data)</div><div class="gmail_extra"> pessoa pessoa.grupo g.1 g.2 g.3 g.4 tc new prop medlnk nlink</div>
<div class="gmail_extra">15 q 3 8 49 157 17 231 157 2.1216216 57.75000 4</div><div class="gmail_extra">16 r 2 27 138 33 27 225 138 1.5862069 56.25000 4</div><div class="gmail_extra">
17 s 2 32 82 25 77 216 82 0.6119403 54.00000 4</div><div class="gmail_extra">18 t 3 12 16 183 3 214 183 5.9032258 53.50000 4</div><div class="gmail_extra">19 u 4 0 54 33 90 212 90 0.7377049 70.66667 3</div>
<div class="gmail_extra">20 v 3 0 0 135 11 211 135 1.7763158 105.50000 2</div></font></div><div class="gmail_extra"><br></div><div><br></div><div class="gmail_quote"><br></div><div><br></div>-- <br>
<div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>Dourados, MS - [22 16.5'S, 54 49'W]<br>
</div>
</div></div></div>