I'm currently extracting phenotype/covariate data I need to run a GWAS. I am also trying to convert the 'bank_centre location' to a dummy variable. In attempting to create the data file to run the GWAS, I keep getting an error for an extra "]" in my code relating to the dummy variable, however I don't see how there is an extra "]" in my code.
this is the first part of my input:
source scriptSettings.sh
Rscript - <<'END'
library(data.table)
d<-fread("phenos.txt")
message("create array dummy")
d[,array01:=as.numeric(as.numeric(f.22000.0.0)>1)]
message ("create bank_centre dummy")
d[,'bank1']<-0
d[,'bank2']<-0
d[,'bank3']<-0
d[which(d[,'f.54.2.0']==11025,'bank1']<-1
d[which(d[,'f.54.2.0']==11026,'bank2']<-1
d[which(d[,'f.54.2.0']==11027,'bank3']<-1
The output I get so far is:
create array dummy
create biobank_centre dummy
Error: unexpected ']' in "d[which(d[,'f.54.2.0']==11025,'bank1']"
Execution halted
Apologies if I am missing something super obvious - any help is much appreciated
I think there is a missing
)
forwhich
.i.e. You may want to try something like this:
d[which(d[,'f.54.2.0']==11025),'bank1']<-1