Dream to Learn is shutting down...

We are very sorry to say that Dream to Learn will be shutting down as of December 28th, 2019. If you have content that you wish to keep, you should make a copy of it before that date.


0COMMENTS0RECOMMENDS

Why I love R: 3 minutes from curiosity to code

115
POSTED IN: Data Analytics & Visualization Blog

Why I love R: 3 minutes from curiosity to code:

 

 

1.See Linked in Article on Lorenz attractor ‘I remember that…’
2.Google It (first hit shows “R” solution J)
3.Find Article Referencing Package
https://www.sixhat.net/lorenz-attractor-in-r.html
4.Check out nicely documented Package PDF
https://cran.r-project.org/web/packages/deSolve/index.html 
5.Open RStudio and  install.packages("deSolve")
6.Ctrl-F for ‘Lorenz’
7.Copy-Paste-Run Code
 
 

# Check out nicely documented Package PDF
# https://cran.r-project.org/web/packages/deSolve/index.html  

 

## =======================================================================
## ex. 1
## The famous Lorenz equations: chaos in the earth
## Lorenz 1963. J. Atmos. Sci. 20, 130-141.
## =======================================================================

library(deSolve)
chaos <- function(t, state, parameters) {
with(as.list(c(state)), {
dx     <- -8/3 * x + y * z
dy     <- -10 * (y - z)
dz     <- -x * y + 28 * y - z
list(c(dx, dy, dz))
})
}
state <- c(x = 1, y = 1, z = 1)
times <- seq(0, 100, 0.01)
out   <- vode(state, times, chaos, 0)
# plot(out, type = "l")   # all versus time
# plot(out[,"x"], out[,"y"], type = "l", main = "Lorenz butterfly",
# xlab = "x", ylab = "y")

##

plot(out[,"x"], out[,"y"], type = "l", main = "Lorenz butterfly")

 

Interested in more content by this author?

About the Author

Ryan Anderson

Ryan Anderson

Hi! I like to play with data, analytics and hack around with robots and gadgets in my garage. Lately I've been learning about machine learning.

About this blog

Description is...<br/>Data Analytics & Visualization Blog - Generating insights from Data since 2013

Created: July 25, 2014

Englishfrançais

Up Next