Closed AnguloB closed 1 year ago
Dear @AnguloB,
thank you for submitting the issue. Are you sure that you are using the lag
function from the stats
package in your R session?
x <- 1:5
stats::lag(x) # the same result as typing `lag(x)` in JASP
# [1] 1 2 3 4 5
# attr(,"tsp")
# [1] 0 4 1
dplyr::lag(x) # what you expect
# [1] NA 1 2 3 4
Note that you can call dplyr::lag()
inside of the R in JASP window as well.
I was sure when I wrote it but clearly I was not using the "stats" one. Thank you very much for your quick reply and sorry for the inconvenience.
I am glad that it helped! I am closing this issue now.
JASP Version
0.16.1
Commit ID
No response
JASP Module
Other Module
What analysis are you seeing the problem on?
lag in Rconsole
What OS are you seeing the problem on?
macOS Intel
Bug Description
As part of an undergraduate course at my university, we have developed some materials to solve an example in psychometrics with a database.
As part of this exercise we do the calculation of percentiles. In order to do this, we need the proportion of observed responses from the previous row. In R, this is relatively simple with the "lag" function of the stats package.
prop <-prop.table(table(score))100 cum <-cumsum(prop.table(table(score))100) perc <- trunc(lag(cum))
As I understand from the JASP documentation, you can use functions from the stats package. Instead, when I try to implement it in the R console it does not work.
For simplicity I have created an example that illustrates the problem.
Expected Behaviour
var1<- c(2, 2, 2, 2, 2) var2<- c(1, 2, 3, 4, 5)
result<-var1 + (lag(var2, k = 1)) result<-var1 + (lag(var2)) # same with this approach
result (in R) NA 3 4 5 6
Instead, in JASP : 3 4 5 6 7
You would expect to get an error result, or the correct result in this case.
Steps to Reproduce
var1<- c(2, 2, 2, 2, 2) var2<- c(1, 2, 3, 4, 5)
var1+var2 result<-var1 + (lag(var2, k = 1)) result
Log (if any)
No response
Final Checklist