Last active
April 21, 2020 10:38
-
-
Save pinetum/0f63ea7048f24889cdd9a170a7e77163 to your computer and use it in GitHub Desktop.
Read binary file in R (4byte float point)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path_binary_file <- "~/Dropbox/元智課程資料/研究所課程/資料探勘/VQ/COL.sil" | |
n_dimension <- 26 | |
n_element_byte <- 4 | |
#------read file----- | |
#create file connection | |
zz <- file(path_binary_file, "rb") | |
# calculate number of element bt file size | |
n_total_element <- file.info(path_binary_file)$size/n_element_byte | |
x <- matrix(readBin(zz, what="double", size=n_element_byte, n=n_total_element), ncol = n_dimension) | |
close(zz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment