Hi i am trying to run this code and am getting this error.
code- for(i in variables) prediction.exercise[, paste0(i,"_lag")] <- shift(prediction.exercise[,i],n=1,type="lag")
error- Error in [.data.frame(prediction.exercise, , i) :
undefined columns selected
prediction.exercise= refers to the dataset
I tried to create a lag in the data set
Related
I am trying to merge two data sets and thus trying to cut some NA data with the following code:
vedba <- read.csv(vedba_in)
head(vedba)
vedba$Start <- as.POSIXct(strptime(vedba$Midway,format="%d/%m/%Y %H:%M:%S"),tz="GMT")
head(vedba)
##cut data
cts <- cut(as.numeric(vedba$Start),breaks=c(breaks[1] - 3600,breaks))
## which dive do each vedba event belong
cts_splt <- strsplit(as.character(cts)[!is.na(cts)],split=",")
cts_splt <- unlist(cts_splt)
cts_splt <- cts_splt[seq(1,length(cts_splt), by=2)]
substring(cts_splt,1) <- "0"
cts_splt <- as.numeric(cts_splt)
dive_no <- match(cts_splt,as.numeric(begin))
Yet when I run it, I receive the following error:
Error in seq.default(1, length(cts_splt), by = 2) :
wrong sign in 'by' argument
I am stumped and can't fix it. I have used this argument before and haven't had the error so something must be wrong with my data set. Any clues?
I have uploaded an image of what my data looks like.
My vedba_in data
I wanted to return List from custom function but im getting error def
myFunc (credit : Column) = {for ( i <- 0 to col("credit")) yield i}
Calling custom function
.withColumn("History" , explode (myFunc("credit")))
Error message "Expected column but found Seq"
I want to explode it to split into multiple rows.
I am trying to run a %cif macro but I am getting the following error:
ERROR: (execution) Invalid argument to function.
count : number of occurrences is 2
operation : EXP at line 1436 column 1
operands : _TEM1008
_TEM1008 7851 rows 1 col (numeric)
statement : ASSIGN at line 1436 column 1
I have only been using SAS for a few months, so would be grateful is someone could point me in the right direction.
Just need to know how can I get the following code not to get me a type mismatch error. The last line which is commented out works but when i replace the Range("B2:B2000") with f it gives me a type mismatch error. Reason why I am not just using the last line instead since it works is because what if column B becomes Column C if i insert a new column in Column B. Is there something else that I need to add to the f to make it work?
f = Application.WorksheetFunction.Match("PCR No.", Range("A1:AZ1"), 0)
ActiveWorkbook.Worksheets("3. PMO Internal View").Sort.SortFields.Add Key:=Cells(1, f)
ActiveWorkbook.Worksheets("3. PMO Internal View").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("3. PMO Internal View").Sort.SortFields.Add Key:= _
f, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
'Range("B2:B2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
I am working on this code but I cannot figure out where I am going wrong
This is the part of the code that shows errors:
sf_num=0; sf_den=0;a=0; o=0;
for i=1:512
for j=1:512
sf_num=sf_num+(w1(i,j)*o(i,j));
a=a+(o(i,j)*o(i,j));
b=b+(w1(i,j)*w1(i,j));
sf_den = sqrt(sf_den + a*double(b));
end
end
and this is the error:
Attempted to access o(1,2); index out of bounds because numel(o)=1.
Error in ==> dwtcode at 44
sf_num=sf_num+(w1(i,j)*o(i,j));
You define o as: o=0 making it a scalar, meaning it only has 1 element.
You can't access index 1,2 of o because it doesn't have that many elements