if statement - In R using if else loop how to extract even and odd nubers -


i have data of 500 ids stored in uid column ;i want extract ids , odd ids separately , store in 2 different data respectively. how in r using if-else loop ?

you don't if-else loop. use subsetting, expression based on whether id odd or even.

odd  <- df[df$uid %% 2 == 1, ] <- df[df$uid %% 2 == 0, ] 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -