I have a data frame containing sequences and I am interested in changing a few 
sequences in a window and the swapping the original sequence back after I have 
completed my analysis.
My temporary data frame that I am creating seq.in.window does not like the way 
I am making me assignment.  The variable seq.in.window gets numbers assigned to 
it, instead of the data contained in
sequence.data. Can someone point out the mistake I am making?
Thanks ../Murli

x<-c("a","t","g","c")
sequence.data<-structure(list(V1 = structure(c(4L, 1L, 3L, 2L, 2L, 3L, 3L, 2L,
2L, 1L, 2L, 1L, 2L, 1L, 1L, 4L, 1L, 4L, 3L, 1L), .Label = c("a",
"c", "g", "t"), class = "factor"), V2 = structure(c(3L, 2L, 4L,
1L, 4L, 1L, 3L, 4L, 2L, 3L, 3L, 4L, 2L, 4L, 4L, 1L, 4L, 2L, 3L,
4L), .Label = c("a", "c", "g", "t"), class = "factor"), V3 = structure(c(3L,
3L, 3L, 3L, 3L, 1L, 4L, 2L, 1L, 3L, 1L, 1L, 1L, 2L, 1L, 4L, 1L,
4L, 1L, 4L), .Label = c("a", "c", "g", "t"), class = "factor"),
    V4 = structure(c(3L, 2L, 1L, 2L, 2L, 3L, 4L, 2L, 1L, 4L,
    3L, 4L, 2L, 1L, 4L, 2L, 4L, 4L, 4L, 3L), .Label = c("a",
    "c", "g", "t"), class = "factor"), V5 = structure(c(3L, 3L,
    3L, 2L, 1L, 1L, 2L, 4L, 2L, 3L, 4L, 2L, 1L, 1L, 4L, 4L, 4L,
    2L, 1L, 4L), .Label = c("a", "c", "g", "t"), class = "factor"),
    V6 = structure(c(2L, 2L, 1L, 4L, 3L, 4L, 1L, 4L, 2L, 3L,
    3L, 2L, 3L, 2L, 2L, 3L, 1L, 4L, 4L, 4L), .Label = c("a",
    "c", "g", "t"), class = "factor")), .Names = c("V1", "V2",
"V3", "V4", "V5", "V6"), class = "data.frame", row.names = c("16",
"4", "1", "9", "6", "2", "15", "19", "18", "12", "13", "91",
"41", "21", "151", "14", "5", "8", "181", "121"))


seq.in.window<-data.frame(matrix(0,nrow=20,ncol=5)) # Creating an empty data 
frame


   for(i in 1:20){

        seq.in.window[i,1:5]<- sequence.data[i,1:5] #Can I do this assignment?

        print(seq.in.window[i,1:5])

        rnd.seq =as.vector(sample(x,length(1:5), replace=TRUE))

        sequence.data[i,5] =t(rnd.seq)

        print(sequence.data[i,1:5])

        cat("\n")

   }

  for(i in 1:20){
        sequence.data[i,1:5]=seq.in.window[i,1:5]
   }

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to