Tugas 1
Contents
Tugas 1#
Misalkan kita memiliki data jumlah desa di Indonesia berdasarkan sensus Potensi Desa (PoDes) BPS dengan format csv. Untuk mengetahui isi dari data tersebut, kita memerlukan library: CSV
dan DataFrames
. Sebelumnya pastikan library tersebut sudah di tambahkan ke dalam Julia dengan perintah: ] add CSV
dan add DataFrames
.
Pertanyaan
Terapkan cari fungsi interpolasi Polynomial dan interpolasi Lagrange dari permasalahan di atas. Code harus memuat plot data dan plot fungsinya.
Load data#
using CSV
using DataFrames
using Plots
data = DataFrame(CSV.File("./pertemuan_4.1/dataset/podes.csv")) # download data di link yang terdapat di soal
first(data,6)
ArgumentError: "./pertemuan_4.1/dataset/podes.csv" is not a valid file or doesn't exist
Stacktrace:
[1] CSV.Context(source::CSV.Arg, header::CSV.Arg, normalizenames::CSV.Arg, datarow::CSV.Arg, skipto::CSV.Arg, footerskip::CSV.Arg, transpose::CSV.Arg, comment::CSV.Arg, ignoreemptyrows::CSV.Arg, ignoreemptylines::CSV.Arg, select::CSV.Arg, drop::CSV.Arg, limit::CSV.Arg, buffer_in_memory::CSV.Arg, threaded::CSV.Arg, ntasks::CSV.Arg, tasks::CSV.Arg, rows_to_check::CSV.Arg, lines_to_check::CSV.Arg, missingstrings::CSV.Arg, missingstring::CSV.Arg, delim::CSV.Arg, ignorerepeated::CSV.Arg, quoted::CSV.Arg, quotechar::CSV.Arg, openquotechar::CSV.Arg, closequotechar::CSV.Arg, escapechar::CSV.Arg, dateformat::CSV.Arg, dateformats::CSV.Arg, decimal::CSV.Arg, groupmark::CSV.Arg, truestrings::CSV.Arg, falsestrings::CSV.Arg, stripwhitespace::CSV.Arg, type::CSV.Arg, types::CSV.Arg, typemap::CSV.Arg, pool::CSV.Arg, downcast::CSV.Arg, lazystrings::CSV.Arg, stringtype::CSV.Arg, strict::CSV.Arg, silencewarnings::CSV.Arg, maxwarnings::CSV.Arg, debug::CSV.Arg, parsingdebug::CSV.Arg, validate::CSV.Arg, streaming::CSV.Arg)
@ CSV ~/.julia/packages/CSV/OnldF/src/context.jl:314
[2] #File#32
@ ~/.julia/packages/CSV/OnldF/src/file.jl:222 [inlined]
[3] CSV.File(source::String)
@ CSV ~/.julia/packages/CSV/OnldF/src/file.jl:162
[4] top-level scope
@ In[2]:1
data[1, 3:end]
DataFrameRow (6 columns)
Row | 2003 | 2005 | 2008 | 2011 | 2014 | 2018 |
---|---|---|---|---|---|---|
Int64? | Int64? | Int64? | Int64? | Int64? | Int64? | |
1 | 4749 | 5168 | 4845 | 3745 | 3630 | 3187 |
x = Array{Float64}(data[1, 3:end])
6-element Vector{Float64}:
4749.0
5168.0
4845.0
3745.0
3630.0
3187.0
cols = names(data)
cols = cols[3:end]
6-element Vector{String}:
"2003"
"2005"
"2008"
"2011"
"2014"
"2018"
y = [parse(Float64, cols[i]) for i=1:6]
6-element Vector{Float64}:
2003.0
2005.0
2008.0
2011.0
2014.0
2018.0
Plot#
t = y .- 2003
6-element Vector{Float64}:
0.0
2.0
5.0
8.0
11.0
15.0
scatter(t, x, label="aktual",
xlabel="sejak tahun 2003",
ylabel="jumlah desa (ribu)",
title="Jumlah desa di Indonesia"
)