R does not recognise columns and rows as they are supposed to be
In the absence of documentation for the file format, what="double",size=4,endian="little" would be a good guess. Many problems people report on this list are due to errors in reading data into R. Converting data from one format to another is always error-prone and you need to check that the conversion was done correctly. Don't try to analyze the imported data until you have checked the import process. E.g., you think your files should contain 360*720 4-byte values, so look at the number of bytes in the file with file.info(file)$size and see if it matches the expected 360*720*4. After you read the data into the matrix, x, look at the quartiles with quantile(x). Do those -9999's represent missing values? If so, make them NA's with is.na(x) <- x==-9999 and look at the quartiles again, with quantile(x,na.rm=TRUE). Take a look at the pattern of the data with image(x) or image(array(rank(x), dim=dim(x))) (or plot(x[,10]) or plot(x[20,]), etc.). If any these things look odd, fix the import procedure before doing the "real" analysis of the data. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jonsson Sent: Friday, May 25, 2012 8:58 AM To: r-help at r-project.org Subject: Re: [R] R does not recognise columns and rows as they are supposed to be Yes I did so. Yes the first values are the right ones: -9999 -9999. so this meant that I should consider my data as: double/4/little Is it so? file <- "C:\\Users\\aalyaari\\Documents\\INRA\\WFD_reprocessed\\dialyswco\\2001\\SWdow n_200101_01.img"
for(what in c("double", "integer")) {
+ for(size in c(4, 8)) {
+ for(endian in c("little", "big")) {
+ cat(sep="", what, "/", size, "/", endian, ":\n ");
+ print(readBin(file, what=what, size=size, endian=endian, n=6))
+ }
+ }
+ }
double/4/little:
[1] -9999 -9999 -9999 -9999 -9999 -9999
double/4/big:
[1] 5.520452e-39 5.520452e-39 5.520452e-39 5.520452e-39 5.520452e-39
5.520452e-39
double/8/little:
[1] -5.592396e+29 -5.592396e+29 -5.592396e+29 -5.592396e+29 -5.592396e+29
-5.592396e+29
double/8/big:
[1] 1.563804e-307 1.563804e-307 1.563804e-307 1.563804e-307 1.563804e-307
1.563804e-307
integer/4/little:
[1] -971228160 -971228160 -971228160 -971228160 -971228160 -971228160
integer/4/big:
[1] 3939526 3939526 3939526 3939526 3939526 3939526
integer/8/little:
[1] -971228160 -971228160 -971228160 -971228160 -971228160 -971228160
integer/8/big:
[1] 3939526 3939526 3939526 3939526 3939526 3939526
-- View this message in context: http://r.789695.n4.nabble.com/R-does-not-recognise- columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631344.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.