I want to just convert from float32 to 16b with scale factor of 10. I wonder why some files were converted correctly while some were not converted correctly. By means, the results of some files are weird. the original files are all ok!.
dir1<- list.files("C:\\New folder (13)", "*.img", full.names = TRUE) results<- list() for (.files in seq_along(dir1)){ file2 <- readBin(dir1[.files], double(), size = 4, n = 360*720, signed = TRUE) file2[file2 != -9999] <- file2[file2 != -9999]*10 results[[length(results) + 1L]] <- file2 fileName <- sprintf("C:\\SWdown_200001_%d.bin", .files) writeBin(as.integer(results[[.files]]), fileName, size = 2)} -- View this message in context: http://r.789695.n4.nabble.com/convert-from-float32-to-16B-tp4631638.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.