How to Convert Strings into Numbers under C-Shell?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to Convert Strings into Numbers under C-Shell?
# 8  
Old 01-17-2009
Hi.

The "R" system is patterned after UNIX "S", but is free. See The R Project for Statistical Computing for more information.

The R system is intended to be used interactively so that one can explore data. However, there is a facility for batch jobs, and that is convenient for demonstrations. Here is such a set of commands:
Code:
test0 <- c(1, 2, 3)
test3 <- c(4.985e-10, 5.130e-10, 5.486e-10, 6.023e-10, 7.015e-10)
test4 <- c(4.869e-10, 5.010-10, 5.363e-10, 5.895e-10, 6.887e-10)

diff <- test3 - test4

diff

plot(diff)

quit()

Which, when run by R will produce this text output:
Code:
> test0 <- c(1, 2, 3)
> test3 <- c(4.985e-10, 5.130e-10, 5.486e-10, 6.023e-10, 7.015e-10)
> test4 <- c(4.869e-10, 5.010-10, 5.363e-10, 5.895e-10, 6.887e-10)
>
> diff <- test3 - test4
>
> diff
[1] 1.16e-11 4.99e+00 1.23e-11 1.28e-11 1.28e-11
>
> plot(diff)
>
> quit()

And there is a postscript plot file also generated.

In some sense, this is using a very big hammer, because this is a very small part of R. Still, if you manipulate data and need to do statistical calculations, this is a very nice system, especially since the style is very UNIX-like ... cheers, drl
# 9  
Old 01-18-2009
Wow, thank you for all the examples under different tools. I will check if zsh exists on my work computer on Monday. My data was actually very small. There are probably 2-6 pairs of 5 numeric values at most. The values were obtained by several grep commands piped together. I work under UNIX through a windows program, so my Excel is always available. It just takes an extra step to output the data from UNIX to something Excel can read.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert list of numbers to text range

Hi, I'd like to take a list of numbers (with a prefix) and convert to a range, for example: cn001 cn004 cn016 cn017 cn018 cn019 cn020 cn021 cn031 cn032 cn038 cn042 cn043 cn044 cn045 (5 Replies)
Discussion started by: chrissycc
5 Replies

2. Shell Programming and Scripting

Sort strings containing numbers

How can I sort this, first by 2nd field then by 1st field. tried sort -b -k 2,2 Input: AS11 AB1 BD34 AB10 AF12 AC2 A345 AB10 R134 AB2 456 AC10 TTT2 BD12 desired output: AS11 AB1 R134 AB2 A345 AB10 BD34 AB10 AF12 AC2 456 AC10 TTT2 BD12 (2 Replies)
Discussion started by: aydj
2 Replies

3. Shell Programming and Scripting

Sort strings with numbers

I want to sort my data first by the 2nd field then by the first field. I can't use sort -V because I don't have gnu sort and cannot install one. How do I go about this? Input: G456 KT1 34 K234 KT10 45 L2 KT2 26 H5 LAF2 28 F3 LAF2 36 Output: G456 KT1 34 L2 KT2 26 K234 KT10 45 F3... (14 Replies)
Discussion started by: aydj
14 Replies

4. Shell Programming and Scripting

Convert Columns in Rows delimited by a strings

Hi Gurus, I have a file that contain inventory information from someones computers: UserName domain\user1 DNSHostName machine1 Caption Microsoft Windows 7 Professional OSArchitecture 64 bits SerialNumber XXX Name HP EliteBook Revolve 810 G1 NumberOfProcessors 1 Name Intel(R)... (2 Replies)
Discussion started by: gilmore666
2 Replies

5. Shell Programming and Scripting

Replace a multi-line strings or numbers

Hi I have no experience in Unix so any help would be appreciated I have the flowing text 235543 123 45654 199 225 578 45654 199 225 I need to find this sequence from A file 45654 199 225 (22 Replies)
Discussion started by: khaled79
22 Replies

6. UNIX for Dummies Questions & Answers

Finding numbers in lines with strings and number and doing some manipulation

Hi, I want to write a script that does something like this: I have a file, in which in every line, there is a string of words, and followed by some space, a number. Now, I want to identify the line, which has the largest startFace number (say m=8118), take that number and add it to the... (2 Replies)
Discussion started by: super_commando
2 Replies

7. Programming

C++ Formatting Numbers to Strings

Hi All, Sorry to say I have 0 experience writing C++ but have been asked to write a piece of code that will take a double input and an integer for number of decimal places as well as integer for padding and output a string that represents the double formatted (with comma thousand separators -... (2 Replies)
Discussion started by: Leedor
2 Replies

8. Shell Programming and Scripting

How to convert hex numbers to decimal ?

Hi, please tell me how to convert hex number to decimal 000000E7 000000000002640D 0000000000025B16 and seconds to minutes, hours, days, months, years bytes to kbytes, mbytes , gbytes read the following examples while read a b do printf "%5d %5d\n" "0x$a" "0x$b" done < "$FILE"... (15 Replies)
Discussion started by: jack2
15 Replies

9. Shell Programming and Scripting

extracting numbers from strings

Hello all, I am being dumb with this and I know there is a simple solution. I have a file with the follwing lines bc stuff (more)...............123 bc stuffagain (moretoo)............0 bc stuffyetagain (morehere)......34 failed L3 thing..............1 failed this... (2 Replies)
Discussion started by: gobi
2 Replies

10. UNIX for Advanced & Expert Users

Req on how to convert hex numbers to decimals

Hi, If i have an input as c1:41 c2:0x0000.00046b3e I want to make output display as c1:41 c2:224062 . Basically convert first part 0x0000 (as hex) to decimal which is 0 and convert second part 0x00046b3e (as hex) to decimal which is 289598 and as such add both parts namely... (3 Replies)
Discussion started by: hare
3 Replies
Login or Register to Ask a Question