R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. ==Belajar Bahasa R lewat Rpubs==

Syntax dalam bahasa R :

  1. untuk mengeluarkan input dari bahasa R, menggunakan tanda kutip tunggal atau ganda ,contoh :
Housing = read.csv("http://www.mosaic-web.org/go/datasets/Income-Housing.csv")
"Hello bro, How are you ? "
## [1] "Hello bro, How are you ? "

sedangkan untuk output angka, hanya mengetik angka tanpa tanda petik,contoh :

library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
34
## [1] 34
3.45
## [1] 3.45
100
## [1] 100

begitu juga untuk melakukan perhitungan, hanya menambahkan +,-,/,*

10+34
## [1] 44
34/4
## [1] 8.5
89*7
## [1] 623
9-67
## [1] -58

2.Program Command promp bisa dimulai dengan (<-)

myString <- (" Yo Whats up Man")
print(myString)
## [1] " Yo Whats up Man"

3.Looping menggunakan bahasa R,dengan fungsi print() untuk mengeluarkan input

for (x in 2:12) {
  print(x)
}
## [1] 2
## [1] 3
## [1] 4
## [1] 5
## [1] 6
## [1] 7
## [1] 8
## [1] 9
## [1] 10
## [1] 11
## [1] 12

dari output diatas diketahui bahwa looping dimulai dari angka 2 yang kemudian terus bertambah 1 sampai looping ke-12. 4.memberikan penjelasan source code dengan menggunakan Command (#)

#berikut penjelasan dari code yang saya berikan
"Hello Bro "
## [1] "Hello Bro "

5.tidak ada syntax untuk menggunakan comment multiline atau seluruh baris sekaligus dalam bahasa R,tapi bisa menggunakan (#) pada setiap barisnya

#berikut contohnya
#ada yang bisa saya bantu
#ada yang lain?
"Thanks Bro, See you "
## [1] "Thanks Bro, See you "