我有這樣的數據集:子集的數據集
> dput(SampleEvents)
structure(list(Event = structure(c(10L, 5L, 6L, 11L, 10L, 7L,
11L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 11L), .Label = c("e10", "e11",
"e12", "e13", "e2", "e3", "e6", "e8", "e9", "Login", "Logout"
), class = "factor"), Transaction.ID = structure(c(NA, 1L, NA,
2L, NA, NA, NA, NA, 3L, NA, NA, NA, NA, NA, NA), .Label = c("t1",
"t4", "t5"), class = "factor"), User.ID = structure(c(1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("kenn1",
"kenn2"), class = "factor"), Event.Date = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "20/5/2017", class = "factor"),
Event.Time = structure(c(12L, 13L, 14L, 15L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L), .Label = c("10:01", "10:02",
"10:03", "10:04", "10:05", "10:06", "10:07", "10:08", "10:09",
"10:10", "10:11", "9:00", "9:30", "9:45", "9:50"), class = "factor")), .Names = c("Event",
"Transaction.ID", "User.ID", "Event.Date", "Event.Time"), class = "data.frame", row.names = c(NA,
-15L))
我想去掉兩個固定值內的所有行下的列「事件」,即,從「行登錄」到‘註銷’,其中有之間的所有失蹤事務ID值‘登錄’和‘註銷’:
我也想保留數據集的當前順序。
如何在R中執行此操作?
請不要提供您的數據爲圖像。對於任何人使用它,他們需要再次輸入。相反,請使用文本格式。理想情況下,您可以使用R中的數據並使用'dput'來提供數據結構。您的圖像看起來像來自Excel。 _至少_你可以保存爲csv並粘貼到你的問題。 – G5W
我對這個網站有點新。讓我嘗試附加數據集。 –
是的,我想在這裏有一個示例並理解邏輯,以便我可以將其應用於我的父數據集中。 –