MATH/COSC 3570 Introduction to Data Science
R and Python are programming languages.
Posit Cloud offers two integrated development environments (IDE):
which are software for efficiently writing computer programs.
😎 Implement R/Python programs without needing to install R/Python and the IDE in your laptop!
😎 Posit Cloud lets you do, share and learn data science entirely online!
Step 2: Click GET STARTED.
Step 3: Cloud Student > Sign Up using your Marquette email address.
In the bar, click workspace 2025-spring-math-3570.
In the workspace, click New Project > New RStudio Project to get into the IDE.
In Untitled Project, name your project as 3570-project.
In the Console pane, write R code: a string "Hello WoRld!"
or math 2 + 4
.
Tools > Global Options > Appearance to select your favorite editor theme.
A R script is a .R file that contains R code.
To create a R script, go to File > New > R Script, or click the green-plus icon on the topleft corner, and select R Script.
ctrl + enter
(Win) or cmd + enter
(Mac)alt + ctrl + p
(Win) or option + cmd + p
(Mac)shift + ctrl + s
(Win) or shift + cmd + s
(Mac)shift + ctrl + enter
(Win) or shift + cmd + enter
(Mac)The (global) environment is where we are currently working.
Anything created or imported into the current R/Python session is stored in the environment and shown in the Environment tab.
After we run the R script, objects stored in the environment are
mtcars
x
storing integer values 1 to 10.y
storing three numeric values 3, 5, 9.A Python script is a .py file that contains Python code.
To create a Python script, go to File > New > Python Script, or click the green-plus icon on the topleft corner, and select Python Script.
Running Python code may need to update some packages. Please say YES!
When you run the Python code in the R console, or type reticulate::repl_python()
, the console will switch from R to Python.
In the Python console >>> quit
to switch back to the R console.
b
storing a string Hello World!
In the console pane, use ⬆️ to show the previous commands.
and more!
install.packages("ggplot2")
What happened when you run
ggplot(mpg, aes(x = displ,
y = hwy,
colour = class)) +
geom_point()
ggplot2::
followed by the name of the function or data.ggplot2::ggplot(ggplot2::mpg,
ggplot2::aes(
x = displ,
y = hwy,
colour = class)
) +
ggplot2::geom_point()
?
followed by the data name or function name like?mean
?mpg
What does the function mean()
do? What is the size of mpg
?
01-Running R Script
Create a R script named lab01-run-script.R in your 3570-project.
Copy and paste the code below into the script, and save it.
bar <- ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, fill = cut),
show.legend = FALSE, width = 1) +
theme(aspect.ratio = 1) +
labs(x = NULL, y = NULL)
bar + coord_flip()
bar + coord_polar()