Run any R code from the box below or use this general-purpose interface
Run any R Code Directly From This Forum
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Test this R code, see here.
- # Define parameters and initial conditions
- a <- -8/3; b <- -10; c <- 28
- #Create a three-valued vector of initial conditions using c function
- yini <- c(X = 1, Y = 1, Z = 1)
- Lorenz <- function(t, y, parms){with (as.list(y), {dX <- a*X + Y*Z; dY <- b*(Y - Z); dZ <- -X*Y + c*Y - Z;
- list(c(dX, dY, dZ))})}
- library(deSolve)
- # We solve the IVP for 100 days producing the output after every 0.01 days
- times <- seq(from = 0, to = 100, by = 0.01)
- #Integrate
- out <- ode(y = yini, times = times, func = Lorenz, parms = NULL)
- # We check the output by printing out the first five lines
- head(out, n = 5)
- plot(out, lwd = 2)
- # Plot variables Y versus X to generate the famous butterfly
- plot(out[,"X"], out[,"Y"], type = "l", xlab = "X", ylab = "Y", main = "Butterfly")
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Expert Member
- Reactions: 23
- Posts: 55
- Joined: 8 years ago
- Contact:
My laptop is dead, the only option is to use this platform at the moment for R analysis. @Eli, is it possible to add csv and port them in this editor?
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Yes, you can use read.csv both here and using SageMath engine.
For example,
will give you:
For example,
- df <- read.csv("https://github.com/selva86/datasets/raw/master/mtcars.csv")
- head(df)
will give you:
- mpg cyl disp hp drat wt qsec vs am gear carb fast cars
- 1 4.582576 6 160 110 3.90 2.620 16.46 0 1 4 4 1 Mazda RX4
- 2 4.582576 6 160 110 3.90 2.875 17.02 0 1 4 4 1 Mazda RX4 Wag
- 3 4.774935 4 108 93 3.85 2.320 18.61 1 1 4 1 1 Datsun 710
- 4 4.626013 6 258 110 3.08 3.215 19.44 1 0 3 1 1 Hornet 4 Drive
- 5 4.324350 8 360 175 3.15 3.440 17.02 0 0 3 2 1 Hornet Sportabout
- 6 4.254409 6 225 105 2.76 3.460 20.22 1 0 3 1 1 Valiant
- carname
- 1 Mazda RX4
- 2 Mazda RX4 Wag
- 3 Datsun 710
- 4 Hornet 4 Drive
- 5 Hornet Sportabout
- 6 Valiant
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Try:
Plot output
- #Let's explore the iris Data with R
- #Load required libraries
- library(datasets)
- data(iris)
- summary(iris)
- plot(iris)
Plot output
- Attachments
-
- iris.png (33.25 KiB) Viewed 57916 times
- iris.png (33.25 KiB) Viewed 57916 times
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
What is the output ?
- my_print = function(ABCD){
- print("MY NAME")
- }
- my_print()
- my_print = function(a){
- print(paste("MY NAME IS",a))
- }
- my_print("John")
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest