Page 1 of 1
Run any R Code Directly From This Forum
Posted: Wed Jul 22, 2020 8:42 pm
by Eli
Run any R code from the box below or use
this general-purpose interface
Re: Run any R Code Directly From This Forum
Posted: Wed Sep 09, 2020 9:21 pm
by Eli
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")
Re: Run any R Code Directly From This Forum
Posted: Fri Sep 11, 2020 5:29 am
by Eli
Here is the output

Re: Run any R Code Directly From This Forum
Posted: Tue Apr 27, 2021 4:55 pm
by Joseph Bundala
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?
Re: Run any R Code Directly From This Forum
Posted: Wed Apr 28, 2021 6:31 am
by Eli
Yes, you can use read.csv both here and using
SageMath engine.
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
Re: Run any R Code Directly From This Forum
Posted: Thu Apr 29, 2021 8:52 pm
by Eli
Try:
#Let's explore the iris Data with R
#Load required libraries
library(datasets)
data(iris)
summary(iris)
plot(iris)
Plot output
Re: Run any R Code Directly From This Forum
Posted: Wed Jan 12, 2022 1:06 am
by Avy_213
Awesome code Elli!
Re: Run any R Code Directly From This Forum
Posted: Wed Apr 19, 2023 5:52 pm
by Eli
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")