I'm a beginner in R and I need some help:
In my database, very big since I'm working with micro-data, I want to remove some rows when there is a specific value of a Column...i was trying to implement some function to do that....but I'm having a problem with the 开发者_StackOverflow社区IF condition(true/false problem). For example, I want to remove the row i when the column DISC in that line is "L", then i did this function:
dellinhas<-function(x){
n<-nrow(x)
i<-1
while (i<=n) {
if (x[i,]$DISC=="L") {x<-x[-(i:i),]}
i<-i+1}
dadosPrmM<-x
}
Where x
is the database. What am I doing wrong?
Use subscripting:
x[x$DISC != "L",]
And try this website for basic data manipulation issues: http://www.statmethods.net/
精彩评论