R help -

I am attempting to write a script that has multiple subjects in 1 data file.
 Each subject has multiple rows with columns as variables.  Here is my code,
I am having problem executing it on each unique subject id (dat$Subject).

   getwd()

setwd("/Users/edwardpatzelt/Desktop/Neuroimaging/MERIT/SRRT/merge")


dat <- read.table("test2.txt", header = TRUE, na.strings = NA,
stringsAsFactors = FALSE, sep = "\t")


for(i in 1:length(dat))

 {

 for (i in 1:)dat[(unique(dat$Subject)),)]

 {

    colg <- dat[grep("Green", dat$CueProbe),]

   colg <- data.frame(colg$SRRTCue.OnsetTime/1000, (colg$SRRTFix2.OnsetTime-
colg$SRRTCue.OnsetTime)/1000, (ifelse((colg$SRRTProbe.ACC == 1 | colg$Probe==
"+"), 1, 0)))

   colr <- dat[grep("Red", dat$CueProbe),]

   colr <- data.frame(colr$SRRTCue.OnsetTime/1000, (colr$SRRTFix2.OnsetTime-
colr$SRRTCue.OnsetTime)/1000, (ifelse((colr$SRRTProbe.ACC == 1 | colr$Probe==
"+"), 1, 0)))

     write.table(colg, file  = paste(dat$Subject[[1]], sep = "\t", append =
"green.txt"), col.names = FALSE, row.names = FALSE)

  write.table(colr, file  = paste(dat$Subject[[1]], sep = "\t", append =
"red.txt"), col.names = FALSE, row.names = FALSE)

     }

  }






-- 
Edward H. Patzelt
Research Assistant – TRiCAM Lab
University of Minnesota – Psychology/Psychiatry
VA Medical Center
Office: S355 Elliot Hall - Twin Cities Campus
Phone: 612-626-0072  Email: patze003@umn.edu

Please consider the environment before printing this email
www.psych.umn.edu/research/tricam

	[[alternative HTML version deleted]]

