[R] Subsetting Enigma: More rows after dataframe[-list,]?
J.delasHeras at ed.ac.uk
J.delasHeras at ed.ac.uk
Wed Jul 18 20:07:20 CEST 2007
Quoting Johannes Graumann <johannes_graumann at web.de>:
> Hello again,
>
> I'm trying to purge the indexes in i.delete from frame and end up with more
> rows!? Please be so kind and let me know where I screw this up ...
>
> Joh
>
>> i.delete
> [1] 40 45 165 212 253 270 280 287 301 352 421 433 463 467
> 487
> [16] 517 537 542 573 594 596 612 614 621 635 650 696 699 707
> 732
> [31] 738 776 826 891 892 936 937 935 940 976 988 995 1037 1043
> 1059
> [46] 1081 1111 1123 1128 1132 1140 1153 1155 1165 1176 1179 1200 1281 1289
> 1300
> [61] 1320 1346 1356 1366 1369 1396 1406 1420 1428 1429 1471 1474 1475 1525
> 1540
> [76] 1554 1565 1645 1667 1665 1706 1711 1724 1764 1788 1791 1805 1808 1847
> 1881
> [91] 10 18 137 238 254 260 262 288 292 314 338 349 414 447
> 457
> [106] 465 470 478 511 530 536 552 582 588 644 655 687 693 701
> 724
> [121] 739 763 771 836 848 859 888 900 902 919 939 972 979 989
> 1000
> [136] 1002 1015 1020 1026 1029 1032 1055 1060 1073 1088 1104 1117 1124 1130
> 1135
> [151] 1144 1221 1225 1249 1251 1257 1376 1384 1386 1453 1487 1529 1532 1534
> 1605
> [166] 1624 1633 1646 1648 1702 1787 1948 1951
>
>> length(i.delete)
> [1] 173
>
>> nrow(frame)
> [1] 1975
>
>> nrow(frame[-i.delete,])
> [1] 1802
Hmmm... i.delete is a vector with 173 elements (indices).
frame has originally 1975 rows, then you remove 173 (i.delete) and you
end up with a new frame with 1802 rows (1975-173).
It works as expected... you get LESS rows afterwards, not more.
(?)
:-)
Jose
--
Dr. Jose I. de las Heras Email: J.delasHeras at ed.ac.uk
The Wellcome Trust Centre for Cell Biology Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology Fax: +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
More information about the R-help
mailing list