R and Python For Oceanographers: A Practical Guide With Applications 1st Edition - Ebook PDFinstant Download
R and Python For Oceanographers: A Practical Guide With Applications 1st Edition - Ebook PDFinstant Download
https://ebooksecure.com/download/r-and-python-for-oceanographers-
a-practical-guide-with-applications-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-introduction-to-machine-
learning-with-python-a-guide-for-data-scientists/
https://ebooksecure.com/download/programming-and-problem-solving-
with-python-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-including-students-with-
special-needs-a-practical-guide-for-classroom-teachers-8th-
edition/
http://ebooksecure.com/product/ebook-pdf-including-students-with-
special-needs-a-practical-guide-for-classroom-teachers-7th-
edition/
(eBook PDF) Doing Research with Children: A Practical
Guide 3rd Edition
http://ebooksecure.com/product/ebook-pdf-doing-research-with-
children-a-practical-guide-3rd-edition/
https://ebooksecure.com/download/security-operations-center-
guidebook-a-practical-guide-for-a-successful-soc-ebook-pdf/
https://ebooksecure.com/download/startup-program-design-a-
practical-guide-for-creating-corporate-accelerators-and-
incubators-ebook-pdf/
(eBook PDF) Django for APIs: Build web APIs with Python
and Django
http://ebooksecure.com/product/ebook-pdf-django-for-apis-build-
web-apis-with-python-and-django/
http://ebooksecure.com/product/python-for-dummies-1st-edition-
pdf-version/
R AND PYTHON
FOR OCEANOGRAPHERS
R AND PYTHON
FOR OCEANOGRAPHERS
A Practical Guide with Applications
HAKAN ALYURUK
Institute of Marine Sciences and Technology,
Dokuz Eylul University, Turkey
Elsevier
Radarweg 29, PO Box 211, 1000 AE Amsterdam, Netherlands
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, United Kingdom
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
© 2019 Elsevier Inc. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or by any means, electronic
or mechanical, including photocopying, recording, or any information storage and retrieval system,
without permission in writing from the publisher. Details on how to seek permission, further
information about the Publisher’s permissions policies and our arrangements with organizations such
as the Copyright Clearance Center and the Copyright Licensing Agency, can be found at our website:
www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the
Publisher (other than as may be noted herein).
Notices
Knowledge and best practice in this field are constantly changing. As new research and experience
broaden our understanding, changes in research methods, professional practices, or medical
treatment may become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating
and using any information, methods, compounds, or experiments described herein. In using such
information or methods they should be mindful of their own safety and the safety of others, including
parties for whom they have a professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume
any liability for any injury and/or damage to persons or property as a matter of products liability,
negligence or otherwise, or from any use or operation of any methods, products, instructions, or ideas
contained in the material herein.
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
ISBN: 978-0-12-813491-7
1.1 Introduction to R
R is a language and package-based software environment that provides a
wide variety of functions for statistical computing and graphics. R is a project
of GNU, and its root depends on S language with some differences.
S language and environment was developed by John Chambers and his col-
leagues at Bell Laboratories (formerly AT&T and now Lucent Technolo-
gies). While S language provides programmable research tools for
statistical analysis, R has evolved as an Open Source alternative of the
S language. R was initially developed by Robert Gentleman and Ross Ihaka
at the statistics department of the University of Auckland. Its name “R”
comes from the first letters of its developers. Besides its statistical capabilities
(such as linear and nonlinear modelling, classical statistical tests, time-series
analysis, classification, clustering, etc.), high-resolution publication-quality
plots can be produced with full control of the users. R is distributed under
the terms of Free Software Foundation’s GNU GPL license. Thanks to
terms of this license, source codes of both base distribution and external
packages with GPL license can be accessed, modified, and re-distributed
by the user. Therefore, data analysts can view and contribute to source codes
of these packages by accessing the running algorithms and adding their spe-
cific functions. As a result, scientists and students at universities can
use R freely and without a license fee. The use of free software in
science encourages and improves worldwide collaboration on data-analysis
approaches. Also, R is used in teaching statistics at undergraduate and grad-
uate levels at universities since students can freely use these statistical
tools [1, 2].
The base distribution of R is maintained by the R Development Core
Team since 1997. In addition, a huge group of volunteer developers con-
tribute to the project by developing new packages or upgrading existing
add-on packages to improve their functionalities. The project’s website is
the main official information source and can be reached from Fig. 1.1:
https://www.r-project.org
1.2 R environment
R statistical environment system is composed of two main parts: base-
distribution system and add-on packages.
agricolae maps
car plyr
ggplot2 psych
lattice
1.3 Installation of R
1.3.1 Installation of R base software
R is an open source software, and it can be downloaded and installed freely.
Latest/older versions of R software for Windows, Linux, or Mac OSX oper-
ating systems could be downloaded and installed from http://cran.r-project.
org/ (Fig. 1.2).
In Linux systems, like Ubuntu, the latest version of R base (r-base) envi-
ronment can be installed from Software Center by adding official reposito-
ries of R-CRAN (Comprehensive R Archive Network) to the repository
list. In Debian systems, latest R version can be installed from Package Man-
ager after adding appropriate CRAN repositories. In Mac OSX systems, the
latest version of R can be downloaded from its official website and installed
according to the instructions.
install.packages("package_name")
Or you can install packages from the R console application under the Pack-
ages menu by clicking the install packages option. Then, you can select the
desired package to install from the drop-down list of add-on packages.
Alternatively, you can install a previously downloaded package from a
local file by following these instructions:
1. First download the latest versions of packages with their dependencies
from CRAN
2. Create PACKAGE and PACKAGE.gz logs for packages in the directory
with these codes:
library(tools)
write_PACKAGES("C:/Users/username/r_packages")
install.packages("package_name", contriburl="file:
C:/Users/username/r_packages ")
install.packages("devtools",
lib="file:C:/Users/username/r_packages")
devtools::install_github("Github_username/package_name")
You can test the installation of add-on packages by loading them from
R console with this code:
library(package_name)
If the code runs without any errors, this means the installation of the package
was successful.
6 R and Python for Oceanographers
1.4.2 RStudio
RStudio is a free and open source IDE for R language (Fig. 1.4). Compared
to official R console, it provides many advantages for editing and running of
scripts. RStudio is available for Windows, Linux, and Mac OSX systems.
More information about RStudio can be found at its official website:
https://www.rstudio.com/
sessionInfo()
# show R version
getRversion()
Introduction to R and Python
Fig. 1.3 A screenshot of R editor and console.
7
8
R and Python for Oceanographers
Fig. 1.4 A screenshot of RStudio.
Introduction to R and Python 9
getwd()
setwd("C:/...")
library()
available.packages()
download.packages("package_name", "download_directory")
update.packages(checkBuilt=TRUE)
installed.packages()
packageDescription("package_name")
# remove packages
remove.packages("package_name", "installed_directory")
license()
10 R and Python for Oceanographers
# display citation
citation()
# attach packages
library(package_name)
# detach packages
detach("package:package_name")
library(lib.loc = .Library)
search()
# running time of R
proc.time()
memory.size()
memory.limit()
# terminate an R session
q()
warnings()
Introduction to R and Python 11
history()
loadhistory(file = ".Rhistory")
savehistory(file = ".Rhistory")
# Save R image
sys.save.image("C:\\Users\\username\\...\\filename.RData")
sys.load.image("C:\\Users\\user\\...\\filename.RData")
Then, install the latest version of a module and its dependencies from the
Python Packaging Index (PyPI):
15
16 R and Python for Oceanographers
For Linux:
# Add below command to the end of your /.bashrc file
export PATH="$PATH:/home/your_user/.local/bin"
export PATH="$PATH:/Users/your_user/Library/Python/3.5/bin"
Change “your_user” with your username and “3.5” with Python version
installed on your system.
For Fedora:
For Windows
setup.py install
– Miniconda: https://conda.io/miniconda.html
– Python(x,y): https://python-xy.github.io/downloads.html
To test the Python installation:
– Open terminal (in Linux/Mac OSX)/command prompt (in Windows),
type python and press enter or click Python icon from the start menu.
– Then, run the following code at the Python shell:
import sys
print sys.version_info
– If you get the below output, it means that Python (version 2) works with-
out any problem on your system.
In this book, R examples were prepared with R version > 3 and tested
with latest R 3.5.1 version.
Python examples were prepared and tested with package versions in
Miniconda Python Environment.
A simple conda environment can be created, and necessary packages can
be installed from command line/terminal by typing:
# Create python environment
# Install packages
References
[1] B.S. Everitt, T. Hothorn, A Handbook of Statistical Analyses Using R, second ed., CRC
Press, Florida, 2010.
[2] R-Project Website, About R, n.d. https://www.r-project.org/about.html. Accessed
01 September 2017.
[3] A. Boschetti, L. Massaron, Python Data Science Essentials, first ed., Pack Publishing,
Birmingham, 2015.
[4] Python Documentation, Foreword for “Programming Python” n.d. (1st ed.), http://
legacy.python.org/doc/essays/foreword/. Accessed 01 September 2017.
[5] Python Documentation, n.d. Modules, https://docs.python.org/2.7/tutorial/modules.
html. Accessed 01 September 2017.
[6] Python Documentation, n.d. Packages, https://docs.python.org/2.7/tutorial/modules.
html#packages. Accessed 01 September 2017.
Another Random Document on
Scribd Without Any Related Topics
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about testbank and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebooksecure.com