Chronbach Alpha calculation

Ron04

New Member
#1
I have the following reprex and add column coding :
INPUT:
df <- tibble::tribble(
~seq, ~date, ~sales,
1, "3/01/2017", 40,
2, "4/01/2017", 2,
3, "5/01/2017", 2,
4, "6/01/2017", 2,
5, "7/01/2017", 30,
6, "8/01/2017", 2,
7, "1/02/2017", 9,
8, "2/02/2017", 5,
9, "3/02/2017", 65,
10, "4/02/2017", 3,
11, "5/02/2017", 65
)
add_column(df, z = -1:1, w = 0)
add_column(df, z = 0, w = 0)
OUTPUT
seq date sales z w

1 1 3/01/2017 40 0 0
2 2 4/01/2017 2 0 0
3 3 5/01/2017 2 0 0
4 4 6/01/2017 2 0 0
5 5 7/01/2017 30 0 0
6 6 8/01/2017 2 0 0
7 7 1/02/2017 9 0 0
8 8 2/02/2017 5 0 0
9 9 3/02/2017 65 0 0
10 10 4/02/2017 3 0 0
11 11 5/02/2017 65 0 0
QUESTION
I need to fill in column Z or W with a calculation with Chronbachs Alpha per line,based on previous sale.So C.the first Alpha calculation would be on item line 2.
How do I calculate the C.Alpha number in column Z per line,? what would the coding be like?

code:
colnames(sales1) <- c("Alpha")
cronbach(cbind(sales[,c(1,3:2)],-1*sales1[,2]))

is my code correct?
where to put the Alpha calculation in the code?
cheers