title: “Untitled” output: html_document date: “2025-11-14”
#1
#把你蒐集到的資料key入
Statistic <- c(68,85,74,88,63,78,90,80,58,63)
Math <- c(85,91,74,100,82,84,78,100,51,70)
## C 固定值意思
## x,y 兩個變項,比方身高體重,你有興趣的變項皆可
colors <- c("#FDAE61", # Orange
"#D9EF8B") # Light green
##畫圖
plot(Statistic,Math,
pch = 19,
col = colors,
main="統計與數學成績的散佈圖")
#2
library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length)) +
geom_histogram(binwidth = 0.5, fill = "forestgreen", color = "black") +
labs(title = "數學成績直方圖",
x = "數學成績",
y = "人數")
#3
# Load ggplot2
library(ggplot2)
# Create data
data <- data.frame(
社團類型=c("公益活動","知識閱讀","科學創新","娛樂休閒","體育競技") ,
次數=c(3,12,5,18,45)
)
# Barplot
ggplot(data, aes(x=社團類型, y=次數)) +
geom_bar(stat = "identity")
#4
Prop <- c(3,7,9,1,2)
pie(Prop , labels =
c("公益活動","知識閱讀","科學創新","娛樂休閒","體育競技"))
#5
# Library
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ lubridate 1.9.4 ✔ tibble 3.3.0
## ✔ purrr 1.2.0 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Create data
data <- data.frame(
x=LETTERS[1:26],
y=abs(rnorm(26))
)
# plot
ggplot(data, aes(x=x, y=y)) +
geom_segment( aes(x=x, xend=x, y=0, yend=y)) +
geom_point( size=5, color="red", fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2)
library (readr)
Data <- read.csv("D:/table1_1.csv")