<div dir="ltr"><div>Uma forma de fazer:</div><div><br></div><div>novo_df <- df</div><div>novo_df[novo_df$ToKeep == F,c("value1","value2")] <- NA</div><div><br></div><div>Com novo_df$ToKeep == F você escolhe as linhas que quer modificar, assim você não precisa usar IF<br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-19 21:52 GMT-02:00 Thiago V. dos Santos <span dir="ltr"><<a href="mailto:thi_veloso@yahoo.com.br" target="_blank">thi_veloso@yahoo.com.br</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12px"><div dir="ltr"><span>Olá pessoal,</span></div><div dir="ltr"><span><br></span></div><div dir="ltr"><span>Considerem o seguinte data.frame:</span></div><div dir="ltr"><span><br></span></div><div dir="ltr">df <- structure(list(date = structure(c(1251350100.288, 1251351900, </div><div dir="ltr">1251353699.712, 1251355500.288, 1251357300, 1251359099.712), class = c("POSIXct", </div><div dir="ltr">"POSIXt")), mix.ratio.csi = c(442.78316237477, 436.757082063885, </div><div dir="ltr">425.742872761246, 395.770804307671, 386.758335309866, 392.115887652156</div><div dir="ltr">), mix.ratio.licor = c(447.141491945547, 441.319548211994, 430.854166343173, </div><div dir="ltr">402.232640566763, 393.683007533694, 398.388336602215), ToKeep = c(FALSE, </div><div dir="ltr">FALSE, TRUE, TRUE, TRUE, TRUE)), .Names = c("date", "value1", </div><div dir="ltr">"value2", "ToKeep"), index = structure(integer(0), ToKeep = c(1L, </div><div dir="ltr">2L, 8L, 52L, 53L, 54L, 55L, 85L, 86L, 87L, 88L, 89L, 92L, 93L, </div><div dir="ltr">94L, 95L, 96L, 97L, 98L, 99L, 100L, 102L, 103L, 105L, 106L, 192L, </div><div dir="ltr">193L, 220L, 223L, 225L, 228L, 229L, 260L, 263L, 264L, 265L, 266L, </div><div dir="ltr">267L, 305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, </div><div dir="ltr">315L, 352L, 353L, 354L, 375L, 376L, 378L, 379L, 380L, 383L, 411L, </div><div dir="ltr">412L, 413L, 414L, 415L, 416L, 418L, 419L, 445L, 453L, 463L, 464L, </div><div dir="ltr">465L, 466L, 467L, 468L, 497L, 504L, 547L, 548L, 549L, 586L, 589L, </div><div dir="ltr">630L, 631L, 632L, 633L, 634L, 635L, 636L, 644L, 645L, 646L, 647L, </div><div dir="ltr">648L, 649L, 650L, 651L, 674L, 675L, 676L, 677L, 678L, 682L, 687L, </div><div dir="ltr">690L, 691L, 724L, 725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, </div><div dir="ltr">733L, 734L, 735L, 736L, 739L, 740L, 741L, 742L, 768L, 771L, 772L, </div><div dir="ltr">773L, 774L, 775L, 776L, 777L, 778L, 779L, 3L, 4L, 5L, 6L, 7L, </div><div dir="ltr">9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, </div><div dir="ltr">22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, </div><div dir="ltr">35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, </div><div dir="ltr">48L, 49L, 50L, 51L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, </div><div dir="ltr">65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, </div><div dir="ltr">78L, 79L, 80L, 81L, 82L, 83L, 84L, 90L, 91L, 101L, 104L, 107L, </div><div dir="ltr">108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, </div><div dir="ltr">119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L, </div><div dir="ltr">130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L, </div><div dir="ltr">141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, </div><div dir="ltr">152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, </div><div dir="ltr">163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, </div><div dir="ltr">174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L, </div><div dir="ltr">185L, 186L, 187L, 188L, 189L, 190L, 191L, 194L, 195L, 196L, 197L, </div><div dir="ltr">198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, </div><div dir="ltr">209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, </div><div dir="ltr">221L, 222L, 224L, 226L, 227L, 230L, 231L, 232L, 233L, 234L, 235L, </div><div dir="ltr">236L, 237L, 238L, 239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, </div><div dir="ltr">247L, 248L, 249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, </div><div dir="ltr">258L, 259L, 261L, 262L, 268L, 269L, 270L, 271L, 272L, 273L, 274L, </div><div dir="ltr">275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 284L, 285L, </div><div dir="ltr">286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L, 295L, 296L, </div><div dir="ltr">297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 316L, 317L, 318L, </div><div dir="ltr">319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, </div><div dir="ltr">330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, </div><div dir="ltr">341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 351L, </div><div dir="ltr">355L, 356L, 357L, 358L, 359L, 360L, 361L, 362L, 363L, 364L, 365L, </div><div dir="ltr">366L, 367L, 368L, 369L, 370L, 371L, 372L, 373L, 374L, 377L, 381L, </div><div dir="ltr">382L, 384L, 385L, 386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L, </div><div dir="ltr">394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L, </div><div dir="ltr">405L, 406L, 407L, 408L, 409L, 410L, 417L, 420L, 421L, 422L, 423L, </div><div dir="ltr">424L, 425L, 426L, 427L, 428L, 429L, 430L, 431L, 432L, 433L, 434L, </div><div dir="ltr">435L, 436L, 437L, 438L, 439L, 440L, 441L, 442L, 443L, 444L, 446L, </div><div dir="ltr">447L, 448L, 449L, 450L, 451L, 452L, 454L, 455L, 456L, 457L, 458L, </div><div dir="ltr">459L, 460L, 461L, 462L, 469L, 470L, 471L, 472L, 473L, 474L, 475L, </div><div dir="ltr">476L, 477L, 478L, 479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, </div><div dir="ltr">487L, 488L, 489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 498L, </div><div dir="ltr">499L, 500L, 501L, 502L, 503L, 505L, 506L, 507L, 508L, 509L, 510L, </div><div dir="ltr">511L, 512L, 513L, 514L, 515L, 516L, 517L, 518L, 519L, 520L, 521L, </div><div dir="ltr">522L, 523L, 524L, 525L, 526L, 527L, 528L, 529L, 530L, 531L, 532L, </div><div dir="ltr">533L, 534L, 535L, 536L, 537L, 538L, 539L, 540L, 541L, 542L, 543L, </div><div dir="ltr">544L, 545L, 546L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, </div><div dir="ltr">558L, 559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, </div><div dir="ltr">569L, 570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, </div><div dir="ltr">580L, 581L, 582L, 583L, 584L, 585L, 587L, 588L, 590L, 591L, 592L, </div><div dir="ltr">593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L, 603L, </div><div dir="ltr">604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L, 614L, </div><div dir="ltr">615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L, 625L, </div><div dir="ltr">626L, 627L, 628L, 629L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, </div><div dir="ltr">652L, 653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L, 661L, 662L, </div><div dir="ltr">663L, 664L, 665L, 666L, 667L, 668L, 669L, 670L, 671L, 672L, 673L, </div><div dir="ltr">679L, 680L, 681L, 683L, 684L, 685L, 686L, 688L, 689L, 692L, 693L, </div><div dir="ltr">694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L, 702L, 703L, 704L, </div><div dir="ltr">705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 713L, 714L, 715L, </div><div dir="ltr">716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 737L, 738L, 743L, </div><div dir="ltr">744L, 745L, 746L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, </div><div dir="ltr">755L, 756L, 757L, 758L, 759L, 760L, 761L, 762L, 763L, 764L, 765L, </div><div dir="ltr">766L, 767L, 769L, 770L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, </div><div dir="ltr"></div><div dir="ltr">787L, 788L, 789L)), row.names = c(NA, 6L), class = "data.frame")</div><div dir="ltr"><br></div><div dir="ltr">Preciso criar um novo data.frame com a seguinte estrutura: </div><div dir="ltr"><br></div><div dir="ltr">1) manter a coluna de data intocável,</div><div dir="ltr"><br></div><div dir="ltr">2) se a coluna 'ToKeep' for igual a FALSE, as colunas 'value1' e 'value2' recebem NA,</div><div dir="ltr"><br></div><div dir="ltr">3) se a coluna 'ToKeep' for igual a TRUE, as colunas 'value1' e 'value2' nao mudam.</div><div dir="ltr"><br></div><div dir="ltr">Estou tentando usar ifelse, mas por enquanto não consegui encontrar o caminho certo para fazer a indexação.</div><div dir="ltr"><br></div><div dir="ltr">Alguém tem alguma sugestão?</div><div></div><div> </div><div><div>Saudações,<br>--<br>Thiago V. dos Santos<br>PhD student<br>Land and Atmospheric Science<br>University of Minnesota<br><a href="http://www.laas.umn.edu/CurrentStudents/MeettheStudents/ThiagodosSantos/index.htm" target="_blank">http://www.laas.umn.edu/CurrentStudents/MeettheStudents/ThiagodosSantos/index.htm</a><br>Phone: <a href="tel:%28612%29%20323%209898" value="+16123239898" target="_blank">(612) 323 9898</a></div></div></div></div><br>_______________________________________________<br>
R-br mailing list<br>
<a 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 código mínimo reproduzível.<br></blockquote></div><br></div>