dataframe - Subset the data based on a unique value in R -


this question has answer here:

i have data below

test=data.frame("name"=c("a","a","a","a","b","b","c"), value=c(10,11,12,13,14,15,16)) 

i want subset test data based on non-repeated name "c", want show data below:

name value    c    16 

i try test[table(test$name)>1,], output wrong.

please give me hint, thanks!!

using data.frame such,

table.freq <- as.data.frame(table(test$name)) test[test$name %in% table.freq$var1[table.freq$freq==1],] #  name value #7    c    16 

or using which

test[test$name %in% names(which(table(test$name)==1)),] #  name value #7    c    16 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -