# http://www.bio.umass.edu/biology/kunkel/LabWiki/images/3/3d/Examples.txt R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin13.4.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [R.app GUI 1.66 (6996) x86_64-apple-darwin13.4.0] [Workspace restored from /Users/josephgkunkel/Documents/Analysis/.RData] [History restored from /Users/josephgkunkel/Documents/Analysis/.Rapp.history] > dir() [1] "OLD" "PC_aligned_Symp_Sym1509_05+17+01+02.R" [3] "PC_aligned_Symp_Sym1509_05+17+02.R" "prep_Sym150905_17_01_02.R" [5] "prep_Sym150905_17_02.R" "rgl_aligned_Symp_Sym1509_05+17+01+02.R" [7] "Sym150905_17_01_02_aligned.nams" "Sym150905_17_01_02_aligned.txt" [9] "Sym150905_17_01_02.dat" "Sym150905_17_01_02.tps" [11] "Sym150905_17_02_aligned.txt" "Sym150905_17_02.tps" > ls() [1] "distance2Points" "place1" "place2" > rm(list=ls()) > A<-0:100 > A [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [22] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [43] 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 [64] 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 [85] 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 > B<-A^2 > B [1] 0 1 4 9 16 25 36 49 64 81 100 121 144 169 [15] 196 225 256 289 324 361 400 441 484 529 576 625 676 729 [29] 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 [43] 1764 1849 1936 2025 2116 2209 2304 2401 2500 2601 2704 2809 2916 3025 [57] 3136 3249 3364 3481 3600 3721 3844 3969 4096 4225 4356 4489 4624 4761 [71] 4900 5041 5184 5329 5476 5625 5776 5929 6084 6241 6400 6561 6724 6889 [85] 7056 7225 7396 7569 7744 7921 8100 8281 8464 8649 8836 9025 9216 9409 [99] 9604 9801 10000 > plot(A,B) > ls > rm(list=ls()) # Reconstruct the data ... > C= rnorm(101) > A<-0:100 > B<-A^2 > XX<-data.frame(A,B,C) > attributes(XX) $names [1] "A" "B" "C" $row.names [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [22] 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 [43] 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 [64] 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 [85] 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 $class [1] "data.frame" > write.csv(XX) "","A","B","C" "1",0,0,-0.917990295073825 "2",1,1,0.416360079261094 "3",2,4,0.0968448821706535 "4",3,9,0.326683557474461 "5",4,16,0.00629393644074855 "6",5,25,-1.80022086717235 . . . "97",96,9216,-2.01163967942991 "98",97,9409,1.73548622727732 "99",98,9604,0.313729109431444 "100",99,9801,-2.588229361511 "101",100,10000,-1.78585401688694 > ?write.csv > write.csv(XX,row.names=FALSE) "A","B","C" 0,0,-0.917990295073825 1,1,0.416360079261094 . . . 96,9216,-2.01163967942991 97,9409,1.73548622727732 98,9604,0.313729109431444 99,9801,-2.588229361511 100,10000,-1.78585401688694 > write.csv(XX,row.names=FALSE,file='ABC.csv') > dir() [1] "ABC.csv" > readLines("ABC.csv") [1] "\"A\",\"B\",\"C\"" "0,0,-0.917990295073825" [3] "1,1,0.416360079261094" "2,4,0.0968448821706535" [5] "3,9,0.326683557474461" "4,16,0.00629393644074855" [7] "5,25,-1.80022086717235" "6,36,1.04280647586538" [9] "7,49,2.51815728304481" "8,64,-0.605631446075619" [11] "9,81,2.08783627568179" "10,100,1.39932236081908" [13] "11,121,0.599622408832816" "12,144,-0.503450866903912" [15] "13,169,0.901805880061815" "14,196,-0.774182544869684" [17] "15,225,-1.90288381407517" "16,256,-0.968672572925644" [19] "17,289,-0.8298264017814" "18,324,0.377230707166148" . . . [91] "89,7921,0.257638992793674" "90,8100,-0.820624655289276" [93] "91,8281,0.583830072226966" "92,8464,0.0544626114660256" [95] "93,8649,2.05704376150094" "94,8836,-0.807535446874657" [97] "95,9025,-0.59029582043659" "96,9216,-2.01163967942991" [99] "97,9409,1.73548622727732" "98,9604,0.313729109431444" [101] "99,9801,-2.588229361511" "100,10000,-1.78585401688694" > ls() [1] "A" "B" "C" "XX" > rm(list=ls()) > ls() > dir() [1] "ABC.csv" > read.csv("ABC.csv") A B C 1 0 0 -0.917990295 2 1 1 0.416360079 3 2 4 0.096844882 4 3 9 0.326683557 . .99 98 9604 0.313729109 100 99 9801 -2.588229362 101 100 10000 -1.785854017 > ls() character(0) > XX<-read.csv("ABC.csv") > readLines("ABC.csv") [1] "\"A\",\"B\",\"C\"" "0,0,-0.917990295073825" "1,1,0.416360079261094" [4] "2,4,0.0968448821706535" "3,9,0.326683557474461" "4,16,0.00629393644074855" [7] "5,25,-1.80022086717235" "6,36,1.04280647586538" "7,49,2.51815728304481" . . . [94] "92,8464,0.0544626114660256" "93,8649,2.05704376150094" "94,8836,-0.807535446874657" [97] "95,9025,-0.59029582043659" "96,9216,-2.01163967942991" "97,9409,1.73548622727732" [100] "98,9604,0.313729109431444" "99,9801,-2.588229361511" "100,10000,-1.78585401688694" > ls() [1] "XX" > XX A B C 1 0 0 -0.917990295 2 1 1 0.416360079 3 2 4 0.096844882 4 3 9 0.326683557 5 4 16 0.006293936 . . 99 98 9604 0.313729109 100 99 9801 -2.588229362 101 100 10000 -1.785854017 > XX[101,3] [1] -1.785854 > XX[101,3]==0 [1] FALSE > XX[101,3]==-1.785854 [1] FALSE > XX[101,3]==-1.785854017 [1] FALSE > XX[101,3]==-1.78585401688694 [1] TRUE > ls() [1] "XX" > attach(XX) > plot(A,B) > points(A,B+200*C, typ='p', col=rainbow(101), pch=20) > require(maps) > map('world', fill = TRUE, col = 1:10) > demo() > > ls() [1] "XX" > A [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [23] 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 [45] 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 [67] 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 [89] 88 89 90 91 92 93 94 95 96 97 98 99 100 > plot(C) > hist(C) > length(C) [1] 101 # Getting Buoy Data http://gyre.umeoce.maine.edu/data/gomoos/buoy/html/ http://gyre.umeoce.maine.edu/data/gomoos/buoy/html/E05.html > source("http://www.bio.umass.edu/biology/kunkel/LabWiki/images/8/8d/E0501_gps_lat_lon_now.R.txt")