删除r中的部分重复行

问题描述 投票:-1回答:1

我只需要保留该图列中的31B行。结构是这样的:

CO2S  H2OS   PLOT
412   102    31
413   102    31
414   102    31B
415   102    31B

谢谢!

duplicates rows partial
1个回答
0
投票
假设您的数据帧称为“ df”,那么这两个中的任何一个都应该起作用。但是我建议使用“哪个”方法,因为在某些极端情况下,子集会引起奇怪的问题。这里有一个很好的讨论:Why is `[` better than `subset`?

df_1 <- subset(df,df$PLOT == "31B") df_2 <- df[which(df$PLOT == "31B"),] and if you want to add more conditions, u can always use "&" df_3 <- df[which(df$PLOT == "31B" & df$CO2S == 414),]

© www.soinside.com 2019 - 2024. All rights reserved.