2011-11-10 18 views
8

Simplemente curioso: ¿hay algún paquete o conjunto de datos que contenga valores para las constantes físicas? Solo pregunto porque ahora he escrito 273.15 (conversión Celsius a Kelvin) incorrecto varias veces. =)Constantes físicas en R

+0

[Este] (http://stackoverflow.com/q/7214781/324364) pregunta puede ser útil, y probablemente sea (casi) un duplicado. – joran

Respuesta

3

Los paquetes marelac y dielectric ambos tienen algunas constantes físicas, pero no esa en particular. marelac::convert_T hará las conversiones de temperatura.

1

debería ser bastante fácil de descargar y analizar esta:

http://physics.nist.gov/cuu/Constants/Table/allascii.txt

  • se ve como formato fijo, pero esos triples numéricos podría ser un poco más incómoda. Sin embargo, no tiene su 273.15, porque tal vez no sea una "constante física" según alguna definición. Pero si alguna vez necesitas el helion blindado para blindar la protón mag. mamá. relación, está allí.

[en realidad, rayar eso, ese archivo no está muy bien formateado, y un par de las constantes rompen incluso el formato aproximado de ancho fijo. Necesidades de procesamiento más listo para ser útil]

+0

No está muy bien formateado, pero no está tan mal. Al menos es de ancho fijo. Una vez que se han definido los anchos, solo necesitamos algunos 'gsub' y' as.numeric' ... ¡sencillos, en el gran esquema de ejercicios de limpieza de datos! – MichaelChirico

2

Te recomendamos 2 opciones:

1) Si necesita estas constantes todo el tiempo que podría hacer uso de la biblioteca .First en forma de C2K<-273.15. Puede asignar constantes y almacenarlas allí. Para obtener más información al respecto, consulte http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_first.html

2) Si desea utilizar los archivos solo algunas veces guarde las constantes en un archivo de texto en el mismo formato que el anterior x<-273.15 y luego proceda la ruta a este archivo utilizando la función fuente en los siguientes formato: source(C:\Users\PAth to save file text\formulas.txt)

Esto le da más control sobre las constantes que depender de un paquete que puede contener o no lo que desea.

+0

Esto suena como un enfoque muy interesante. ¿Puede explicar cómo obtendría la fuente para llamar a la conversión particular si tengo más de una conversión almacenada allí? Además, esa es una manera bastante fácil de configurar vim como editor. ¿Cómo puedo volver a pasar los comandos a R (probé CTRL + R pero eso no funcionó)? – thequerist

10

Es una bastante grande tarea de montar esta información, pero algunas de las constantes termodinámicas están disponibles en marelac:

> convert_T(0, "K") 
    K  C  F 
1 0 -273.15 -459.67 

Además de los recursos de I en my answer to the question that that @joran cited estos son más recursos en el NIST:

http://www.nist.gov/pml/wmd/metric/si-units.cfm

http://www.nist.gov/pml/wmd/pubs/upload/AppC-11-hb44-final.pdf

http://www.nist.gov/pml/wmd/pubs/upload/AppC-11-hb44-final.pdf

me dio a la tarea de leer la tabla Constantes NIST, por lo que la edición de la conversión a numérico sería razonable, y este fue el código de entrada:

require(foreign) 
fundconst <- read.fwf("allascii.txt", 
         widths=diff(c(0,54, 77, 99, 111)), 
         header=FALSE, skip=12) 
fundconst$V1 <- gsub(" ", "", fundconst[,1]) # strips some of hte white-space 
fundconst$V2 <- as.numeric(gsub(" ", "", fundconst[,2])) 
fundconst$V3 <- as.numeric(gsub(" ", "", fundconst[,3])) 
names(fundconst) <- c("Quantity", "Value", "Uncertainty", "Unit") 
dput(fundconst) 

.... y aquí es el versión de dput:

fundconst <- 
    structure(list(Quantity = c("alpha particle-electron mass ratio", 
"alpha particle mass ", "alpha particle mass energy equivalent ", 
"alpha particle mass energy equivalent in MeV", "alpha particle mass in u", 
"alpha particle molar mass ", "alpha particle-proton mass ratio", 
"Angstrom star ", "atomic mass constant", "atomic mass constant energy equivalent", 
"atomic mass constant energy equivalent in MeV ", "atomic mass unit-electron volt relationship ", 
"atomic mass unit-hartree relationship ", "atomic mass unit-hertz relationship ", 
"atomic mass unit-inverse meter relationship ", "atomic mass unit-joule relationship ", 
"atomic mass unit-kelvin relationship", "atomic mass unit-kilogram relationship", 
"atomic unit of 1st hyperpolarizability", "atomic unit of 2nd hyperpolarizability", 
"atomic unit of action ", "atomic unit of charge ", "atomic unit of charge density ", 
"atomic unit of current", "atomic unit of electric dipole mom. ", 
"atomic unit of electric field ", "atomic unit of electric field gradient", 
"atomic unit of electric polarizability", "atomic unit of electric potential ", 
"atomic unit of electric quadrupole mom. ", "atomic unit of energy ", 
"atomic unit of force", "atomic unit of length ", "atomic unit of mag. dipole mom. ", 
"atomic unit of mag. flux density", "atomic unit of magnetizability", 
"atomic unit of mass ", "atomic unit of mom.um ", "atomic unit of permittivity ", 
"atomic unit of time ", "atomic unit of velocity ", "Avogadro constant ", 
"Bohr magneton ", "Bohr magneton in eV/T ", "Bohr magneton in Hz/T ", 
"Bohr magneton in inverse meters per tesla ", "Bohr magneton in K/T", 
"Bohr radius ", "Boltzmann constant", "Boltzmann constant in eV/K", 
"Boltzmann constant in Hz/K", "Boltzmann constant in inverse meters per kelvin ", 
"characteristic impedance of vacuum", "classical electron radius ", 
"Compton wavelength", "Compton wavelength over 2 pi", "conductance quantum ", 
"conventional value of Josephson constant", "conventional value of von Klitzing constant ", 
"Cu x unit ", "deuteron-electron mag. mom. ratio ", "deuteron-electron mass ratio", 
"deuteron g factor ", "deuteron mag. mom.", "deuteron mag. mom. to Bohr magneton ratio ", 
"deuteron mag. mom. to nuclear magneton ratio", "deuteron mass ", 
"deuteron mass energy equivalent ", "deuteron mass energy equivalent in MeV", 
"deuteron mass in u", "deuteron molar mass ", "deuteron-neutron mag. mom. ratio", 
"deuteron-proton mag. mom. ratio ", "deuteron-proton mass ratio", 
"deuteron rms charge radius", "electric constant ", "electron charge to mass quotient", 
"electron-deuteron mag. mom. ratio ", "electron-deuteron mass ratio", 
"electron g factor ", "electron gyromag. ratio ", "electron gyromag. ratio over 2 pi ", 
"electron-helion mass ratio", "electron mag. mom.", "electron mag. mom. anomaly", 
"electron mag. mom. to Bohr magneton ratio ", "electron mag. mom. to nuclear magneton ratio", 
"electron mass ", "electron mass energy equivalent ", "electron mass energy equivalent in MeV", 
"electron mass in u", "electron molar mass ", "electron-muon mag. mom. ratio ", 
"electron-muon mass ratio", "electron-neutron mag. mom. ratio", 
"electron-neutron mass ratio ", "electron-proton mag. mom. ratio ", 
"electron-proton mass ratio", "electron-tau mass ratio ", "electron to alpha particle mass ratio ", 
"electron to shielded helion mag. mom. ratio ", "electron to shielded proton mag. mom. ratio ", 
"electron-triton mass ratio", "electron volt ", "electron volt-atomic mass unit relationship ", 
"electron volt-hartree relationship", "electron volt-hertz relationship", 
"electron volt-inverse meter relationship", "electron volt-joule relationship", 
"electron volt-kelvin relationship ", "electron volt-kilogram relationship ", 
"elementary charge ", "elementary charge over h", "Faraday constant", 
"Faraday constant for conventional electric current", "Fermi coupling constant ", 
"fine-structure constant ", "first radiation constant", "first radiation constant for spectral radiance", 
"hartree-atomic mass unit relationship ", "hartree-electron volt relationship", 
"Hartree energy", "Hartree energy in eV", "hartree-hertz relationship", 
"hartree-inverse meter relationship", "hartree-joule relationship", 
"hartree-kelvin relationship ", "hartree-kilogram relationship ", 
"helion-electron mass ratio", "helion g factor ", "helion mag. mom.", 
"helion mag. mom. to Bohr magneton ratio ", "helion mag. mom. to nuclear magneton ratio", 
"helion mass ", "helion mass energy equivalent ", "helion mass energy equivalent in MeV", 
"helion mass in u", "helion molar mass ", "helion-proton mass ratio", 
"hertz-atomic mass unit relationship ", "hertz-electron volt relationship", 
"hertz-hartree relationship", "hertz-inverse meter relationship", 
"hertz-joule relationship", "hertz-kelvin relationship ", "hertz-kilogram relationship ", 
"inverse fine-structure constant ", "inverse meter-atomic mass unit relationship ", 
"inverse meter-electron volt relationship", "inverse meter-hartree relationship", 
"inverse meter-hertz relationship", "inverse meter-joule relationship", 
"inverse meter-kelvin relationship ", "inverse meter-kilogram relationship ", 
"inverse of conductance quantum", "Josephson constant", "joule-atomic mass unit relationship ", 
"joule-electron volt relationship", "joule-hartree relationship", 
"joule-hertz relationship", "joule-inverse meter relationship", 
"joule-kelvin relationship ", "joule-kilogram relationship ", 
"kelvin-atomic mass unit relationship", "kelvin-electron volt relationship ", 
"kelvin-hartree relationship ", "kelvin-hertz relationship ", 
"kelvin-inverse meter relationship ", "kelvin-joule relationship ", 
"kelvin-kilogram relationship", "kilogram-atomic mass unit relationship", 
"kilogram-electron volt relationship ", "kilogram-hartree relationship ", 
"kilogram-hertz relationship ", "kilogram-inverse meter relationship ", 
"kilogram-joule relationship ", "kilogram-kelvin relationship", 
"lattice parameter of silicon", "Loschmidt constant (273.15 K, 100 kPa)", 
"Loschmidt constant (273.15 K, 101.325 kPa)", "mag. constant ", 
"mag. flux quantum ", "molar gas constant", "molar mass constant ", 
"molar mass of carbon-12 ", "molar Planck constant ", "molar Planck constant times c ", 
"molar volume of ideal gas (273.15 K, 100 kPa) ", "molar volume of ideal gas (273.15 K, 101.325 kPa) ", 
"molar volume of silicon ", "Mo x unit ", "muon Compton wavelength ", 
"muon Compton wavelength over 2 pi ", "muon-electron mass ratio", 
"muon g factor ", "muon mag. mom.", "muon mag. mom. anomaly", 
"muon mag. mom. to Bohr magneton ratio ", "muon mag. mom. to nuclear magneton ratio", 
"muon mass ", "muon mass energy equivalent ", "muon mass energy equivalent in MeV", 
"muon mass in u", "muon molar mass ", "muon-neutron mass ratio ", 
"muon-proton mag. mom. ratio ", "muon-proton mass ratio", "muon-tau mass ratio ", 
"natural unit of action", "natural unit of action in eV s", "natural unit of energy", 
"natural unit of energy in MeV ", "natural unit of length", "natural unit of mass", 
"natural unit of mom.um", "natural unit of mom.um in MeV/c ", 
"natural unit of time", "natural unit of velocity", "neutron Compton wavelength", 
"neutron Compton wavelength over 2 pi", "neutron-electron mag. mom. ratio", 
"neutron-electron mass ratio ", "neutron g factor", "neutron gyromag. ratio", 
"neutron gyromag. ratio over 2 pi", "neutron mag. mom. ", "neutron mag. mom. to Bohr magneton ratio", 
"neutron mag. mom. to nuclear magneton ratio ", "neutron mass", 
"neutron mass energy equivalent", "neutron mass energy equivalent in MeV ", 
"neutron mass in u ", "neutron molar mass", "neutron-muon mass ratio ", 
"neutron-proton mag. mom. ratio", "neutron-proton mass difference", 
"neutron-proton mass difference energy equivalent", "neutron-proton mass difference energy equivalent MeV", 
"neutron-proton mass difference in u ", "neutron-proton mass ratio ", 
"neutron-tau mass ratio", "neutron to shielded proton mag. mom. ratio", 
"Newtonian constant of gravitation ", "Newtonian constant of gravitation over h-bar c", 
"nuclear magneton", "nuclear magneton in eV/T", "nuclear magneton in inverse meters per tesla", 
"nuclear magneton in K/T ", "nuclear magneton in MHz/T ", "Planck constant ", 
"Planck constant in eV s ", "Planck constant over 2 pi ", "Planck constant over 2 pi in eV s ", 
"Planck constant over 2 pi times c in MeV fm ", "Planck length ", 
"Planck mass ", "Planck mass energy equivalent in GeV", "Planck temperature", 
"Planck time ", "proton charge to mass quotient", "proton Compton wavelength ", 
"proton Compton wavelength over 2 pi ", "proton-electron mass ratio", 
"proton g factor ", "proton gyromag. ratio ", "proton gyromag. ratio over 2 pi ", 
"proton mag. mom.", "proton mag. mom. to Bohr magneton ratio ", 
"proton mag. mom. to nuclear magneton ratio", "proton mag. shielding correction", 
"proton mass ", "proton mass energy equivalent ", "proton mass energy equivalent in MeV", 
"proton mass in u", "proton molar mass ", "proton-muon mass ratio", 
"proton-neutron mag. mom. ratio", "proton-neutron mass ratio ", 
"proton rms charge radius", "proton-tau mass ratio ", "quantum of circulation", 
"quantum of circulation times 2", "Rydberg constant", "Rydberg constant times c in Hz", 
"Rydberg constant times hc in eV ", "Rydberg constant times hc in J", 
"Sackur-Tetrode constant (1 K, 100 kPa)", "Sackur-Tetrode constant (1 K, 101.325 kPa)", 
"second radiation constant ", "shielded helion gyromag. ratio", 
"shielded helion gyromag. ratio over 2 pi", "shielded helion mag. mom. ", 
"shielded helion mag. mom. to Bohr magneton ratio", "shielded helion mag. mom. to nuclear magneton ratio ", 
"shielded helion to proton mag. mom. ratio ", "shielded helion to shielded proton mag. mom. ratio", 
"shielded proton gyromag. ratio", "shielded proton gyromag. ratio over 2 pi", 
"shielded proton mag. mom. ", "shielded proton mag. mom. to Bohr magneton ratio", 
"shielded proton mag. mom. to nuclear magneton ratio ", "speed of light in vacuum", 
"standard acceleration of gravity", "standard atmosphere ", "standard-state pressure ", 
"Stefan-Boltzmann constant ", "tau Compton wavelength", "tau Compton wavelength over 2 pi", 
"tau-electron mass ratio ", "tau mass", "tau mass energy equivalent", 
"tau mass energy equivalent in MeV ", "tau mass in u ", "tau molar mass", 
"tau-muon mass ratio ", "tau-neutron mass ratio", "tau-proton mass ratio ", 
"Thomson cross section ", "triton-electron mass ratio", "triton g factor ", 
"triton mag. mom.", "triton mag. mom. to Bohr magneton ratio ", 
"triton mag. mom. to nuclear magneton ratio", "triton mass ", 
"triton mass energy equivalent ", "triton mass energy equivalent in MeV", 
"triton mass in u", "triton molar mass ", "triton-proton mass ratio", 
"unified atomic mass unit", "von Klitzing constant ", "weak mixing angle ", 
"Wien frequency displacement law constant", "Wien wavelength displacement law constant " 
), Value = c(7294.2995361, 6.64465675e-27, 5.97191967e-10, 3727.37924, 
4.001506179125, 0.004001506179125, 3.97259968933, 1.00001495e-10, 
1.660538921e-27, 1.492417954e-10, 931.494061, 931494061, 34231776.845, 
2.2523427168e+23, 751300660420000, 1.492417954e-10, 10809540800000, 
1.660538921e-27, 3.206361449e-53, 6.23538054e-65, 1.054571726e-34, 
1.602176565e-19, 1081202338000, 0.00662361795, 8.47835326e-30, 
514220652000, 9.717362e+21, 1.6487772754e-41, 27.21138505, 4.486551331e-40, 
4.35974434e-18, 8.23872278e-08, 5.2917721092e-11, 1.854801936e-23, 
235051.7464, 7.891036607e-29, 9.10938291e-31, 1.99285174e-24, 
1.112650056e-10, 2.418884326502e-17, 2187691.26379, 6.02214129e+23, 
9.27400968e-24, 5.7883818066e-05, 13996245550, 46.6864498, 0.67171388, 
5.2917721092e-11, 1.3806488e-23, 8.6173324e-05, 20836618000, 
69.503476, 376.730313461, 2.8179403267e-15, 2.4263102389e-12, 
3.86159268e-13, 7.7480917346e-05, 4.835979e+14, 25812.807, 1.00207697e-13, 
-0.0004664345537, 3670.4829652, 0.8574382308, 4.33073489e-27, 
0.0004669754556, 0.8574382308, 3.34358348e-27, 3.00506297e-10, 
1875.612859, 2.013553212712, 0.002013553212712, -0.44820652, 
0.307012207, 1.99900750097, 2.1424e-15, 8.854187817e-12, -175882008800, 
-2143.923498, 0.00027244371095, -2.00231930436153, 176085970800, 
28024.95266, 0.00018195430761, -9.2847643e-24, 0.00115965218076, 
-1.00115965218076, -1838.2819709, 9.10938291e-31, 8.18710506e-14, 
0.510998928, 0.00054857990946, 5.4857990946e-07, 206.7669896, 
0.00483633166, 960.9205, 0.00054386734461, -658.2106848, 0.00054461702178, 
0.000287592, 0.000137093355578, 864.058257, -658.2275971, 0.00018192000653, 
1.602176565e-19, 1.07354415e-09, 0.03674932379, 241798934800000, 
806554.429, 1.602176565e-19, 11604.519, 1.782661845e-36, 1.602176565e-19, 
241798934800000, 96485.3365, 96485.3321, 1.166364e-05, 0.0072973525698, 
3.74177153e-16, 1.191042869e-16, 2.9212623246e-08, 27.21138505, 
4.35974434e-18, 27.21138505, 6579683920729000, 21947463.13708, 
4.35974434e-18, 315775.04, 4.85086979e-35, 5495.8852754, -4.255250613, 
-1.074617486e-26, -0.001158740958, -2.127625306, 5.00641234e-27, 
4.49953902e-10, 2808.391482, 3.0149322468, 0.0030149322468, 2.9931526707, 
4.4398216689e-24, 4.135667516e-15, 1.5198298460045e-16, 3.335640951e-09, 
6.62606957e-34, 4.7992434e-11, 7.37249668e-51, 137.035999074, 
1.3310250512e-15, 1.23984193e-06, 4.556335252755e-08, 299792458, 
1.986445684e-25, 0.01438777, 2.210218902e-42, 12906.4037217, 
4.8359787e+14, 6700535850, 6.24150934e+18, 2.29371248e+17, 1.509190311e+33, 
5.03411701e+24, 7.2429716e+22, 1.112650056e-17, 9.2510868e-14, 
8.6173324e-05, 3.1668114e-06, 20836618000, 69.503476, 1.3806488e-23, 
1.536179e-40, 6.02214129e+26, 5.60958885e+35, 2.061485968e+34, 
1.356392608e+50, 4.52443873e+41, 8.987551787e+16, 6.5096582e+39, 
5.431020504e-10, 2.6516462e+25, 2.6867805e+25, 1.2566370614e-06, 
2.067833758e-15, 8.3144621, 0.001, 0.012, 3.9903127176e-10, 0.119626565779, 
0.022710953, 0.022413968, 1.205883301e-05, 1.00209952e-13, 1.173444103e-14, 
1.867594294e-15, 206.7682843, -2.0023318418, -4.49044807e-26, 
0.00116592091, -0.00484197044, -8.89059697, 1.883531475e-28, 
1.692833667e-11, 105.6583715, 0.1134289267, 0.0001134289267, 
0.1124545177, -3.183345107, 0.1126095272, 0.0594649, 1.054571726e-34, 
6.58211928e-16, 8.18710506e-14, 0.510998928, 3.86159268e-13, 
9.10938291e-31, 2.73092429e-22, 0.510998928, 1.28808866833e-21, 
299792458, 1.3195909068e-15, 2.1001941568e-16, 0.00104066882, 
1838.6836605, -3.82608545, 183247179, 29.1646943, -9.6623647e-27, 
-0.00104187563, -1.91304272, 1.674927351e-27, 1.505349631e-10, 
939.565379, 1.008664916, 0.001008664916, 8.892484, -0.68497934, 
2.30557392e-30, 2.0721465e-13, 1.29333217, 0.00138844919, 1.00137841917, 
0.52879, -0.68499694, 6.67384e-11, 6.70837e-39, 5.05078353e-27, 
3.1524512605e-08, 0.02542623527, 0.00036582682, 7.62259357, 6.62606957e-34, 
4.135667516e-15, 1.054571726e-34, 6.58211928e-16, 197.3269718, 
1.616199e-35, 2.17651e-08, 1.220932e+19, 1.416833e+32, 5.39106e-44, 
95788335.8, 1.32140985623e-15, 2.1030891047e-16, 1836.15267245, 
5.585694713, 267522200.5, 42.5774806, 1.410606743e-26, 0.00152103221, 
2.792847356, 2.5694e-05, 1.672621777e-27, 1.503277484e-10, 938.272046, 
1.007276466812, 0.001007276466812, 8.88024331, -1.45989806, 0.99862347826, 
8.775e-16, 0.528063, 0.0003636947552, 0.0007273895104, 10973731.568539, 
3289841960364000, 13.60569253, 2.179872171e-18, -1.1517078, -1.1648708, 
0.01438777, 203789465.9, 32.43410084, -1.074553044e-26, -0.001158671471, 
-2.127497718, -0.761766558, -0.7617861313, 267515326.8, 42.5763866, 
1.410570499e-26, 0.001520993128, 2.792775598, 299792458, 9.80665, 
101325, 1e+05, 5.670373e-08, 6.97787e-16, 1.11056e-16, 3477.15, 
3.16747e-27, 2.84678e-10, 1776.82, 1.90749, 0.00190749, 16.8167, 
1.89111, 1.89372, 6.652458734e-29, 5496.9215267, 5.957924896, 
1.504609447e-26, 0.001622393657, 2.978962448, 5.0073563e-27, 
4.50038741e-10, 2808.921005, 3.0155007134, 0.0030155007134, 2.9937170308, 
1.660538921e-27, 25812.8074434, 0.2223, 58789254000, 0.0028977721 
), Uncertainty = c(2.9e-06, 2.9e-34, 2.6e-17, 8.2e-05, 6.2e-11, 
6.2e-14, 3.6e-10, 9e-17, 7.3e-35, 6.6e-18, 2.1e-05, 21, 0.024, 
1.6e+14, 530000, 6.6e-18, 9800000, 7.3e-35, 7.1e-61, 2.8e-72, 
4.7e-42, 3.5e-27, 24000, 1.5e-10, 1.9e-37, 11000, 2.1e+14, 1.6e-50, 
6e-07, 9.9e-48, 1.9e-25, 3.6e-15, 1.7e-20, 4.1e-31, 0.0052, 1.3e-37, 
4e-38, 8.8e-32, NA, 1.2e-28, 0.00071, 2.7e+16, 2e-31, 3.8e-14, 
310, 1e-06, 6.1e-07, 1.7e-20, 1.3e-29, 7.8e-11, 19000, 6.3e-05, 
NA, 2.7e-24, 1.6e-21, 2.5e-22, 2.5e-14, NA, NA, 2.8e-20, 3.9e-12, 
1.5e-06, 7.2e-09, 1e-34, 3.9e-12, 7.2e-09, 1.5e-34, 1.3e-17, 
4.1e-05, 7.7e-11, 7.7e-14, 1.1e-07, 2.4e-09, 1.8e-10, 2.1e-18, 
NA, 3900, 1.8e-05, 1.1e-13, 5.3e-13, 3900, 0.00062, 1.7e-13, 
2.1e-31, 2.7e-13, 2.7e-13, 7.5e-07, 4e-38, 3.6e-21, 1.1e-08, 
2.2e-13, 2.2e-16, 5.2e-06, 1.2e-10, 0.00023, 3.2e-13, 5.4e-06, 
2.2e-13, 2.6e-08, 5.5e-14, 1e-05, 7.2e-06, 1.7e-13, 3.5e-27, 
2.4e-17, 8.1e-10, 5300000, 0.018, 3.5e-27, 0.011, 3.9e-44, 3.5e-27, 
5300000, 0.0021, 0.0043, 5e-11, 2.4e-12, 1.7e-23, 5.3e-24, 2.1e-17, 
6e-07, 1.9e-25, 6e-07, 33000, 0.00011, 1.9e-25, 0.29, 2.1e-42, 
5e-06, 5e-08, 2.7e-34, 1.4e-11, 2.5e-08, 2.2e-34, 2e-17, 6.2e-05, 
2.5e-09, 2.5e-12, 2.5e-09, 3.1e-33, 9.1e-23, 7.6e-12, NA, 2.9e-41, 
4.4e-17, 3.3e-58, 4.4e-08, 9.4e-25, 2.7e-14, 2.3e-19, NA, 8.8e-33, 
1.3e-08, 9.8e-50, 4.2e-06, 1.1e+07, 300, 1.4e+11, 1e+10, 6.7e+25, 
2.2e+17, 6.6e+16, NA, 8.4e-20, 7.8e-11, 2.9e-12, 19000, 6.3e-05, 
1.3e-29, 1.4e-46, 2.7e+19, 1.2e+28, 9.1e+26, 6e+42, 2e+34, NA, 
5.9e+33, 8.9e-18, 2.4e+19, 2.4e+19, NA, 4.6e-23, 7.5e-06, NA, 
NA, 2.8e-19, 8.4e-11, 2.1e-08, 2e-08, 8e-13, 5.3e-20, 3e-22, 
4.7e-23, 5.2e-06, 1.3e-09, 1.5e-33, 6.3e-10, 1.2e-10, 2.2e-07, 
9.6e-36, 8.6e-19, 3.5e-06, 2.9e-09, 2.9e-12, 2.8e-09, 8.4e-08, 
2.8e-09, 5.4e-06, 4.7e-42, 1.5e-23, 3.6e-21, 1.1e-08, 2.5e-22, 
4e-38, 1.2e-29, 1.1e-08, 8.3e-31, NA, 1.1e-24, 1.7e-25, 2.5e-10, 
1.1e-06, 9e-07, 43, 6.9e-06, 2.3e-33, 2.5e-10, 4.5e-07, 7.4e-35, 
6.6e-18, 2.1e-05, 4.3e-10, 4.3e-13, 2.2e-07, 1.6e-07, 7.6e-37, 
6.8e-20, 4.2e-07, 4.5e-10, 4.5e-10, 4.8e-05, 1.6e-07, 8e-15, 
8e-43, 1.1e-34, 2.2e-17, 5.6e-10, 3.3e-10, 1.7e-07, 2.9e-41, 
9.1e-23, 4.7e-42, 1.5e-23, 4.4e-06, 9.7e-40, 1.3e-12, 7.3e+14, 
8.5e+27, 3.2e-48, 2.1, 9.4e-25, 1.5e-25, 7.5e-07, 4.6e-08, 6.3, 
1e-06, 3.3e-34, 1.2e-11, 2.3e-08, 1.4e-08, 7.4e-35, 6.6e-18, 
2.1e-05, 9e-11, 9e-14, 2.2e-07, 3.4e-07, 4.5e-10, 5.1e-18, 4.8e-05, 
2.4e-13, 4.7e-13, 5.5e-05, 17000, 3e-07, 9.6e-26, 2.3e-06, 2.3e-06, 
1.3e-08, 5.1, 8.1e-07, 2.7e-34, 1.4e-11, 2.5e-08, 1.1e-08, 3.3e-09, 
6.6, 1e-06, 3.5e-34, 1.7e-11, 3e-08, NA, NA, NA, NA, 2.1e-13, 
6.3e-20, 1e-20, 0.31, 2.9e-31, 2.6e-14, 0.16, 0.00017, 1.7e-07, 
0.0015, 0.00017, 0.00017, 1.3e-37, 5e-06, 7.6e-08, 3.8e-34, 2.1e-11, 
3.8e-08, 2.2e-34, 2e-17, 6.2e-05, 2.5e-09, 2.5e-12, 2.5e-09, 
7.3e-35, 8.4e-06, 0.0021, 53000, 2.6e-09), Unit = structure(c(NA, 
38L, 28L, 53L, 66L, 40L, NA, 41L, 38L, 28L, 53L, 17L, 16L, 24L, 
45L, 28L, 36L, 38L, 13L, 14L, 32L, 6L, 9L, 4L, 8L, 68L, 69L, 
12L, 67L, 10L, 28L, 58L, 41L, 34L, 65L, 35L, 38L, 39L, 21L, 1L, 
43L, 57L, 34L, 20L, 26L, 47L, 37L, 41L, 29L, 18L, 25L, 46L, 60L, 
41L, 41L, 41L, 63L, 27L, 60L, 41L, NA, NA, NA, 34L, NA, NA, 38L, 
28L, 53L, 66L, 40L, NA, NA, NA, 41L, 21L, 7L, NA, NA, NA, 64L, 
56L, NA, 34L, NA, NA, NA, 38L, 28L, 53L, 66L, 40L, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 28L, 66L, 16L, 24L, 45L, 28L, 
36L, 38L, 6L, 5L, 11L, 15L, 23L, NA, 71L, 72L, 66L, 17L, 28L, 
17L, 24L, 45L, 28L, 36L, 38L, NA, NA, 34L, NA, NA, 38L, 28L, 
53L, 66L, 40L, NA, 66L, 17L, 3L, 45L, 28L, 36L, 38L, NA, 66L, 
17L, 16L, 24L, 28L, 36L, 38L, 60L, 27L, 66L, 17L, 16L, 24L, 45L, 
36L, 38L, 66L, 17L, 16L, 24L, 45L, 28L, 38L, 66L, 17L, 16L, 24L, 
45L, 28L, 36L, 41L, 48L, 48L, 59L, 73L, 31L, 40L, 40L, 33L, 30L, 
52L, 52L, 52L, 41L, 41L, 41L, NA, NA, 34L, NA, NA, NA, 38L, 28L, 
53L, 66L, 40L, NA, NA, NA, NA, 32L, 19L, 28L, 53L, 41L, 38L, 
39L, 55L, 62L, 43L, 41L, 41L, NA, NA, NA, 64L, 56L, 34L, NA, 
NA, 38L, 28L, 53L, 66L, 40L, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 51L, 2L, 34L, 20L, 47L, 37L, 56L, 32L, 19L, 32L, 19L, 54L, 
41L, 38L, 22L, 36L, 62L, 7L, 41L, 41L, NA, NA, 64L, 56L, 34L, 
NA, NA, NA, 38L, 28L, 53L, 66L, 40L, NA, NA, NA, 41L, NA, 50L, 
50L, 45L, 24L, 17L, 28L, NA, NA, 42L, 64L, 56L, 34L, NA, NA, 
NA, NA, 64L, 56L, 34L, NA, NA, 43L, 44L, 61L, 61L, 70L, 41L, 
41L, NA, 38L, 28L, 53L, 66L, 40L, NA, NA, NA, 49L, NA, NA, 34L, 
NA, NA, 38L, 28L, 53L, 66L, 40L, NA, 38L, 60L, NA, 25L, 42L), .Label = c(" s", 
"(GeV/c^2)^-2", "16 E_h", "A", "A J^-1", "C", "C kg^-1", "C m", 
"C m^-3", "C m^2", "C mol^-1", "C^2 m^2 J^-1", "C^3 m^3 J^-2", 
"C^4 m^4 J^-3", "C_90 mol^-1", "E_h", "eV", "eV K^-1", "eV s", 
"eV T^-1", "F m^-1", "GeV", "GeV^-2", "Hz", "Hz K^-1", "Hz T^-1", 
"Hz V^-1", "J", "J K^-1", "J m mol^-1", "J mol^-1 K^-", "J s", 
"J s mol^-1", "J T^-1", "J T^-2", "K", "K T^-1", "kg", "kg m s^-1", 
"kg mol^-1", "m", "m K", "m s^-1", "m s^-2", "m^-1", "m^-1 K^-1", 
"m^-1 T^-1", "m^-3", "m^2", "m^2 s^-1", "m^3 kg^-1 s^", "m^3 mol^-1", 
"MeV", "MeV fm", "MeV/c", "MHz T^-1", "mol^-1", "N", "N A^-2", 
"ohm", "Pa", "s", "S", "s^-1 T^-1", "T", "u", "V", "V m^-1", 
"V m^-2", "W m^-2 K^-4", "W m^2", "W m^2 sr^-1", "Wb"), class = "factor")), .Names = c("Quantity", 
"Value", "Uncertainty", "Unit"), row.names = c(NA, -334L), class = "data.frame") 
+3

¿Podríamos quizás incluir esto en un paquete en CRAN? Hay un paquete de 'constantes' en r-forge que pretendía hacer algo similar, pero nunca pude hacerlo realmente útil. Creo que estos datos, tal vez también envueltos en una superclase de datos.frame para mostrar muy bien las unidades y los nombres (con el método de impresión, etc.), podrían formar una referencia útil para muchos. También podríamos incluir algunas funciones de conversión, una categorización, alias para constantes comunes como c, R, etc., y una buena función de búsqueda. – baptiste

+0

@baptiste: Creo que sería una buena idea. Si ya ha comenzado un paquete de constantes, me complacería ser un colaborador. Mi idea fue organizar un paquete alrededor de las unidades fundamentales: longitud, tiempo, masa, carga, y luego incluir categorías derivadas como densidad, concentración (conteo/volumen), puntos de ebullición, capacidad de calor, etc. –

+0

@Dwin sí, Me pregunto cuál es el mejor formato para capturar los atributos específicos de una unidad. ¿Funcionaría aquí un marco orientado a objetos? Tal vez las clases de referencia? Un número tendría una dimensión (unidad) unida a él, y habría métodos asociados para convertir varios sistemas de unidades. – baptiste

0

Aquí hay otro análisis sintáctico de la tabla de constantes físicas NIST CODATA. Es similar a la respuesta anterior de BondedDust pero con (lo que creo que es) una legibilidad ligeramente más fácil debido al uso de stringr.


    #parsing NIST CODATA data for physical constants 
    require(stringr) #simplifies regex usage syntax in R 

    #web page with data 
    link <- 'http://physics.nist.gov/cuu/Constants/Table/allascii.txt' 

    allstr <- readLines(link) 
    codata.str <- allstr[11:345] #data starts at line 11 

    #at least 3 spaces separate columns 
    codata.str2 <- str_replace_all(codata.str, '[ ]{3,100}', '\t') 

    #four cols in source table 
    codata.mat <- str_split_fixed(codata.str2, '\t', n=4) 

    #eliminate spaces separating every three decimal digits 
    codata.mat[,c(2,3)] <- str_replace_all(codata.mat[,c(2,3)], " ", "") 

    codata <- data.frame(quantity = codata.mat[,1], 
          value  = as.numeric(codata.mat[,2]), 
          uncertainty = as.numeric(codata.mat[,3]), 
          units  = codata.mat[,4] 
       ) 

Y eso es todo. Ahora es fácil buscar, en R, los datos para encontrar las constantes que desea, y asignar constantes que usará para nombres de variables, sin tener que escribirlos manualmente.


    > codata[str_detect(codata$quantity, 'electron mass'),] 
             quantity  value uncertainty units 
    2  alpha particle-electron mass ratio 7.294300e+03  2.9e-06  
    63   deuteron-electron mass ratio 3.670483e+03  1.5e-06  
    89       electron mass 9.109383e-31  4.0e-38 kg 
    90   electron mass energy equivalent 8.187105e-14  3.6e-21  J 
    91 electron mass energy equivalent in MeV 5.109989e-01  1.1e-08 MeV 
    92      electron mass in u 5.485799e-04  2.2e-13  u 
    130    helion-electron mass ratio 5.495885e+03  5.0e-06  
    195    muon-electron mass ratio 2.067683e+02  5.2e-06  
    223   neutron-electron mass ratio 1.838684e+03  1.1e-06  
    264    proton-electron mass ratio 1.836153e+03  7.5e-07  
    310    tau-electron mass ratio 3.477150e+03  3.1e-01  
    320    triton-electron mass ratio 5.496922e+03  5.0e-06 

    > me.u < codata[str_detect(codata$quantity, 'electron mass in u'),'value'] 
    > me.u 
    [1] 0.0005485799