r - Find users joined before certain time -


i newbie , need guidance.

basically have table following information:

userid   username    d0j 983357   xxxxxxxx    25/08/2017 983358   xxxxxxxx    01/09/2017 983359   xxxxxxxx    03/09/2017 983360   xxxxxxxx    05/09/2017 ..... ..... 

what want achieve extract records of users have joined site 15 days before current date. have tired googling around , many other sites not able figure out proper way. have tried using lubridate no success.

tada :)

library(dplyr) library(lubridate) df %>% filter(dmy(d0j) > as_date(sys.date()) - 15*days()) 

dmy (for day month year) formats date correctly, , it's simple filter on inequality, replace > >= if relevant

result

  userid username        d0j 1 983358 xxxxxxxx 01/09/2017 2 983359 xxxxxxxx 03/09/2017 3 983360 xxxxxxxx 05/09/2017 

data

df <- read.table(text="userid   username    d0j 983357   xxxxxxxx    25/08/2017                  983358   xxxxxxxx    01/09/2017                  983359   xxxxxxxx    03/09/2017                  983360   xxxxxxxx    05/09/2017",header=t,stringsasfactor=f) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -