[R] Strange data frame behavior

Raoni Rodrigues caciquesamurai at gmail.com
Tue Sep 25 07:22:26 CEST 2012


Hello all,

I don't understand a strange behavior in data frame manipulation.

data_frame1 = data.frame(Site = c("S1", "S2", "S3", "S4", "L1", "L2",
"L3", "L4"),
	     				Number = c(1, 3, 5, 2, 1, 1, 2, 1))

data_frame2 = data_frame1 [data_frame1$Site != "S1", ]

dput (data_frame2)

structure(list(Site = structure(c(6L, 7L, 8L, 1L, 2L, 3L, 4L), .Label = c("L1",
"L2", "L3", "L4", "S1", "S2", "S3", "S4"), class = "factor"),
    Number = structure(c(3L, 4L, 2L, 1L, 1L, 2L, 1L), .Label = c("1",
    "2", "3", "5"), class = "factor")), .Names = c("Site", "Number"
), row.names = 2:8, class = "data.frame")

Why site "S1" do not disappeared from data_frame2's structure?

And what I have to do to eliminate it definitively from my new data
frame (data_frame2)?

Sorry for this basic question, but I really did not understand...

Thanks in advanced,

Raoni
-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.raoni at gmail.com



More information about the R-help mailing list