Hi I am very new to R and statistical programming in general. I am trying to reorder data from a .csv file. I have managed to import the data and create a zero matrix. I am now trying to fill the matrix. There seems to be some problem with this section of my code. I have highlighted the dodgy code in red. Please help if possible.
###################################################### ########### Create matrix ########################### ###################################################### #Open the csv file OGSdata <- read.table("MG3199.csv",sep=",",header=TRUE) #creates 3 separate vectors sample <- OGSdata[,1] mci <- OGSdata[,2] pct <- OGSdata[,3] #change mci range offset <- min(mci)-1 mci <- (mci - offset) #matrix sizes mci_count <- max(mci) sample_count <- max(sample) #creates a zero matrix OGS <- mat.or.vec(mci_count,sample_count) #Create labels sample_lab <- ("A-9","B-9", "C-9", "D-9", "E-9","A-12","B-12", "C-12", "D-12", "E-12") #add data for (i in 1:length(pct)) { OGS(mci(i),sample(i))<- pct(i); } What I want is to have colum1 from original data to be the xlabel, column 2 to be the ylabel and the 3rd colum to be the values in the matrix Any help is appreciated. Kind Regards Amit Patel ___________________________________________________________ now. [[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.