[R] Variance Calculation in R
Hello, Thanks everyone for helping me with the previous queries. step 1: Here is the orginal data: short sample ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 step 2: i calculate the variance of the sample using this R code x<-1:2 y<-2:141 data.matrix<-data.matrix(data[,y])#create data.matrix variableprobe<-apply(data.matrix[x,],1,var) step 3: however, when i type in variableprobe, it gives me this. 1 21.58257457 step 4: I need the code to output this: ProbeID Variance 1 224588_at 21.58257457 What do i need to do to modify the code to give me better description like the one above? thank. Keizer -- View this message in context: http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790621.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Variance Calculation in R
sorry...in step 4-i need the R code to output in this format when i export to excel. ProbeID Variance 1 224588_at 21.58257457 thanks Keizer_71 wrote: > > Hello, > > Thanks everyone for helping me with the previous queries. > > step 1: Here is the orginal data: short sample > > ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C > 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 > > step 2: i calculate the variance of the sample using this R code > > x<-1:2 > y<-2:141 > data.matrix<-data.matrix(data[,y])#create data.matrix > variableprobe<-apply(data.matrix[x,],1,var) > > step 3: however, when i type in variableprobe, it gives me this. > > 1 21.58257457 > > step 4: I need the code to output this: > > ProbeID Variance > 1 224588_at 21.58257457 > > > What do i need to do to modify the code to give me better description like > the one above? > > thank. > Keizer > > > > -- View this message in context: http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Variance Calculation in R
Try this: write.table(cbind(data.matrix[1], Variance = apply(data.matrix[,-1], 1, var)),file='file.xls') On 02/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: > > sorry...in step 4-i need the R code to output in this format when i export > to > excel. > > ProbeID Variance > 1 224588_at 21.58257457 > > thanks > > > > Keizer_71 wrote: > > > > Hello, > > > > Thanks everyone for helping me with the previous queries. > > > > step 1: Here is the orginal data: short sample > > > > ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C > > 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 > > > > step 2: i calculate the variance of the sample using this R code > > > > x<-1:2 > > y<-2:141 > > data.matrix<-data.matrix(data[,y])#create data.matrix > > variableprobe<-apply(data.matrix[x,],1,var) > > > > step 3: however, when i type in variableprobe, it gives me this. > > > > 1 21.58257457 > > > > step 4: I need the code to output this: > > > > ProbeID Variance > > 1 224588_at 21.58257457 > > > > > > What do i need to do to modify the code to give me better description like > > the one above? > > > > thank. > > Keizer > > > > > > > > > > -- > View this message in context: > http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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.
Re: [R] Variance Calculation in R
Hi Henrique, It is definitely better, but it doesn't show me the ProbeID which identify the probes name Here was the result when i export to excel with your code. "Variance" 1 2.425509867 21.6216446425273 any suggestions? thanks, Kei Keizer_71 wrote: > > Hello, > > Thanks everyone for helping me with the previous queries. > > step 1: Here is the orginal data: short sample > > ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C > 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 > > step 2: i calculate the variance of the sample using this R code > > x<-1:2 > y<-2:141 > data.matrix<-data.matrix(data[,y])#create data.matrix > variableprobe<-apply(data.matrix[x,],1,var) > > step 3: however, when i type in variableprobe, it gives me this. > > 1 21.58257457 > > step 4: I need the code to output this: > > ProbeID Variance > 1 224588_at 21.58257457 > > > What do i need to do to modify the code to give me better description like > the one above? > > thank. > Keizer > > > > -- View this message in context: http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15791115.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Variance Calculation in R
Then you can try: rownames(data.matrix) <- as.character(data.matrix$ProbeID) data.matrix <- data.matrix[-1] as.matrix(apply(data.matrix1, 1, var)) or out <- apply(data.matrix1, 1, var) data.frame(ProbeID = names(out), Variance = unname(out)) Works for me On 02/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: > > Hi Henrique, > > It is definitely better, but it doesn't show me the ProbeID which identify > the probes name > > Here was the result when i export to excel with your code. > > "Variance" > 1 2.425509867 21.6216446425273 > > > any suggestions? > > thanks, > Kei > > > Keizer_71 wrote: > > > > Hello, > > > > Thanks everyone for helping me with the previous queries. > > > > step 1: Here is the orginal data: short sample > > > > ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C > > 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 > > > > step 2: i calculate the variance of the sample using this R code > > > > x<-1:2 > > y<-2:141 > > data.matrix<-data.matrix(data[,y])#create data.matrix > > variableprobe<-apply(data.matrix[x,],1,var) > > > > step 3: however, when i type in variableprobe, it gives me this. > > > > 1 21.58257457 > > > > step 4: I need the code to output this: > > > > ProbeID Variance > > 1 224588_at 21.58257457 > > > > > > What do i need to do to modify the code to give me better description like > > the one above? > > > > thank. > > Keizer > > > > > > > > > > -- > View this message in context: > http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15791115.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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.
Re: [R] Variance Calculation in R
unfortunately, it is not showing probeID Henrique Dallazuanna wrote: > > Try this: > > write.table(cbind(data.matrix[1], Variance = apply(data.matrix[,-1], > 1, var)),file='file.xls') > > > On 02/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: >> >> sorry...in step 4-i need the R code to output in this format when i >> export >> to >> excel. >> >> ProbeID Variance >> 1224588_at 21.58257457 >> >> thanks >> >> >> >> Keizer_71 wrote: >> > >> > Hello, >> > >> > Thanks everyone for helping me with the previous queries. >> > >> > step 1: Here is the orginal data: short sample >> > >> >ProbeID Sample_1_D Sample_1_CSample_2_D Sample_2_C >> > 1 224588_at 2.425509867 11.34031409 11.46868531 11.75741478 >> > >> > step 2: i calculate the variance of the sample using this R code >> > >> > x<-1:2 >> > y<-2:141 >> > data.matrix<-data.matrix(data[,y])#create data.matrix >> > variableprobe<-apply(data.matrix[x,],1,var) >> > >> > step 3: however, when i type in variableprobe, it gives me this. >> > >> > 1 21.58257457 >> > >> > step 4: I need the code to output this: >> > >> >ProbeID Variance >> > 1 224588_at 21.58257457 >> > >> > >> > What do i need to do to modify the code to give me better description >> like >> > the one above? >> > >> > thank. >> > Keizer >> > >> > >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> 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. >> > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > > __ > 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. > > -- View this message in context: http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15792364.html Sent from the R help mailing list archive at Nabble.com. __ 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.