# NOT RUN {
id <- c(rep(1, 3), rep(2, 3), 3)
desc <- c('New', 'New', 'Good', 'New', 'Good', 'Good', 'New')
df <- data.frame(id, desc)
df <- createDataFrame(df)
w1 <- orderBy(windowPartitionBy('desc'), df$id)
w2 <- rowsBetween(w1, 0, 3)
df1 <- withColumn(df, "sum", over(sum(df$id), w2))
head(df1)
# }
Run the code above in your browser using DataLab