summaryrefslogtreecommitdiff
path: root/conversion
diff options
context:
space:
mode:
authorSt33v <st33v@woodenspoon.net>2013-05-16 18:23:22 +1000
committerSt33v <st33v@woodenspoon.net>2013-05-16 18:23:22 +1000
commit06ec3eced6e521437a3ee613200c7fe7e00dba6a (patch)
tree580c189aa38131e43b8db04ff47438cf5e6948bf /conversion
parentbb8740e5edc4de06db4f413d83c994130d329dad (diff)
Create conversion
Added f2c (Fahrenheit to Celsius)
Diffstat (limited to 'conversion')
-rw-r--r--conversion18
1 files changed, 18 insertions, 0 deletions
diff --git a/conversion b/conversion
new file mode 100644
index 0000000..fc8d107
--- /dev/null
+++ b/conversion
@@ -0,0 +1,18 @@
+#######################################################################
+# f2c
+# convert evil Fahrenheit to Celcius
+# SJP April 2007
+f2c <- function(deg, sc='F', string=FALSE){
+# sc == scale (default is f therefore cvt tfrom F to C)
+ sc <- substr(toupper(sc),1,1) # clean input
+ if (sc=='F'){
+ res <- (deg - 32) * (5/9)
+ to <- 'C'
+ } else {
+ res <- deg * 1.8 + 32
+ to <- 'F'; sc <- 'C'
+ }
+ if (string) res <- sprintf('Converted from %i %1s to %i %1s.',
+ round(deg, 0), sc, round(res, 0), to)
+ return(res)
+}