library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.5.3
## Warning: package 'forcats' was built under R version 4.5.3
## Warning: package 'lubridate' was built under R version 4.5.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.2 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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
url <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-09-01/key_crop_yields.csv"
df_crop <- read_csv(url)
## Rows: 13075 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Entity, Code
## dbl (12): Year, Wheat (tonnes per hectare), Rice (tonnes per hectare), Maize...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
df_crop <- as_tibble(df_crop)
View(df_crop)
glimpse(df_crop)
## Rows: 13,075
## Columns: 14
## $ Entity <chr> "Afghanistan", "Afghanistan", "Afgh…
## $ Code <chr> "AFG", "AFG", "AFG", "AFG", "AFG", …
## $ Year <dbl> 1961, 1962, 1963, 1964, 1965, 1966,…
## $ `Wheat (tonnes per hectare)` <dbl> 1.0220, 0.9735, 0.8317, 0.9510, 0.9…
## $ `Rice (tonnes per hectare)` <dbl> 1.5190, 1.5190, 1.5190, 1.7273, 1.7…
## $ `Maize (tonnes per hectare)` <dbl> 1.4000, 1.4000, 1.4260, 1.4257, 1.4…
## $ `Soybeans (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Potatoes (tonnes per hectare)` <dbl> 8.6667, 7.6667, 8.1333, 8.6000, 8.8…
## $ `Beans (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Peas (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Cassava (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Barley (tonnes per hectare)` <dbl> 1.0800, 1.0800, 1.0800, 1.0857, 1.0…
## $ `Cocoa beans (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Bananas (tonnes per hectare)` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA,…
No 1
Menampilkan kolom Entity, Year, Potatoes, dan Cassava saja
data_select <- select(df_crop, Entity, Year, 'Potatoes (tonnes per hectare)',
'Cassava (tonnes per hectare)')
data_select
## # A tibble: 13,075 × 4
## Entity Year `Potatoes (tonnes per hectare)` Cassava (tonnes per hecta…¹
## <chr> <dbl> <dbl> <dbl>
## 1 Afghanistan 1961 8.67 NA
## 2 Afghanistan 1962 7.67 NA
## 3 Afghanistan 1963 8.13 NA
## 4 Afghanistan 1964 8.6 NA
## 5 Afghanistan 1965 8.8 NA
## 6 Afghanistan 1966 9.07 NA
## 7 Afghanistan 1967 9.8 NA
## 8 Afghanistan 1968 10 NA
## 9 Afghanistan 1969 10.2 NA
## 10 Afghanistan 1970 9.54 NA
## # ℹ 13,065 more rows
## # ℹ abbreviated name: ¹`Cassava (tonnes per hectare)`
No 2
Mengeliminasi kolom Soybeans, Beans, dan Peas dari tabel
select(df_crop, -c(`Soybeans (tonnes per hectare)`, `Beans (tonnes per hectare)`,
`Peas (tonnes per hectare)`))
## # A tibble: 13,075 × 11
## Entity Code Year `Wheat (tonnes per hectare)` Rice (tonnes per hecta…¹
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Afghanistan AFG 1961 1.02 1.52
## 2 Afghanistan AFG 1962 0.974 1.52
## 3 Afghanistan AFG 1963 0.832 1.52
## 4 Afghanistan AFG 1964 0.951 1.73
## 5 Afghanistan AFG 1965 0.972 1.73
## 6 Afghanistan AFG 1966 0.867 1.52
## 7 Afghanistan AFG 1967 1.12 1.92
## 8 Afghanistan AFG 1968 1.16 1.95
## 9 Afghanistan AFG 1969 1.19 1.98
## 10 Afghanistan AFG 1970 0.956 1.81
## # ℹ 13,065 more rows
## # ℹ abbreviated name: ¹`Rice (tonnes per hectare)`
## # ℹ 6 more variables: `Maize (tonnes per hectare)` <dbl>,
## # `Potatoes (tonnes per hectare)` <dbl>,
## # `Cassava (tonnes per hectare)` <dbl>, `Barley (tonnes per hectare)` <dbl>,
## # `Cocoa beans (tonnes per hectare)` <dbl>,
## # `Bananas (tonnes per hectare)` <dbl>
No 3
Menampilkan Tahun dimana hasil panen padi (Rice) di Indonesia
nilainya di bawah 2 ton
data_filter<-filter(df_crop, `Rice (tonnes per hectare)` < 2)
data_filter$Year
## [1] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1977 1988
## [15] 1989 1990 1991 1992 1993 1994 1996 1961 1962 1963 1964 1965 1966 1967
## [29] 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [43] 1982 1983 1984 1985 1986 1988 1961 1962 1970 1978 1995 1996 1997 1998
## [57] 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
## [71] 2013 2014 2015 2016 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
## [85] 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984
## [99] 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1999 2000
## [113] 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
## [127] 2015 2016 2017 2018 1961 1962 1992 1993 1994 1995 1961 1962 1963 1964
## [141] 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
## [155] 1979 1981 1961 1962 1963 1964 1965 1966 1967 1968 1970 1971 1972 1974
## [169] 1975 1976 1989 1990 1991 1994 1995 1998 1961 1962 1963 1964 1965 1966
## [183] 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1978 1979 1980 1981
## [197] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [211] 1996 1997 1999 1985 1986 1987 1988 1989 1991 1992 1993 1994 1995 1996
## [225] 1997 1998 1999 2000 2001 2002 1961 1962 1963 1964 1965 1966 1967 1968
## [239] 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
## [253] 1983 1984 1985 1986 1987 1988 1990 1992 1993 1994 1999 2000 2002 1961
## [267] 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
## [281] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1990
## [295] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1976 1977
## [309] 1978 1980 1981 1982 1983 1984 1985 1987 1990 1991 1992 1994 1995 1996
## [323] 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
## [337] 2011 2012 2013 2014 2016 2017 1961 1962 1963 1964 1965 1966 1967 1968
## [351] 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
## [365] 1983 1984 1985 1986 1987 1988 1992 1994 1995 1997 1998 2001 2002 2003
## [379] 2004 2005 2007 2011 2017 2018 1967 1969 1970 1971 1973 1977 1978 2013
## [393] 2015 2017 2018 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971
## [407] 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985
## [421] 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
## [435] 2002 2004 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
## [449] 1973 1974 1975 1976 1977 2002 2003 2004 2005 2006 2007 2008 2010 2011
## [463] 2012 2013 2014 2015 2016 2017 2018 1961 1962 1963 1964 1965 1967 1968
## [477] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [491] 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
## [505] 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
## [519] 2004 2006 2007 2008 2009 2011 2013 2014 2015 2016 2017 2018 1961 1962
## [533] 1963 1964 1965 1966 1967 1968 1961 1962 1963 1964 1965 1966 1967 1968
## [547] 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
## [561] 1983 1984 1985 1986 1987 1990 1993 1994 1995 1996 1997 1998 1999 2000
## [575] 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
## [589] 2015 2016 2017 2018 1961 1962 1964 1965 1966 1961 1962 1963 1964 1965
## [603] 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
## [617] 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993
## [631] 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
## [645] 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 1961 1962 1963
## [659] 1964 1965 1969 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [673] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [687] 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
## [701] 2010 2011 2012 2013 2014 2015 2016 2017 2018 1961 1962 1963 1964 1965
## [715] 1966 1967 1968 1969 1970 1973 1974 1976 1982 1961 1962 1963 1964 1965
## [729] 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
## [743] 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993
## [757] 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
## [771] 2008 2009 1961 1962 1963 1964 1965 1967 1968 1969 1970 1972 1973 1993
## [785] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [799] 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
## [813] 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
## [827] 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
## [841] 2017 2018 1961 1962 1963 1961 1962 1963 1964 1965 1966 1967 1968 1969
## [855] 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
## [869] 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997
## [883] 1998 1999 2000 2002 1962 1963 1968 1993 1994 1995 1996 1997 1998 1999
## [897] 2000 2001 2003 2004 2005 2006 2007 1961 1962 1963 1964 1965 1966 1967
## [911] 1968 1969 1970 1971 1972 1973 1974 1977 1978 1979 1980 1983 1987 1998
## [925] 1961 1963 1964 1965 1966 1970 1971 1972 1973 1974 1975 1976 1977 1978
## [939] 1979 1980 1981 1982 2005 2006 2009 2010 2017 2018 1962 1966 1967 1968
## [953] 1969 1970 1971 1974 1975 1976 1977 1978 1985 1988 1991 1992 1961 1962
## [967] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976
## [981] 1977 1978 1979 1980 1981 1982 1983 1985 1986 1987 1988 1989 1990 1991
## [995] 1992 1993 1994 1995 1996 1997 1998 2003 2005 2006 2007 2008 2009 2010
## [1009] 2011 2012 2013 2014 2015 2016 2017 2018 1961 1962 1963 1964 1965 1966
## [1023] 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
## [1037] 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1997 1998
## [1051] 1999 2007 1961 1962 1963 1964 1965 1967 1968 1969 1974 1975 1976 1996
## [1065] 1997 2001 2002 2003 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
## [1079] 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984
## [1093] 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
## [1107] 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
## [1121] 2013 2014 2015 2016 2017 2018 1961 1962 1963 1964 1965 1966 1967 1968
## [1135] 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
## [1149] 1983 1984 1985 1992 1993 1995 1996 1997 1998 1999 2000 2001 2002 2003
## [1163] 2004 2005 2006 2007 2008 2011 2012 2013 2014 2015 2016 2017 2018 1967
## [1177] 1968 1969 1970 1971 1972 1973 1976 1961 1962 1963 1994 1998 2003 1961
## [1191] 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
## [1205] 1976 1977 1978 1979 1980 1981 1982 1962 1963 1964 1966 1967 1968 1974
## [1219] 1975 1976 1977 1978 1979 1981 1982 1983 1987 1997 1998 1999 2000 2001
## [1233] 2002 2003 2004 2005 2007 2008 2016 1961 1962 1964 1965 1966 1968 1970
## [1247] 1974 1976 1977 1978 1980 1961 1962 1963 1964 1965 1966 1967 1968 1969
## [1261] 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1981 1982 1961 1962
## [1275] 1963 1964 1965 1966 1967 1992 1993 1995 1999 2000 2001 1961 1962 1964
## [1289] 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1996 1997
## [1303] 1998 1999 2000 2001 2002 2003 2004 2017 2008 2009 1992 1993 1994 1995
## [1317] 1996 1997 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
## [1331] 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986
## [1345] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [1359] 1975 1976 1977 1978 1979 1980 1981 1982 1983 1988 1961 1962 1963 1964
## [1373] 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
## [1387] 1979 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973
## [1401] 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987
## [1415] 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001
## [1429] 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
## [1443] 2016 2017 2018 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971
## [1457] 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1993 1961 1962
## [1471] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976
## [1485] 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1961 1962
## [1499] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1977
## [1513] 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991
## [1527] 1992 1993 1994 1995 1996 1997 1998 2000 2001 2002 2003 2004 2005 2006
## [1541] 2007 2008 2010 2011 2012 2013 2014 2015 2016 2017 2018 1964 1961 1962
## [1555] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976
## [1569] 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
## [1583] 1991 1992 1993 1994 1995 1996 1997 2002 1961 1962 1963 1965 1967 1968
## [1597] 1969 1970 1971 1972 1978 2015 2018 1961 1962 1963 1964 1965 1966 1967
## [1611] 1969 1970 1987 1998 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
## [1625] 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
## [1639] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [1653] 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
## [1667] 1989 1990 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006
## [1681] 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 1961 1962
## [1695] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976
## [1709] 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
## [1723] 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
## [1737] 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
## [1751] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [1765] 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
## [1779] 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
## [1793] 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
## [1807] 2017 2018 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
## [1821] 1973 1974 1975 1976 1977 1961 1962 1963 1964 1965 1966 1967 1968 1969
## [1835] 1970 1971 1972 1973 1974 1976 1977 1978 1979 1980 1981 1982 1984 1986
## [1849] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
## [1863] 1975 1976 1977 1978 1979 1961 1962 1961 1962 1963 1964 1965 1971 1972
## [1877] 1975 1976 1977 1978 1979 1980 1981 1996 1961 1962 1963 1964 1965 1966
## [1891] 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
## [1905] 1988 1989 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
## [1919] 2003 2004 2005 2006 2007 2008 2009 2010 2012 2013 2014 2017 1961 1962
## [1933] 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976
## [1947] 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
## [1961] 1961 1962 1963 1964 1965 1966 1967 1968 1961 1962 1963 1964 1965 1966
## [1975] 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
## [1989] 1981 1982 1984 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
## [2003] 1997 1998 1999 2000 2002 2003 2004 2005 2006 2007 2008 2009 1970 1972
## [2017] 1973 1978 1979 1980 1981 1961 1962 1963 1964 1965 1966 1967 1968 1969
## [2031] 1970 1971 1972 1973 1974 1975 1976 1998 1999 2000 2001 2002 2003 2004
## [2045] 2008 2009 2010 2011 2012 2013 2014 2016 2017 2018 1986 1987 1988 1989
## [2059] 1991 1972 1976 1980 1989 1990 1991 2001 2002 1967 1970 1985 1990 1998
## [2073] 1999 1972 1973 1974 1975 1976 1977 1979 1980 1961 1962 1963 1964 1965
## [2087] 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
## [2101] 1980 1981 1982 1985 1986 1987 1988 1961 1962 1963 1964 1965 1966 1967
## [2115] 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [2129] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [2143] 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
## [2157] 2010 2011 2012 2013 2014 2015 2016 2017 2018 1961 1962 1963 1964 1965
## [2171] 1967 1968 1969 1961 1962 1963 1967 1969 2014 2015 2016 2017 2018 1977
## [2185] 1978 1994 1995 2013 2015 2016 1961 1962 1963 1964 1965 1966 1967 1968
## [2199] 1969 1970 1971 1990 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
## [2213] 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1983 1961 1962
## [2227] 1963 1964 1965 1966 1967 1968 1969 1972 1961 1961 1962 1963 1964 1965
## [2241] 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1979 1982
## [2255] 1961 1962 1963 1964 1965 1966 1973 1975 1976 2014 1961 1962 1963 1964
## [2269] 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
## [2283] 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
## [2297] 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 1965 1968 1970
## [2311] 1971 1973 1993 1994 1995 1996 1961 1962 1963 1964 1965 1966 1967 1968
## [2325] 1969 1970 1971 1972 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
## [2339] 1984 1985 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
## [2353] 1999 2000 2002 2003 2004 2005 2006 2008 2009 1961 1962 1963 1964 1965
## [2367] 1966 1967 1968 1969 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
## [2381] 1981 1982 1990 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971
## [2395] 1972 1973 2001 2002 2003 2004 2005 2006 2007 2008 1961 1962 1963 1964
## [2409] 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
## [2423] 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
## [2437] 1993 1994 1995 1996 2000 2001 2012 2014 2015 2016 2017 2018 1999 2001
## [2451] 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
## [2465] 2016 2017 2018 1996 1997 1998 1999 2000 2001 2002 2007 2008 2009 2010
## [2479] 2011 2012 2013 2014 2015 2016 2017 2018 1961 1961 1962 1963 1964 1965
## [2493] 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
## [2507] 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
## [2521] 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
## [2535] 1995 1996 1961 1962 1963 1964 1965 1966 1967 1970 1971 1961 1962 1964
## [2549] 1965 1966 1967 1968 1969 1977 1978 1961 1962 1963 1964 1965 1966 1967
## [2563] 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [2577] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [2591] 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2010
## [2605] 2011 2012 2013 2014 1961 1962 1968 1969 1970 1971 1972 1973 1974 1975
## [2619] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989
## [2633] 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
## [2647] 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
## [2661] 2018 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973
## [2675] 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985
No 4
Negara yang punya hasil gandum (Wheat) di atas 5 ton pada tahun 2000
ke atas
data_filter<-filter(df_crop, Year > 2000,`Wheat (tonnes per hectare)` > 5)
data_filter$Entity
## [1] "Austria" "Austria" "Austria" "Austria"
## [5] "Austria" "Austria" "Austria" "Austria"
## [9] "Austria" "Austria" "Belgium" "Belgium"
## [13] "Belgium" "Belgium" "Belgium" "Belgium"
## [17] "Belgium" "Belgium" "Belgium" "Belgium"
## [21] "Belgium" "Belgium" "Belgium" "Belgium"
## [25] "Belgium" "Belgium" "Belgium" "Belgium"
## [29] "Bulgaria" "Central America" "Central America" "Central America"
## [33] "Central America" "Central America" "Central America" "Central America"
## [37] "Central America" "Central America" "Central America" "Central America"
## [41] "Chile" "Chile" "Chile" "Chile"
## [45] "Chile" "Chile" "Chile" "Chile"
## [49] "China" "China" "China" "China"
## [53] "China" "China" "Croatia" "Croatia"
## [57] "Croatia" "Croatia" "Croatia" "Croatia"
## [61] "Croatia" "Croatia" "Czech Republic" "Czech Republic"
## [65] "Czech Republic" "Czech Republic" "Czech Republic" "Czech Republic"
## [69] "Czech Republic" "Czech Republic" "Czech Republic" "Czech Republic"
## [73] "Czech Republic" "Denmark" "Denmark" "Denmark"
## [77] "Denmark" "Denmark" "Denmark" "Denmark"
## [81] "Denmark" "Denmark" "Denmark" "Denmark"
## [85] "Denmark" "Denmark" "Denmark" "Denmark"
## [89] "Denmark" "Denmark" "Denmark" "Eastern Asia"
## [93] "Eastern Asia" "Eastern Asia" "Eastern Asia" "Eastern Asia"
## [97] "Egypt" "Egypt" "Egypt" "Egypt"
## [101] "Egypt" "Egypt" "Egypt" "Egypt"
## [105] "Egypt" "Egypt" "Egypt" "Egypt"
## [109] "Egypt" "Egypt" "Egypt" "Egypt"
## [113] "Egypt" "Egypt" "Europe, Western" "Europe, Western"
## [117] "Europe, Western" "Europe, Western" "Europe, Western" "Europe, Western"
## [121] "Europe, Western" "Europe, Western" "Europe, Western" "Europe, Western"
## [125] "Europe, Western" "Europe, Western" "Europe, Western" "Europe, Western"
## [129] "Europe, Western" "Europe, Western" "Europe, Western" "Europe, Western"
## [133] "European Union" "European Union" "European Union" "European Union"
## [137] "European Union" "European Union" "European Union" "European Union"
## [141] "European Union" "European Union" "European Union" "European Union"
## [145] "European Union" "European Union" "France" "France"
## [149] "France" "France" "France" "France"
## [153] "France" "France" "France" "France"
## [157] "France" "France" "France" "France"
## [161] "France" "France" "France" "France"
## [165] "Germany" "Germany" "Germany" "Germany"
## [169] "Germany" "Germany" "Germany" "Germany"
## [173] "Germany" "Germany" "Germany" "Germany"
## [177] "Germany" "Germany" "Germany" "Germany"
## [181] "Germany" "Germany" "Hungary" "Hungary"
## [185] "Hungary" "Hungary" "Hungary" "Hungary"
## [189] "Ireland" "Ireland" "Ireland" "Ireland"
## [193] "Ireland" "Ireland" "Ireland" "Ireland"
## [197] "Ireland" "Ireland" "Ireland" "Ireland"
## [201] "Ireland" "Ireland" "Ireland" "Ireland"
## [205] "Ireland" "Ireland" "Latvia" "Lithuania"
## [209] "Luxembourg" "Luxembourg" "Luxembourg" "Luxembourg"
## [213] "Luxembourg" "Luxembourg" "Luxembourg" "Luxembourg"
## [217] "Luxembourg" "Luxembourg" "Luxembourg" "Luxembourg"
## [221] "Luxembourg" "Luxembourg" "Luxembourg" "Luxembourg"
## [225] "Luxembourg" "Luxembourg" "Malta" "Malta"
## [229] "Mexico" "Mexico" "Mexico" "Mexico"
## [233] "Mexico" "Mexico" "Mexico" "Mexico"
## [237] "Mexico" "Mexico" "Mexico" "Mexico"
## [241] "Namibia" "Namibia" "Namibia" "Namibia"
## [245] "Namibia" "Namibia" "Namibia" "Namibia"
## [249] "Namibia" "Namibia" "Namibia" "Namibia"
## [253] "Namibia" "Namibia" "Namibia" "Netherlands"
## [257] "Netherlands" "Netherlands" "Netherlands" "Netherlands"
## [261] "Netherlands" "Netherlands" "Netherlands" "Netherlands"
## [265] "Netherlands" "Netherlands" "Netherlands" "Netherlands"
## [269] "Netherlands" "Netherlands" "Netherlands" "Netherlands"
## [273] "Netherlands" "New Zealand" "New Zealand" "New Zealand"
## [277] "New Zealand" "New Zealand" "New Zealand" "New Zealand"
## [281] "New Zealand" "New Zealand" "New Zealand" "New Zealand"
## [285] "New Zealand" "New Zealand" "New Zealand" "New Zealand"
## [289] "New Zealand" "New Zealand" "New Zealand" "Northern Europe"
## [293] "Northern Europe" "Northern Europe" "Northern Europe" "Northern Europe"
## [297] "Northern Europe" "Northern Europe" "Northern Europe" "Northern Europe"
## [301] "Northern Europe" "Northern Europe" "Northern Europe" "Northern Europe"
## [305] "Northern Europe" "Northern Europe" "Northern Europe" "Northern Europe"
## [309] "Northern Europe" "Norway" "Norway" "Saudi Arabia"
## [313] "Saudi Arabia" "Saudi Arabia" "Saudi Arabia" "Saudi Arabia"
## [317] "Saudi Arabia" "Saudi Arabia" "Saudi Arabia" "Saudi Arabia"
## [321] "Saudi Arabia" "Saudi Arabia" "Saudi Arabia" "Saudi Arabia"
## [325] "Saudi Arabia" "Saudi Arabia" "Slovakia" "Slovakia"
## [329] "Slovakia" "Slovenia" "Slovenia" "Slovenia"
## [333] "Slovenia" "Slovenia" "Slovenia" "Sweden"
## [337] "Sweden" "Sweden" "Sweden" "Sweden"
## [341] "Sweden" "Sweden" "Sweden" "Sweden"
## [345] "Sweden" "Sweden" "Sweden" "Sweden"
## [349] "Sweden" "Sweden" "Sweden" "Sweden"
## [353] "Switzerland" "Switzerland" "Switzerland" "Switzerland"
## [357] "Switzerland" "Switzerland" "Switzerland" "Switzerland"
## [361] "Switzerland" "Switzerland" "Switzerland" "Switzerland"
## [365] "Switzerland" "Switzerland" "Switzerland" "Switzerland"
## [369] "Switzerland" "United Kingdom" "United Kingdom" "United Kingdom"
## [373] "United Kingdom" "United Kingdom" "United Kingdom" "United Kingdom"
## [377] "United Kingdom" "United Kingdom" "United Kingdom" "United Kingdom"
## [381] "United Kingdom" "United Kingdom" "United Kingdom" "United Kingdom"
## [385] "United Kingdom" "United Kingdom" "United Kingdom" "Zambia"
## [389] "Zambia" "Zambia" "Zambia" "Zambia"
## [393] "Zambia" "Zambia" "Zambia" "Zambia"
## [397] "Zambia" "Zambia" "Zambia" "Zambia"
## [401] "Zambia" "Zambia" "Zambia" "Zambia"
## [405] "Zambia" "Zimbabwe"
No 5
Memunculkan data negara Indonesia dan Malaysia khusus untuk tahun
2015 saja
data_filter <- filter(df_crop, Code=='IDN' | Code=='MYS', Year == 2015 )
data_filter
## # A tibble: 2 × 14
## Entity Code Year `Wheat (tonnes per hectare)` `Rice (tonnes per hectare)`
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Indonesia IDN 2015 NA 5.34
## 2 Malaysia MYS 2015 NA 4.02
## # ℹ 9 more variables: `Maize (tonnes per hectare)` <dbl>,
## # `Soybeans (tonnes per hectare)` <dbl>,
## # `Potatoes (tonnes per hectare)` <dbl>, `Beans (tonnes per hectare)` <dbl>,
## # `Peas (tonnes per hectare)` <dbl>, `Cassava (tonnes per hectare)` <dbl>,
## # `Barley (tonnes per hectare)` <dbl>,
## # `Cocoa beans (tonnes per hectare)` <dbl>,
## # `Bananas (tonnes per hectare)` <dbl>
No 6
Negara yang punya hasil jagung (Maize) paling rendah di tahun
2020
data_filter <- filter(df_crop, !is.na(`Maize (tonnes per hectare)`), Year == 2020 )
data_filter <- arrange(data_filter, `Maize (tonnes per hectare)`)
head(data_filter,1)
## # A tibble: 0 × 14
## # ℹ 14 variables: Entity <chr>, Code <chr>, Year <dbl>,
## # Wheat (tonnes per hectare) <dbl>, Rice (tonnes per hectare) <dbl>,
## # Maize (tonnes per hectare) <dbl>, Soybeans (tonnes per hectare) <dbl>,
## # Potatoes (tonnes per hectare) <dbl>, Beans (tonnes per hectare) <dbl>,
## # Peas (tonnes per hectare) <dbl>, Cassava (tonnes per hectare) <dbl>,
## # Barley (tonnes per hectare) <dbl>, Cocoa beans (tonnes per hectare) <dbl>,
## # Bananas (tonnes per hectare) <dbl>
No 7
Mengurutkan data Indonesia dari hasil kentang (Potatoes) yang paling
tinggi
data_filter <- filter(df_crop, Code=='IDN')
data_arrange <- arrange(data_filter, desc(`Potatoes (tonnes per hectare)`))
data_arrange
## # A tibble: 58 × 14
## Entity Code Year `Wheat (tonnes per hectare)` Rice (tonnes per hectare…¹
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Indonesia IDN 2018 NA 5.19
## 2 Indonesia IDN 2016 NA 5.24
## 3 Indonesia IDN 2015 NA 5.34
## 4 Indonesia IDN 2014 NA 5.13
## 5 Indonesia IDN 2006 NA 4.62
## 6 Indonesia IDN 2008 NA 4.89
## 7 Indonesia IDN 1995 NA 4.35
## 8 Indonesia IDN 2012 NA 5.14
## 9 Indonesia IDN 2009 NA 5.00
## 10 Indonesia IDN 2005 NA 4.57
## # ℹ 48 more rows
## # ℹ abbreviated name: ¹`Rice (tonnes per hectare)`
## # ℹ 9 more variables: `Maize (tonnes per hectare)` <dbl>,
## # `Soybeans (tonnes per hectare)` <dbl>,
## # `Potatoes (tonnes per hectare)` <dbl>, `Beans (tonnes per hectare)` <dbl>,
## # `Peas (tonnes per hectare)` <dbl>, `Cassava (tonnes per hectare)` <dbl>,
## # `Barley (tonnes per hectare)` <dbl>, …
No 8
Membuat kolom Rice_Status berisi teks “Tinggi” jika padi > 4 ton,
dan “Rendah” jika di bawahnya
df_crop %>%
mutate(Rice_Status = ifelse(`Rice (tonnes per hectare)` > 4, "Tinggi", "Rendah"))
## # A tibble: 13,075 × 15
## Entity Code Year `Wheat (tonnes per hectare)` Rice (tonnes per hecta…¹
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Afghanistan AFG 1961 1.02 1.52
## 2 Afghanistan AFG 1962 0.974 1.52
## 3 Afghanistan AFG 1963 0.832 1.52
## 4 Afghanistan AFG 1964 0.951 1.73
## 5 Afghanistan AFG 1965 0.972 1.73
## 6 Afghanistan AFG 1966 0.867 1.52
## 7 Afghanistan AFG 1967 1.12 1.92
## 8 Afghanistan AFG 1968 1.16 1.95
## 9 Afghanistan AFG 1969 1.19 1.98
## 10 Afghanistan AFG 1970 0.956 1.81
## # ℹ 13,065 more rows
## # ℹ abbreviated name: ¹`Rice (tonnes per hectare)`
## # ℹ 10 more variables: `Maize (tonnes per hectare)` <dbl>,
## # `Soybeans (tonnes per hectare)` <dbl>,
## # `Potatoes (tonnes per hectare)` <dbl>, `Beans (tonnes per hectare)` <dbl>,
## # `Peas (tonnes per hectare)` <dbl>, `Cassava (tonnes per hectare)` <dbl>,
## # `Barley (tonnes per hectare)` <dbl>, …
No 9
Rata-rata hasil panen pisang (Bananas) di Indonesia dari seluruh
tahun yang ada
mean(filter(df_crop, Code=='IDN')$`Bananas (tonnes per hectare)` )
## [1] 30.50554
No 10
Menampilkan data jagung mulai tahun 2010, lalu menghitung simpangan
baku per negara, dan mengurutkannya dari nilai yang paling besar
df_crop %>%
filter(Year > 2010,!is.na(`Maize (tonnes per hectare)`)) %>%
group_by(Code) %>%
summarise(`Std Deviation Maize (tonnes per hectare)` = sd(`Maize (tonnes per hectare)`)) %>%
arrange(desc(`Std Deviation Maize (tonnes per hectare)`))
## # A tibble: 171 × 2
## Code `Std Deviation Maize (tonnes per hectare)`
## <chr> <dbl>
## 1 KWT 9.85
## 2 ARE 9.37
## 3 JOR 7.49
## 4 ISR 5.03
## 5 <NA> 2.72
## 6 GUF 2.59
## 7 NCL 2.26
## 8 VCT 1.78
## 9 SVK 1.74
## 10 OMN 1.72
## # ℹ 161 more rows