Unit conversions: Difference between revisions
No edit summary |
(→Answer) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 103: | Line 103: | ||
F|F|Unit|1|Farad, the SI unit of capacitance | F|F|Unit|1|Farad, the SI unit of capacitance | ||
Wb|Wb|Unit|1|Weber, the SI unit of magnetic flux | Wb|Wb|Unit|1|Weber, the SI unit of magnetic flux | ||
-|%|Unit|0.01|Fraction | |||
</t2b> | </t2b> | ||
==Rationale== | ==Rationale== | ||
===Help=== | |||
Start out by filling in the amount in the first field. In the second field write the original units from which you wish to convert. The third field is for the units you wish to convert the amount to. If you leave this blank, the amount will be converted to basic SI units. | |||
There are several things to notify when filling the second and third fields: | |||
*Mark the units between '''apostrophies'''. | |||
*Leave a space between different units. | |||
*'''Do not''' leave a space after a division slash. | |||
Press ''Run code'' to execute the conversion tool. Wait a moment for it to complete the conversion. | |||
==See also== | ==See also== |
Latest revision as of 08:09, 13 June 2012
Moderator:Jouni (see all) |
This page is a stub. You may improve it into a full page. |
Upload data
|
- The code related to this tool is now a part of Opasnet (R library) (function convert.units).
Convert almost any unit to any other unit!
Question
How to convert data from one unit to another in R?
Answer
We need conversion factors, which are listed below, and a code that does the actual conversion. Function convert.units is used to perform conversions. It has three parameters:
- x: a numeric vector of values that are to be converted.
- tounit: a character vector of units that are preferred in the output. This can contain more units than needed, as long as the the entries are exclusive (i.e., only one unit for length, only one for energy etc.).
- fromunit: a character vector of units used in the input. It has (or is coerced to) the same size as x.
Composite units can be used, e.g. ug /m3. Then, each part of the unit is converted separately, e.g. micrograms to picograms and cubic metre to litres.
> convert.units(1, tounit = c("pg", "l"), fromunit = "ug /m3")
will result in
Unit | Result |
---|---|
pg /l | 1000 |
Note that in the units, different parts are separated with space, but the units in the denominator must have the slash before them without a space.
Obs | From | To | Type | Result | Description |
---|---|---|---|---|---|
1 | Prefix | 1 | basic unit | ||
2 | da | Prefix | 10 | deca | |
3 | h | Prefix | 100 | hecto | |
4 | k | Prefix | 1000 | kilo | |
5 | M | Prefix | 1e+6 | mega | |
6 | G | Prefix | 1e+9 | giga | |
7 | T | Prefix | 1e+12 | tera | |
8 | P | Prefix | 1e+15 | peta | |
9 | E | Prefix | 1e+18 | exa | |
10 | Z | Prefix | 1e+21 | zetta | |
11 | Y | Prefix | 1e+24 | yotta | |
12 | d | Prefix | 0.1 | deci | |
13 | c | Prefix | 0.01 | centi | |
14 | m | Prefix | 0.001 | milli | |
15 | μ | Prefix | 1e-6 | micro | |
16 | u | Prefix | 1e-6 | micro | |
17 | n | Prefix | 1e-9 | nano | |
18 | p | Prefix | 1e-12 | pico | |
19 | f | Prefix | 1e-15 | femto | |
20 | a | Prefix | 1e-18 | atto | |
21 | z | Prefix | 1e-21 | zepto | |
22 | y | Prefix | 1e-24 | yocto | |
23 | J | J | Unit | 1 | Joule, the Si unit of energy |
24 | Wh | J | Unit | 3600 | 1 Wh = 1 Wh * 3600 s/h = 3600 Ws = 3600 MJ |
25 | toe | J | Unit | 3.5e+10 | 1 toe = 1000 kgoe = 1000 kg * 35 MJ/kg = 35000 MJ (energy as tons of oil equivalent) |
26 | cal | J | Unit | 4.1868 | calorie |
27 | eV | J | Unit | 1.602176565e-19 | electronvolt |
28 | g | g | Unit | 1 | gram, the SI unit of mass (although the definition is based on kg) |
29 | ton | g | Unit | 1e+6 | metric ton |
30 | tn | g | Unit | 1e+6 | metric ton |
31 | lb | g | Unit | 453.59237 | international avoirdupois pound |
32 | s | s | Unit | 1 | second, the SI unit of time |
33 | min | s | Unit | 60 | minute |
34 | h | s | Unit | 3600 | hour |
35 | d | s | Unit | 86400 | day |
36 | a | s | Unit | 31557600 | year (assuming 365.25 days per year) |
37 | m | m | Unit | 1 | metre, the SI unit of length |
38 | in | m | Unit | 0.0254 | inch (strangely, some people still use these) |
39 | ft | m | Unit | 0.3048 | foot = 12 inches |
40 | mi | m | Unit | 1609.344 | mile = 5280 feet |
41 | Å | m | Unit | 1e-10 | 1 angstrom = 100 pm |
42 | m3 | m3 | Unit | 1 | cubic metre, the SI unit of volume |
43 | l | m3 | Unit | 0.001 | litre |
44 | m^3 | m3 | Unit | 1 | |
45 | A | A | Unit | 1 | Ampere, the SI unit of electric current |
46 | V | V | Unit | 1 | Volt, the SI unit of electric potential |
47 | N | N | Unit | 1 | Newton, the SI unit of force |
48 | W | W | Unit | 1 | Watt, the SI unit of power |
49 | hp | W | Unit | 735.498 75 | horsepower (metric) |
50 | Pa | Pa | Unit | 1 | Pascal, the SI unit of pressure |
51 | psi | Pa | Unit | 6894.757 | pound-force per square inch |
52 | bar | Pa | Unit | 100000 | bar |
53 | atm | Pa | Unit | 101325 | atmosphere (standard) |
54 | mol | mol | Unit | 1 | mole, the SI unit of substance amount |
55 | M | mol /l | Unit | 1 | |
56 | Hz | Hz | Unit | 1 | Hertz, the SI unit of frequency |
57 | Hz | /s | Unit | 1 | |
58 | C | C | Unit | 1 | Coulomb, the SI unit of electric quantity |
59 | O | O | Unit | 1 | Ohm, the SI unit of resistance |
60 | F | F | Unit | 1 | Farad, the SI unit of capacitance |
61 | Wb | Wb | Unit | 1 | Weber, the SI unit of magnetic flux |
62 | - | % | Unit | 0.01 | Fraction |
Rationale
Help
Start out by filling in the amount in the first field. In the second field write the original units from which you wish to convert. The third field is for the units you wish to convert the amount to. If you leave this blank, the amount will be converted to basic SI units.
There are several things to notify when filling the second and third fields:
- Mark the units between apostrophies.
- Leave a space between different units.
- Do not leave a space after a division slash.
Press Run code to execute the conversion tool. Wait a moment for it to complete the conversion.
See also
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>