[R] Filling in a Zero Matrix
Julian Burgos
jmburgos at u.washington.edu
Mon Nov 26 20:16:44 CET 2007
Hi Amy,
Many (perhaps most) of the people on the list do not receive emails with
html...so we can't see colored text. Also it would be helpfully to have
a bit of your data, so we can run your code (see the posting guide in
this regard,http://www.R-project.org/posting-guide.html).
Please explain what are the 'xlabel' and the 'ylabel' that you
mentioned. I don't see those variables in your code.
Julian
Amit Patel wrote:
> 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 at 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.
More information about the R-help
mailing list