30770/error-saying-error-in-lag-x-1-unused-argument-1
I need to refer to lagged and lead values of variables but I cannot seem to get the code for the lag function working as documented.
> library(dplyr) > x <- seq(100,500,100) > x [1] 100 200 300 400 500 > lead(x,1) [1] 200 300 400 500 NA > lag(x,1) Error in lag(x, 1) : unused argument (1) >
lag only works as expected with time-series objects. For instance:
cbind(x = ts(1:10), y = lag(1:10, -1))
In your case:
lag_n <- function(x, n) {c(rep(NA, n), x)[1:length(x)])
Make sure is a factor time <- as.factor(c("pm", ...READ MORE
You could try the httr library: library(XML) library(httr) url <- 'http://www.sainsburys.co.uk/shop/gb/groceries/fruit-veg/all-fruit#langId=44&storeId=10151&catalogId=10122&categoryId=12545&parent_category_rn=12518&top_category=12518&pageSize=30&orderBy=FAVOURITES_FIRST&searchTerm' doc <- ...READ MORE
Brief invoke REBMIX as : REBMIX[[i, j, k]] ...READ MORE
Make sure you’ve installed the package purr ...READ MORE
Well it truly depends on your requirement, If ...READ MORE
You can use the removesparseterm function. Removes sparse ...READ MORE
You can do this in R using ...READ MORE
Try replacing ID <- c("A123","A123","A123","A123","B456","B456","B456") item <- c("bread", "butter", "milk", ...READ MORE
There is small mistake in your code. ...READ MORE
Hey @ali, rnorm() function requires an argument, ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.