I'd like to be compare binary or hexadecimal numbers to a range in R.
Specifically, I have hex codes of aircrafts (e.g. 4067F7) and I'd like to know which country that code is allocated to (e.g. UK). The country allocations are given as binary ranges.
cf. the table here: http://www.kloth.net/radio/icao24alloc.php
I figured that I can convert from hex to binary with hex2bin but after that I'm stuck as I can't figure out how to compare the binaries to the ranges.
Thanks!
Related
I have a data frame in R that I want to analyse. I want to know how many specific numbers are in a data frame column. for example, I want to know the frequency of number 0.9998558 by using
sum(deviation_multiple_regression_3cell_types_all_spots_all_intersection_genes_exclude_50_10dec_rowSums_not_0_for_moran_scaled[,3]== 0.9998558)
However, it seems that the decimal shown is not the actual one (it must be 0.9998558xxxxx) since the result I got from using the above command is 0 (the correct one should be 3468). How can I access that number without knowing the exact decimal numbers so that I get the correct answer? Please see the screenshot below.
The code below gives the number of occurrences in the column.
x <- 0.9998558
length(which(df$a==x))
If you are looking for numbers stating with 0.9998558, I think you can do it in two different ways: working with data as numeric or as character.
Let x be your variable:
Data as character
This way counts exactly what you are looking for
sum(substr(as.character(x),1,9)=="0.9998558")
Data as numeric
This will include all the values with a difference with the reference value lower than 1e-7; this may include values not starting exactly with 0.9998558
sum(abs(x-0.9998558)<1e-7)
You can also "truncate" the numbers in your vector and compare them with the number you want. Here, we write 10^7 because 7 is the number of decimals you want to compare.
sum(trunc(x*10^7)/10^7)==0.9998558)
I am currently having a problem with some texts in my dataset, where it has Chinese and number mixed strings, and cannot be easily transferred and handled for later data processing. For example, in the date column, I have month-day written as --月--日, which corresponds to -- month and --day. Also, the column for deviation date, which describes how far it deviates from the average. 提前--天 means advance --days, 推迟--天 means postpone -- days. Is there a smart way in R that I can efficiently convert these Chinese and number mixed text into English and number mixed text?
Thanks
snapshot of mixed strings
Does anybody know of a package that can be used to extract all dates from a block of text using R? I am looking for something similar to search_dates from dateparser.search in python (see pg 11 of this: https://readthedocs.org/projects/dateparser/downloads/pdf/latest/#:~:text=dateparser.search.,or%20time%20and%20parse%20them.&text=text%20(str%7Cunicode)%20%E2%80%93,date%20and%2For%20time%20expressions.)
I have tried searching google, but for R, I only find options to convert a character string (with no surplus characters) to a date string. I am more after something that can find and identify multiple dates in a range of different formats in a large block of text.
I have to read data from an archaic fixed-width table. Some of the fields are in the IBM packed decimal Format, and I have no idea how to get the numbers.
for example, one line of my Input file might look like this:
140101 72 ‘ëm§11
where ‘ëm§1 is actually the packed decimal representation of the number 3153947. SAS can read this field correctly via INPUT gew pd4.4
Anyone any expericnes with this issue?
I know that in Java there is the class BigInteger, that permits to treat the integers in their full representation via Strings. Is there something similar in R? I use integers to represent indices in my data structure, and I need to keep that representation as exact as possible and hence not to obtain indices such as ``7.897557e+14''. Thanks in advance.