Hello everyone, I am using the following program to get the p-value of some numbers (column 'LR' of the data.dat file). I want to write the 1st and 2nd column of the output file (data.out) as an integer while the program change them to double. Could anybody please tell me how I can write the code which writes the values of the first two columns as integer? Thanks library ('MASS') MP<-read.table(file='data.dat') names(MP)<-c('B','R','S','L','LR','Q') a<-as.matrix((1-pchisq(MP$LR, df=1))) b<-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) write.matrix(b,'data.out')
On Feb 22, 2007, at 8:36 PM, Mohsen Jafarikia wrote:> I am using the following program to get the p-value of some numbers > (column 'LR' of the data.dat file). I want to write the 1st and 2nd > column of the output file (data.out) as an integer while the program > change them to double. Could anybody please tell me how I can write > the code which writes the values of the first two columns as integer? > > library ('MASS') > MP<-read.table(file='data.dat') > names(MP)<-c('B','R','S','L','LR','Q') > a<-as.matrix((1-pchisq(MP$LR, df=1))) > b<-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) > write.matrix(b,'data.out')?Round _____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 WWW: http://www.people.virginia.edu/~mk9y/
write.matrix(as.integer(b),'data.out') Mohsen Jafarikia wrote:> Hello everyone, > I am using the following program to get the p-value of some numbers > (column 'LR' of the data.dat file). I want to write the 1st and 2nd > column of the output file (data.out) as an integer while the program > change them to double. Could anybody please tell me how I can write > the code which writes the values of the first two columns as integer? > Thanks > > > library ('MASS') > MP<-read.table(file='data.dat') > names(MP)<-c('B','R','S','L','LR','Q') > a<-as.matrix((1-pchisq(MP$LR, df=1))) > b<-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) > write.matrix(b,'data.out') > > ______________________________________________ > R-help at stat.math.ethz.ch 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.-- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466