numbers

R: assign incremental numbers to rows containing a same label

冷暖自知 提交于 2019-12-03 18:15:45
问题 Given a dataframe df as follows: chrom position strand value label chr1 17432 - 0 romeo chr1 17433 - 0 romeo chr1 17434 - 0 romeo chr1 17435 - 0 romeo chr1 17409 - 1 juliet chr1 17410 - 1 juliet chr1 17411 - 1 juliet For each group of labels, I would like to number the lines that share the same label starting from 1 and put those numbers in a new column. (I don't just want to count them, the goal is to number them). The output should look something like this: chrom position strand value label

How to write own isnumber() function?

只谈情不闲聊 提交于 2019-12-03 18:08:06
问题 I'm new to C and I'm thinking how to write this function myself. I take a parameter from command line, so it is stored in argv array and I want to decide whether it is or isn't number. What is the easiest way to do this? Thank you #include <stdio.h> int isNumber(int *param) { if (*param > 0 && *param < 128) return 1; return 0; } int main(int argc, char *argv[]) { if (argc == 2) isNumber(argv[1]); else printf("Not enought parameters."); return 0; } 回答1: Read about strtol(3). You could use it

Extract number from string javascript

泄露秘密 提交于 2019-12-03 17:36:04
Is anyone know a way to extract numbers from a string in Javascript ? Example: 1 banana + 1 pineapple + 3 oranges My purpose is to have the result in a array or JSON or something else Result : [1,1,3] var result= "1 banana + 1 pineapple + 3 oranges"; result.match(/[0-9]+/g) Using String.prototype.match() and parseInt() : let s = "1 banana + 1 pineapple + 3 oranges"; let result = s.match(/\d+/g).map(n => parseInt(n)); console.log(result); Use this regex / -> start \d+ -> digit /g -> end and g for global match var str="1 banana + 1 pineapple + 3 oranges",mats=[]; str.match(/\d+/g).forEach

First N digits of a long number in constant-time?

血红的双手。 提交于 2019-12-03 17:18:38
In a Project Euler problem I need to deal with numbers that can have hundreds of digits. And I need to perform some calculation on the first 9 digits. My question is: what is the fastest possible way to determine the first N digits of a 100-digit integer? Last N digits are easy with modulo/remainder. For the first digits I can apply modulo 100 times to get digit by digit, or I can convert the number to String and truncate, but they all are linear time. Is there a better way? You can count number of digits with this function: (defn dec-digit-count [n] (inc (if (zero? n) 0 (long (Math/floor

is_numeric() vs. is_float() vs. is_int()

回眸只為那壹抹淺笑 提交于 2019-12-03 17:12:50
问题 My understanding is... if is_numeric($input) === true then either is_float($input) === true OR is_int($input) === true OR $input === 0 OR $input is a numeric string (meaning it'd satisfy one of the first 3 if it weren't wrapped in quotes). Is that accurate? Are there other differences? 回答1: See PHP's documentation on is_numeric. It talks about everything that is allowed, and it's more than is_float and is_int . It's also important to note that is_int only works on things that are type integer

Why do i get #### in the NUMBER column after format… Oracle?

怎甘沉沦 提交于 2019-12-03 17:07:11
问题 I have two problematic columns: Fee NUMBER type, AdjFee also NUMBER. After column Fee format a5; select Fee ID smth from Visit; i get Fee ID smth #### 123 klkl #### 654 rfjgr 回答1: You can adjust the number of digits you want SQL*Plus to use to display the numeric data just as you adjust the number of characters used to display character data. Something like column fee format 999999999.99 will tell SQL*Plus to display up to 9 digits before the decimal point and two after the decimal point. You

Formatting a number with a metric prefix? [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-03 16:29:38
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Engineering notation in C#? Whether a metric prefix is preferable to the scientific notation may be up for debate but i think it has its use-cases for physical units. I had a look around but it seems .NET does not have anything like that built in, or am i mistaken about that? Any method of achieving that would be fine. As a clarification: The goal is to display any given number as a floating point or integer

PHP - Find a string in file then show it's line number

别等时光非礼了梦想. 提交于 2019-12-03 15:57:37
问题 I have an application which needs to open the file, then find string in it, and print a line number where is string found. For example, file example.txt contains few hashes: APLF2J51 1a79a4d60de6718e8e5b326e338ae533 EEQJE2YX 66b375b08fc869632935c9e6a9c7f8da O87IGF8R c458fb5edb84c54f4dc42804622aa0c5 APLF2J51 B7TSW1ZE 1e9eea56686511e9052e6578b56ae018 EEQJE2YX affb23b07576b88d1e9fea50719fb3b7 So, I want to PHP search for "1e9eea56686511e9052e6578b56ae018" and print out its line number, in this

support new Indian currency symbol in java

一曲冷凌霜 提交于 2019-12-03 15:47:02
how to format a number with new Indian currency symbol(₹) using java.if there is any workaround let us share . Aaron Until Java properly supports the new character you can manually specify the currency symbol using its unicode value. The Unicode for the Indian currency symbol is U+20B9 So to insert this character into a java string you specify it as \u20B9 instead of the default DecimalFormat currency value of \u00A4 For example: DecimalFormat formatter = new DecimalFormat("\u20B9 000"); Unfortunately this will hard code your output to always display the rupee symbol. If you need to support

Formatting Numbers in Swift 3

邮差的信 提交于 2019-12-03 14:58:55
I want to format number to this: 123.234.234.234 from 123234234234 depends on what the user types into the text field. I don't want to manage currency, it's not about currency, it is about the user has to type in a number and this number should be formatted correctly to be easier to read. Not with a comma, with a dot. I found only currency stuff in the whole research What you are looking for is probably groupingSeparator of NumberFormatter let formater = NumberFormatter() formater.groupingSeparator = "." formater.numberStyle = .decimal let formattedNumber = formater.string(from: number) You