Here is my R Code
x<-1:20000
y<-2:141
data.matrix<-data.matrix(data[,y])#create data.matrix
variableprobe<-apply(data.matrix[x,],1,var)
variableprobe #output variance across probesets
hist(variableprobe) #displaying histogram of variableprobe
write.table(cbind(data[1],
Variance=apply(data[,y],1,var)),file='c://variance.csv')
#export as a .csv file.
Output in Excel
all in 1 column.
ProbeID "Variance"
1 "224588_at" 21.5825745738848
How do i separate them so that i can have three columns
ProbeID Variance
1 224588_at 21.582.....
thanks,
Kei
--
View this message in context:
http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
Sent from the R help mailing list archive at Nabble.com.
If you are asking how to convert to multiple columns in Excel, look at the "text to column" option in I think the data tab. On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 <christophe.lo at gmail.com> wrote:> > Here is my R Code > > x<-1:20000 > y<-2:141 > data.matrix<-data.matrix(data[,y])#create data.matrix > variableprobe<-apply(data.matrix[x,],1,var) > variableprobe #output variance across probesets > hist(variableprobe) #displaying histogram of variableprobe > write.table(cbind(data[1], > Variance=apply(data[,y],1,var)),file='c://variance.csv') > #export as a .csv file. > > Output in Excel > all in 1 column. > > ProbeID "Variance" > 1 "224588_at" 21.5825745738848 > > How do i separate them so that i can have three columns > > ProbeID Variance > 1 224588_at 21.582..... > > thanks, > Kei > > > -- > View this message in context: http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
hi, did you try write.xls in xlsReadWrite package? On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 <christophe.lo at gmail.com> wrote:> > Here is my R Code > > x<-1:20000 > y<-2:141 > data.matrix<-data.matrix(data[,y])#create data.matrix > variableprobe<-apply(data.matrix[x,],1,var) > variableprobe #output variance across probesets > hist(variableprobe) #displaying histogram of variableprobe > write.table(cbind(data[1], > Variance=apply(data[,y],1,var)),file='c://variance.csv') > #export as a .csv file. > > Output in Excel > all in 1 column. > > ProbeID "Variance" > 1 "224588_at" 21.5825745738848 > > How do i separate them so that i can have three columns > > ProbeID Variance > 1 224588_at 21.582..... > > thanks, > Kei > > > -- > View this message in context: http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- ==============================WenSui Liu ChoicePoint Precision Marketing Phone: 678-893-9457 Email : wensui.liu at choicepoint.com Blog : statcompute.spaces.live.com
The other respondants here have missed the point - write.table() as
invoked by the OP does not produce a csv file. The default separator is
" " (a space) in write.table(), so no wonder Excel cocked it up as it
assumes that a csv file is one that has elements separated by a comma
",". We don't need to rely on extra packages or using Excel to
fix-up
the file written by R - just use R's tools appropriately.
Kei, some points.
Did you actually try to run the example you provided? It failed on line
4 for me as you use data.matrix as a name for an object and it is an R
function, which R says can't be subset as data.matrix[x, ] in the call
to apply.
Instead of being able to step through your code to see where the problem
was I spent a few minutes trying to fix it up and decipher what you
intended before I spotted the call to write.table.
Secondly, space out your code - it makes it much easier to read if you
put spaces round "<-", e.g.:
x <- 1:20000
and leave a space after the "," comma separating arguments in function
calls.
Now to the answer (or one possible answer)
To generate a proper csv file, see ?write.csv, or ?write.csv2 if you are
in of those strange countries that uses a comma as the decimal
separator. Because your example doesn't work, I can't test this, but
this should give you a csv file that opens in Excel as you want:
write.csv(cbind(data[1], Variance=apply(data[,y], 1, var)),
file="c://variance.csv")
HTH
G
On Sun, 2008-03-02 at 18:59 -0800, Keizer_71 wrote:> Here is my R Code
>
> x<-1:20000
> y<-2:141
> data.matrix<-data.matrix(data[,y])#create data.matrix
> variableprobe<-apply(data.matrix[x,],1,var)
> variableprobe #output variance across probesets
> hist(variableprobe) #displaying histogram of variableprobe
> write.table(cbind(data[1],
> Variance=apply(data[,y],1,var)),file='c://variance.csv')
> #export as a .csv file.
>
> Output in Excel
> all in 1 column.
>
> ProbeID "Variance"
> 1 "224588_at" 21.5825745738848
>
> How do i separate them so that i can have three columns
>
> ProbeID Variance
> 1 224588_at 21.582.....
>
> thanks,
> Kei
>
>
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%