Removing an entry in r -


in sas there capability remove observation through simple if statement. instance if wanted delete rows year = #. write:

if year == "#" delete;  

is there equivalent way in r? tried this:

 df<- df[!(df$year == "#"),] 

data set in r:

year        month #           june #           july  #           august 2015        august 

but when run df$year, still # factor level when thought filtered out?

you're doing right. still factor level, doesn't mean exists in vector df$year. can drop factor level if need droplevels or using factor again df$year <- factor(df$year)

if need convert factor numeric labels numeric vector, can use:

as.numeric( ## convert numeric expected   as.character( ## because factors numbers labels     your_factor      )   ) ) 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -