<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span><div>Caro Benilton,</div><div><br></div><div style="background-color: transparent;">Segue um exemplo mas próximo do real.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;">library(RColorBrewer)</div><div><br></div><div>dfm <- data.frame(Solo=rep(c("LVA", "LVD"), 3), col=rep("#000000", 6))</div><div><br></div><div>mypalette <- brewer.pal(3,"Greys")</div><div><br></div><div>var <- data.frame(wrong=unique(dfm$Sol), right=mypalette[2:3])</div><div><br></div><div>for (i in seq(along = dimnames(var)[[1L]])){</div><div> 
 dfm[,2][which(dfm[,1] == var[[i,1]])] <- var[[i,2]]</div><div>}</div></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> </div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">Obrigado.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font face="times new roman, new york, times, serif">Alisson Lucrécio da Costa</font><br></div>  <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Benilton
 Carvalho <beniltoncarvalho@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Alisson Lucrecio <alissonluc@yahoo.com.br> <br><b><span style="font-weight: bold;">Cc:</span></b> r-br <r-br@listas.c3sl.ufpr.br> <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, May 22, 2013 1:27 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [R-br] Duvida plot base1<br> </font> </div> <div class="y_msg_container"><br>novamente.... exemplo reproduzivel.<br><br>bom trabalho<br><br>Em 22 de maio de 2013 12:49, Alisson Lucrecio<br><<a ymailto="mailto:alissonluc@yahoo.com.br" href="mailto:alissonluc@yahoo.com.br">alissonluc@yahoo.com.br</a>> escreveu:<br>> O exemplo mostrei coincidiu de ser 2 e 2, mas o meu problema é com um numero<br>> diferente (ex. dfm com 36 lina e na var ex, 4). Assim teria que ficar<br>> replicando os meus data.frames (var) para coincidir. Se consegui resolver<br>>
 por outra forma ficaria muito mais fácil.<br>><br>> Obrigado.<br>><br>> Alisson Lucrécio da Costa<br>> ________________________________<br>> From: Benilton Carvalho <<a ymailto="mailto:beniltoncarvalho@gmail.com" href="mailto:beniltoncarvalho@gmail.com">beniltoncarvalho@gmail.com</a>><br>> To: Alisson Lucrecio <<a ymailto="mailto:alissonluc@yahoo.com.br" href="mailto:alissonluc@yahoo.com.br">alissonluc@yahoo.com.br</a>><br>> Cc: r-br <<a ymailto="mailto:r-br@listas.c3sl.ufpr.br" href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a>><br>> Sent: Wednesday, May 22, 2013 12:36 PM<br>><br>> Subject: Re: [R-br] Duvida plot base1<br>><br>> Alisson,<br>><br>> o que exatamente vc quer fazer e' substituir  a coluna 'col'  de dfm<br>> pela coluna 'right' de var? E' isso?<br>><br>> pq nao usar merge?<br>><br>> saida = merge(dfm, var, by.x='Solo',
 by.y='wrong')<br>> saida[[2]] = NULL<br>> names(saida) = names(dfm)<br>><br>> ou apenas o match?<br>><br>> i = match(dfm$Solo, var$wrong)<br>> dfm$col = var$wrong[i]<br>><br>> ?<br>><br>> b<br>><br>> Em 22 de maio de 2013 10:44, Alisson Lucrecio<br>> <<a ymailto="mailto:alissonluc@yahoo.com.br" href="mailto:alissonluc@yahoo.com.br">alissonluc@yahoo.com.br</a>> escreveu:<br>>> Caro Benilton,<br>>><br>>> Segue um exemplo reproduzível.<br>>><br>>><br>>> library(RColorBrewer)<br>>><br>>> dfm <- data.frame(Solo=c("LVA", "LVD"), col=rep("#000000", 2))<br>>><br>>> mypalette <- brewer.pal(3,"Greys")<br>>><br>>> var <- data.frame(wrong=unique(dfm$Sol),<br>>>                  right=mypalette[2:3])<br>>><br>>> for (i in seq(along = dimnames(var)[[1L]])){<br>>> 
 dfm[,2][which(dfm[,1] == var[[i,1]])] <- var[[i,2]]<br>>> }<br>>><br>>> Obrigado<br>>><br>>><br>>> Alisson Lucrécio da Costa<br>>> ________________________________<br>>> From: Benilton Carvalho <<a ymailto="mailto:beniltoncarvalho@gmail.com" href="mailto:beniltoncarvalho@gmail.com">beniltoncarvalho@gmail.com</a>><br>>> To: r-br <<a ymailto="mailto:r-br@listas.c3sl.ufpr.br" href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a>>; Alisson Lucrecio<br>>> <<a ymailto="mailto:alissonluc@yahoo.com.br" href="mailto:alissonluc@yahoo.com.br">alissonluc@yahoo.com.br</a>><br>>> Sent: Wednesday, May 22, 2013 10:26 AM<br>>> Subject: Re: [R-br] Duvida plot base1<br>>><br>>> dificil, muito dificil, ser preciso na ausencia de um exemplo<br>>> reproduzivel...<br>>><br>>> mas, acho que o problema resume-se 'a falta de aspas em torno do
 valor...<br>>><br>>> blah <- '#D9D9D9'<br>>><br>>> b<br>>><br>>> Em 22 de maio de 2013 10:16, Alisson Lucrecio<br>>> <<a ymailto="mailto:alissonluc@yahoo.com.br" href="mailto:alissonluc@yahoo.com.br">alissonluc@yahoo.com.br</a>> escreveu:<br>>>> Caro Colegas,<br>>>> Bom dia.<br>>>><br>>>> Eu estou tentando construir uma PCA no base, mas estou entendo alguns<br>>>> problema.<br>>>><br>>>> Tenho uma data.frame com uma célula com valor "#F7F7F7" (dm.x[,1+i]) e<br>>>> gostaria de substitui-la por outro valor de acordo com o valor de uma<br>>>> célula<br>>>> especifica,<br>>>><br>>>> assim tenho:<br>>>><br>>>> dm.x[,2][which(dm.x[,1] == 0)] <- #D9D9D9<br>>>><br>>>><br>>>> Erro.<br>>>><br>>>> Mensagens de aviso perdidas:<br>>>>
 In `[<-.factor`(`*tmp*`, which(dm.x[, 1 + i] == var[[ii, 1]]), value =<br>>>> c(NA_integer_,  :<br>>>>  invalid factor level, NAs generated<br>>>><br>>>> Obrigando<br>>>><br>>>> Alisson Lucrécio da Costa<br>>>><br>>>> _______________________________________________<br>>>> R-br mailing list<br>>>> <a ymailto="mailto:R-br@listas.c3sl.ufpr.br" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>>>> <a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>>>> Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça<br>>>> código<br>>>> mínimo reproduzível.<br>>><br>><br><br></div> </div> </div>  </div></body></html>