Reputation: 81
I want to write some integers to a binary file and I want to force them to be written in two bytes even if a few of them don't fit (trim these). I get an error when I do this (below). Is there another way to do it? Thanks!
Error in writeBin(Info_Differences, file_differences, size = 2) : size 2 is unknown on this machine
Upvotes: 2
Views: 315
Reputation: 40831
Yeah, you probably have doubles that look like integers. Try this:
writeBin(as.integer(Info_Differences), file_differences, size = 2)
or, to check what Info_Differences really is:
typeof(Info_Differences) # double or integer?
Upvotes: 1