[R] reading in hexadecimal data - not working with data ending in E

Duncan Murdoch murdoch.duncan at gmail.com
Wed Oct 8 21:57:58 CEST 2014


On 08/10/2014 7:02 AM, mark.hogue at srs.gov wrote:
> I am trying to read in data from an instrument that is recorded in
> hexadecimal format. Using either:
>
>      y.hex <- read.table(file="hex.data", as.is=TRUE)
>
> or
>
>      y.hex <- read.table(file="hex.data", text=TRUE)
>
> gets all the data in just fine except points like `055E` or `020E`. In
> these cases, the E is stripped so I get just 055 or 020.

You need to read the ?read.table help.  as.is and text don't do anything 
like what you want.

The argument you need to use is colClasses.  I think you want to set it 
to "character".

Duncan Murdoch
>
> The question is how should this data be imported to avoid the E-ending
> problem?
>
> (By the way, my follow-up is to convert this data using, `y <-
> strtoi(y.hex, 16L)`)
>
> Thanks for any suggestions,
>
> Mark Hogue
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list