r - Row division for even number rows -


i trying divide first row second, third row fourth , fifth row sixth , onward large data table. there way without computation.

input

name month income john jan 10000  john_county jan 20000  tanya jan 20000  tanya_county jan 40000 

output

name month per_income john jan 50% tanya jan 50%  

in r can use , odd index:

odds <- c(true, false) ii[odds,"per_income"] <- paste0(ii[odds,3] / ii[!odds,3] * 100,"%") ii[odds,] #    name month income per_income # 1  john   jan  10000        50% # 3 tanya   jan  20000        50% 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -