Showing posts with label Programming-R. Show all posts
Showing posts with label Programming-R. Show all posts

Monday, January 23, 2023

Line Charts Pada Programming-R

 


Grafik garis memiliki garis yang menghubungkan semua titik dalam diagram.

Untuk membuat garis, gunakan fungsi plot() dan tambahkan parameter tipe dengan nilai "l":

Contoh :

plot(1:10type="l")


plot(1:10type="l", col="blue")


plot(1:10type="l", lwd=2)

Note : lwd adalah ketebalan

parameter :

  • 1 is default, while 0.5 means 50% smaller
  • 2 means 100% larger


plot(1:10type="l", lwd=5, lty=3)

note : lty merupakan styles

parameter : 

  • 0 removes the line
  • 1 displays a solid line
  • 2 displays a dashed line
  • 3 displays a dotted line
  • 4 displays a "dot dashed" line
  • 5 displays a "long dashed" line
  • 6 displays a "two dashed" line


Multiline

line1 <- c(1,2,3,4,5,10)
line2 <- c(2,5,7,8,9,10)

plot(line1, type = "l", col = "blue")
lines(line2, type="l", col = "red")


Scatterplot Charts Pada Programming-R

 


Scatterplot Charts digunakan untuk menampilkan hubungan antara dua variabel numerik, dan memplot satu titik untuk setiap pengamatan. Dibutuhkan dua vektor dengan panjang yang sama, satu untuk sumbu x (horizontal) dan satu untuk sumbu y (vertikal)

Contoh :

x <- c(5,7,8,7,2,2,9,4,11,12,9,6)
y <- c(99,86,87,88,111,103,87,94,78,77,85,86)

plot(x, y)


x <- c(5,7,8,7,2,2,9,4,11,12,9,6)
y <- c(99,86,87,88,111,103,87,94,78,77,85,86)

plot(x, y, main="Observation", xlab="age", ylab="speed")


# day one, the age and speed of 12 cars:
x1 <- c(5,7,8,7,2,2,9,4,11,12,9,6)
y1 <- c(99,86,87,88,111,103,87,94,78,77,85,86)

# day two, the age and speed of 15 cars:
x2 <- c(2,2,8,1,15,8,12,9,7,3,11,4,7,14,12)
y2 <- c(100,105,84,105,90,99,90,95,94,100,79,112,91,80,85)

plot(x1, y1, main="Observation", xlab="age", ylab="speed", col="red"cex=2)
points(x2, y2, col="blue", cex=2)



Pie Charts Pada Programming-R

 


Pie Charts merupakan tampilan grafis melingkar dari data.  Fungsi pie() untuk menggambar diagram lingkaran:

Contoh :

# Create a vector of pies
x <- c(10,20,30,40)

# Display the pie chart
pie(x)



# Create a vector of pies
x <- c(10,20,30,40)

# Display the pie chart and start the first pie at 90 degrees
pie(x, init.angle = 90)

# Create a vector of pies
x <- c(10,20,30,40)

# Create a vector of labels
mylabel <- c("Apples""Bananas""Cherries""Dates")

# Display the pie chart with labels
pie(x, label = mylabel, main = "Fruits")




# Create a vector of colors
colors <- c("blue""yellow""green""black")

# Display the pie chart with colors
pie(x, label = mylabel, main = "Fruits", col = colors)


# Create a vector of labels
mylabel <- c("Apples""Bananas""Cherries""Dates")

# Create a vector of colors
colors <- c("blue""yellow""green""black")

# Display the pie chart with colors
pie(x, label = mylabel, main = "Pie Chart", col = colors)

# Display the explanation box
legend("bottomright", mylabel, fill = colors)


posisi :

 bottomrightbottombottomleftlefttoplefttoptoprightrightcenter


Bar Charts Pada Programming-R

 


Bar Charts menggunakan batang persegi panjang untuk memvisualisasikan data. Bagan batang dapat ditampilkan secara horizontal atau vertikal. Tinggi atau panjang batang sebanding dengan nilai yang diwakilinya.

Format : barplot()

Contoh :

# x-axis values
x <- c("A""B""C""D")

# y-axis values
y <- c(2468)

barplot(y, names.arg = x)


x <- c("A""B""C""D")
y <- c(2468)

barplot(y, names.arg = x, col = "red")


x <- c("A""B""C""D")
y <- c(2468)

barplot(y, names.arg = x, density = 10)



x <- c("A""B""C""D")
y <- c(2468)

barplot(y, names.arg = x, width = c(1,2,3,4))


x <- c("A""B""C""D")
y <- c(2468)

barplot(y, names.arg = x, horiz = TRUE)



Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...