knitr::opts_chunk$set(
message = F,
warning = F
)
Load the dataset
pacman::p_load(tidyverse,
sjPlot)
Explore the dataset
df <- read_csv("https://j.mp/2JJYkeN")
head(df)
Some thoughts: Year should be integer or factor
Check the amount of NA data
For this I will use the visdat package
glimpse(df)
Rows: 100
Columns: 110
$ RespondentID <chr> "6151307314", "6150081146", "6144349659", "6139980102", "6131571599", "612…
$ `Power position` <chr> "Oposition", "Oposition", "Oposition", "Government", "Oposition", "Opositi…
$ Participation <chr> "yes", "yes", "yes", "Yes", "yes", "yes", "Yes", "Yes", "Yes", "Yes", "Yes…
$ Year <dbl> 1956, 1980, 1982, 1949, 1953, 1955, 1951, 1945, 1970, 1956, 1962, 1964, 19…
$ Gender <chr> "Man", "Man", "Man", "Man", "Man", "Man", "Man", "Man", "Man", "Man", "Man…
$ Language <chr> "Russian", "Latvian", "Latvian", "Latvian", "Latvian", "Latvian", "Latvian…
$ Parties <chr> "Frakcij? \"Saska?a\"", "Pie frakcij?m nepiedero�s deput?ts", "Latvijas Re…
$ YearsMP <dbl> 18, 25, 7, 6, 1, 25, 2, 25, 25, 6, 6, 15, 6, 6, 2, 3, 1, 4, 17, 4, 4, 5, 7…
$ Chairman <chr> "No", "No", "No", "Yes", "No", "No", "No", "No", "No", "Yes", "No", "Yes",…
$ Specialisation <chr> "more than two", "more than two", "more than two", "one or two", "one or t…
$ `8.LETA/BNS` <chr> "No", "No", "No", "yes", "yes", "No", "No", "No", "No", "No", "No", "No", …
$ Monitoring <chr> "No", "No", "No", "yes", "yes", "yes", "No", "yes", "No", "No", "yes", "ye…
$ Oft_radio_TV <chr> "Few times a year", "Once", "Once", "Once", "na", "Less or not at all", "M…
$ Oft_newspaper <chr> "Few times a year", "twice a week", "twice a month", "twice a month", "na"…
$ Oft_publication <chr> "Few times a year", "Once", "Once", "Once", "na", "Less or not at all", "t…
$ FB <chr> "yes", "twice a week", "twice a month", "twice a week", "yes", "na", "Many…
$ draugiem.lv <chr> "na", "Many times a week", "Once", "Less or not at all", "na", "na", "yes"…
$ Instagram <chr> "na", "yes", "twice a month", "yes", "na", "na", "na", "twice a month", "y…
$ vkontakte <chr> "na", "na", "yes", "na", "na", "na", "na", "na", "na", "na", "na", "yes", …
$ Odnoklassniki <chr> "na", "yes", "yes", "na", "na", "na", "na", "na", "na", "na", "na", "na", …
$ Twitter <chr> "na", "na", "yes", "na", "na", "na", "na", "na", "na", "na", "na", "na", "…
$ dont_use <chr> "na", "na", "na", "na", "na", "yes", "na", "na", "na", "na", "yes", "na", …
$ Soc.media_useful <chr> "4", "yes", "na", "na", "3", "6", "na", "yes", "na", "na", "na", "na", "ye…
$ Lv_unbiased <chr> "3", "na", "yes", "na", "4", "3", "2", "na", "na", "na", "4", "na", "na", …
$ LV_truthful <chr> "4", "5", "na", "4", "4", "3", "4", "na", "3", "6", "4", "na", "3", "na", …
$ LV_complete_pic <dbl> 4, 2, 5, 4, 3, 3, 4, 1, 3, 3, 4, 4, 3, 5, 3, 4, 3, 3, 2, 5, 3, 2, 3, 3, 4,…
$ LV_know_sub <dbl> 3, 2, 3, 3, 3, 3, 4, 3, 2, 3, 3, 3, 3, 2, 3, 4, 3, 3, 2, 3, 3, 2, 2, 3, 4,…
$ LV_trustworthy <dbl> 2, 2, 4, 3, 4, 3, 3, 3, 2, 4, 4, 3, 4, 2, 2, 3, 3, 3, 3, 3, 3, 1, 2, 2, 3,…
$ RU_unbiased <dbl> 3, 3, 3, 3, 2, 3, 5, 3, 1, 4, 4, 3, 3, 2, 4, 4, 2, 3, 3, 3, 2, 1, 5, 3, 3,…
$ RU_truthful <dbl> 4, 2, 3, 3, 2, 3, 6, 3, 5, 2, 3, 3, 2, 2, 2, 4, 2, 3, 2, 4, 3, 2, 3, 3, 4,…
$ RU_comp_picture <dbl> 3, 2, 4, 6, 6, 3, 6, 3, 2, 6, 2, 3, 2, 2, 3, 4, 2, 1, 2, 2, 2, 3, 2, 3, 4,…
$ RU_know_sub <dbl> 2, 2, 2, 6, 2, 3, 6, 3, 2,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, 2, 2, 6, 5, 6, 7, 6,…
$ LV_radio_pub <dbl> 8, 8, 2, 7, 5, 7, 1, 2, 10, 10, 8, 8, 8, 10, 8, 9, 8, 7, 3, 3, 7, 6, 10, 6…
$ RU_radio_pub <dbl> 1, 6, 5, NA, 4, 8, 8, 7, 7, NA, 9, 8, 8, 8, 8, 8, 8, 2, 3, 8, 6, 6, 10, 4,…
$ LV_TV_pub <dbl> 9, 7, 4, 8, 8, 8, 1, 6, 10, 9, 5, 8, 7, 8, 6, 9, 8, 8, 7, 6, 8, 6, 5, 6, 9…
$ RU_TV_pub <dbl> 1, 6, 7, NA, 8, 8, 7, 6, 9, NA, 10, 8, 9, 10, 6, 9, 8, 5, 7, 9, 6, 8, 6, 4…
$ LV_newsp_pub <dbl> 6, 8, 6, 9, 3, 5, 1, 6, 10, 8, 9, 8, 8, 10, 7, 8, 8, 9, 8, 8, 9, 8, 5, 5, …
$ RU_newspap_pub <dbl> 0, 7, 7, NA, 3, 5, 5, 7, 7, NA, 9, 8, 9, 10, 5, 6, 8, 6, 8, 9, 7, 8, 6, 4,…
$ LV_magaz_pub <dbl> 8, 7, 8, 6, 2, 4, 1, 5, 6, 9, 10, 8, 8, 10, 3, 6, 8, 7, 6, 7, 5, 8, 4, 3, …
$ RU_magaz_pub <dbl> 3, 7, 4, NA, 2, 4, 5, 7, 8, NA, 8, 8, 9, 10, 3, 6, 8, 6, 6, 8, 6, 8, 6, 2,…
$ LV_newssites_pub <dbl> 7, 7, 4, 4, 8, 8, 1, 6, 4, NA, 7, 8, 8, 10, 4, 7, 8, 7, 2, 5, 5, 8, 5, 6, …
$ RU_newssites_pub <dbl> 5, 7, 5, NA, 8, 8, 7, 3, 6, NA, 9, 8, 9, 10, 4, 7, 8, 6, 2, 6, 6, 7, 6, 5,…
$ Much_power <dbl> 3, 9, 5, 4, 3, 3, 1, 2, 10, 10, 9, 8, 8, 10, 8, 9, 3, 8, 2, 4, 8, 7, 10, 4…
$ Media_owners <dbl> 4, 7, 7, NA, 4, 3, 3, 8, 7, NA, 2, 8, 4, 10, 8, 9, 3, 7, 2, 9, 7, 6, 10, 4…
$ Motiv_pol_power <dbl> 3, 5, 7, 4, 2, 3, 6, 7, 4, 4, 3, 8, 3, 10, 3, 2, 3, 1, 4, 7, 3, 6, 3, 3, 4…
$ Journalists_indep <dbl> 3, 5, 3, 5, 3, 2, 6, 4, 5, 4, 2, 4, 4, 5, 4, 3, 2, 4, 5, 5, 2, 5, 4, 2, 3,…
$ Media_pub_agenda <dbl> 3, 4, 4, 3, 3, 3, 4, 4, 5, 4, 3, 5, 3, 5, 2, 2, 4, 4, 5, 5, 3, 4, 4, 2, 2,…
$ Politicians_publicity <dbl> 5, 1, 6, 3, 0, 2, 3, 4, 2, 5, 4, 4, 3, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 4, 3,…
$ Analitic_broadcast <dbl> 4, 4, 2, 4, 4, 5, 6, 2, 5, 3, 3, 2, 3, 2, 2, 3, 4, 4, 4, 2, 4, 2, 4, 3, 4,…
$ Makes_breakes_politic <dbl> 5, 5, 4, 4, 3, 4, 3, 4, 4, 3, 3, 4, 4, 5, 3, 4, 4, 4, 4, 4, 3, 3, 4, 4, 5,…
$ Distrust_politicians <dbl> 4, 5, 4, 4, 5, 4, 6, 5, 4, 4, 4, 3, 4, 4, 2, 4, 4, 4, 3, 4, 4, 4, 3, 4, 5,…
$ More_power_than_MP <dbl> 5, 5, 4, 5, 2, 3, 1, 3, 3, 4, 3, 4, 4, 5, 3, 3, 4, 4, 3, 5, 4, 4, 3, 4, 5,…
$ More_power_elect <dbl> 5, 2, 3, 5, 5, 3, 6, 4, 5, 4, 2, 5, 3, 5, 2, 1, 4, 4, 3, 5, 3, 4, 3, 4, 2,…
$ Leak_info <dbl> 5, 3, 4, 3, 3, 5, 6, 4, 5, 4, 4, 3, 4, 5, 2, 1, 4, 5, 3, 4, 3, 5, 2, 5, 2,…
$ Express_opinion <dbl> 1, 5, 2, 4, 3, 3, 6, 5, 4, 5, 3, 2, 3, 4, 5, 2, 4, 5, 4, 3, 4, 2, 4, 4, 4,…
$ Agenda_prime <dbl> 3, 5, 4, 5, 4, 5, 3, 5, 2, 3, 2, 4, 4, 5, 5, 3, 3, 3, 5, 4, 6, 4, 5, 4, 3,…
$ Agenda_ministers <dbl> 4, 2, 6, 5, 3, 5, 5, 3, 5, 5, 5, 4, 4, 5, 1, 2, 3, 2, 5, 5, 1, 4, 1, 3, 3,…
$ Agenda_MP <dbl> 3, 4, 3, 4, 3, 4, 4, 5, 5, 4, 4, 5, 4, 4, 5, 4, 3, 5, 4, 5, 4, 5, 4, 3, 5,…
$ Agenda_parties <dbl> 2, 4, 3, 4, 4, 4, 2, 4, 3, 3, 4, 3, 4, 3, 3, 3, 3, 5, 4, 4, 3, 4, 4, 3, 4,…
$ Agenda_interest_groups <dbl> 4, 4, 3, 3, 3, 4, 2, 4, 3, 3, 4, 3, 3, 3, 2, 4, 3, 3, 3, 4, 2, 4, 3, 3, 3,…
$ Agenda_TV_radio <dbl> 4, 4, 4, 4, 4, 4, 2, 3, 4, 4, 4, 3, 3, 3, 4, 4, 3, 5, 5, 3, 3, 3, 3, 4, 4,…
$ Agenda_written_press <dbl> 3, 3, 3, 3, 4, 4, 5, 3, 4, 4, 5, 4, 4, 3, 3, 4, 3, 4, 2, 5, 4, 4, 3, 3, 2,…
$ `10y_parties` <dbl> 4, 4, 3, 4, 6, 6, 3, 3, 5, 4, 4, 3, 4, 4, 3, 4, 4, 5, 3, 4, 5, 3, 2, 5, 2,…
$ `10y_MP` <dbl> 3, 2, 3, 3, 5, 5, 6, 4, 3, 4, 7, 2, 4, 2, 2, 3, 4, 5, 2, 4, 2, 3, 2, 4, 2,…
$ `10y_ministers` <dbl> 6, 7, 2, 6, 5, 6, 4, 4, 7, 5, 6, 2, 5, 2, 7, 6, 4, 5, 7, 3, 6, 3, 5, 5, 6,…
$ `10_years_unions` <dbl> 2, 7, 5, 5, 3, 3, 6, 6, 5, 4, 6, 6, 5, 6, 6, 5, 4, 5, 6, 6, 6, 7, 5, 4, 5,…
$ `10y_employers` <dbl> 5, 7, 4, 5, 3, 6, 2, 2, 3, 4, 4, 5, 3, 4, 6, 6, 4, 5, 5, 4, 5, 6, 5, 5, 7,…
$ `10y_municip` <dbl> 5, 4, 4, 3, 3, 6, 4, 6, 5, 5, 5, 6, 3, 4, 2, 4, 4, 5, 3, 5, 3, 7, 3, 5, 2,…
$ `10y_NGO` <dbl> 4, 5, 4, 4, NA, 6, 6, 1, 5, 5, 5, 5, 4, 3, 2, 5, 4, 5, 4, 4, 5, 4, 2, 3, 3…
$ `10y_media` <dbl> 7, 7, 4, 5, 4, 7, 2, 2, 6, 6, 4, 5, 2, 4, 5, 4, 4, 6, 5, 5, 7, 4, 6, 5, 4,…
$ `10y_officials` <dbl> 7, 5, 3, 4, 2, 6, 6, 4, 6, 6, 5, 5, 5, 4, 2, 5, 4, 5, 4, 6, 3, 5, 1, 6, 3,…
$ `10y_EU` <dbl> 6, 6, 2, 6, 2, 7, 2, 1, 7, 6, 4, 4, 2, 3, 4, 6, 4, 6, 5, 5, 5, 3, 2, 3, 5,…
$ `10y_OECD` <dbl> 5, 6, 4, 4, 3, 6, 4, 5, 3, 3, 6, 5, 2, 6, 5, 3, 4, 5, 6, 6, 4, 5, 4, 6, 4,…
$ Inf_Parl_agenda <chr> "to some extent", "6", "5", "4", "to some extent", "to some extent", "4", …
$ Inf_Govr_agenda <chr> "quite a little", "5", "4", "3", "quite a little", "to some extent", "na",…
$ Inf_disc_Parliament <chr> "quite a little", "to some extent", "3", "to some extent", "to some extent…
$ Inf_disc_pub <chr> "very much", "to some extent", "quite a little", "to some extent", "quite …
$ Inf_MP_success <chr> "very much", "to some extent", "to some extent", "quite a little", "quite …
$ Inf_deb_Parliament <chr> "often", "quite a little", "quite a little", "very little or not at all", …
$ Inf_Committees <chr> "very often", "very much", "quite a little", "very little or not at all", …
$ Inf_party_meeting <chr> "often", "now and then", "very much", "now and then", "often", "now and th…
$ Inf_question_hour <chr> "now and then", "often", "often", "often", "now and then", "often", "seldo…
$ Inf_coalition_talks <chr> "na", "now and then", "now and then", "seldom", "na", "now and then", "na"…
$ Inf_informal_gather <chr> "very often", "now and then", "very often", "seldom", "na", "now and then"…
$ Act_initiatives <chr> "Quite small part", "often", "now and then", "often", "Quite small part", …
$ Act_govern <chr> "Quite large part", "often", "na", "now and then", "None", "Quite large pa…
$ Act_question_govern <chr> "Quite large part", "Quite large part", "often", "Neither big nor small", …
$ Act_plenar_speach <chr> "Neither big nor small", "Quite large part", "Quite small part", "Neither …
$ Act_committee_speach <chr> "Neither big nor small", "Quite large part", "Quite small part", "Neither …
$ Act_oral_hour <chr> "na", "Very large part", "Quite small part", "Quite small part", "Neither …
$ Info_soc_prob <chr> "Some", "Quite large part", "Very large part", "Quite small part", "Quite …
$ Info_import_pub <chr> "Some", "None", "Neither big nor small", "Quite small part", "Some", "Quit…
$ Info_public <chr> "Quite a lot", "Quite a lot", "Quite large part", "Quite a lot", "Some", "…
$ Inf_polit_weapon <chr> "Quite little", "Quite a lot", "Some", "Quite a lot", "Quite little", "Qui…
$ Info_other_MP <chr> "Some", "Often", "Quite little", "Quite a lot", "Some", "Quite a lot", "Ve…
$ Info_imp_parties <chr> "Often", "Quite a lot", "Often", "Quite little", "Quite a lot", "Quite a l…
$ X108 <chr> NA, "Quite a lot", "Some", "Some", NA, NA, "Quite a lot", "Very little or …
$ X109 <chr> NA, "Often", "Some", "Quite a lot", NA, NA, NA, "Some", "Quite a lot", "Of…
$ X110 <chr> NA, NA, "Quite a lot", NA, NA, NA, NA, "Some", NA, NA, NA, "Quite a lot", …
and plot
pacman::p_load(visdat)
Lot of NAs…
Let’s check some variables
df %>%
visdat::vis_dat()
table(df$Gender)
Man Woman
43 9
table(df$`Power position`)
Government Oposition
61 39
Seems to me that the data are divided in
demographic data
[1] “RespondentID” “Power position” “Participation” “Year” “Gender”
[6] “Language” “Parties” “YearsMP” “Chairman” “Specialisation”
[11] “8.LETA/BNS”
Some questions about use of social media
“Monitoring” “Oft_radio_TV” “Oft_newspaper” “Oft_publication”
[16] “FB” “draugiem.lv” “Instagram” “vkontakte” “Odnoklassniki”
[21] “Twitter” “dont_use”
some perceptions about their utility
the rest of the columns
We can use an special package to create summary table ready for publication, it’s called gtsummary
table(df$Gender, df$`Power position`)
Government Oposition
Man 30 13
Woman 5 4
Learn about the package here: https://github.com/ddsjoberg/gtsummary
For example, a table of the demographic data by power position would be:
pacman::p_load(gtsummary)
As you can see, there is a lot of data to clean here.
I strongly suggest you to learn two of the tidyverse packages:
What are MPs perception on media power compared to other actors (Columns Agenda_TV_radio and Agenda_written_press compared to Agenda_prime; Agenda_ministers; Agenda_MP; Agenda_parties; Agenda_interest_groups). The survey was in Likert scale 1 - 5);
I don’t have much experience with this, so I google: https://www.google.com/search?q=lickert+data+r&oq=lickert+data+r&aqs=chrome..69i57.7470j0j1&sourceid=chrome&ie=UTF-8
I will subset the dataset, selecting some columns only
df %>%
select(`Power position`:Specialisation) %>% # here I select the desired columns to summarize
gtsummary::tbl_summary(by = `Power position`)
| Characteristic | Government, N = 611 | Oposition, N = 391 |
|---|---|---|
| Participation | ||
| No | 26 (43%) | 22 (56%) |
| yes | 0 (0%) | 17 (44%) |
| Yes | 35 (57%) | 0 (0%) |
| Year | 1,963 (1,954, 1,971) | 1,964 (1,956, 1,973) |
| Unknown | 26 | 22 |
| Gender | ||
| Man | 30 (86%) | 13 (76%) |
| Woman | 5 (14%) | 4 (24%) |
| Unknown | 26 | 22 |
| Language | ||
| Latvian | 32 (91%) | 11 (65%) |
| Russian | 3 (8.6%) | 6 (35%) |
| Unknown | 26 | 22 |
| Parties | ||
| Frakcij? "No sirds Latvijai" | 0 (0%) | 7 (18%) |
| Frakcij? "Saska?a" | 0 (0%) | 24 (62%) |
| Frakcij?��Vienot?ba" | 23 (38%) | 0 (0%) |
| Latvijas Re?ionu apvien?bas frakcij? | 0 (0%) | 7 (18%) |
| Nacion?l? apvien?bas �Visu Latvijai!�-�T?vzemei un Br?v?bai/LNNK�frakcij? | 17 (28%) | 0 (0%) |
| Pie frakcij?m nepiedero�s deput?ts | 0 (0%) | 1 (2.6%) |
| Za?o un Zemnieku savien?bas frakcij? | 21 (34%) | 0 (0%) |
| YearsMP | 6 (4, 6) | 7 (3, 18) |
| Unknown | 26 | 22 |
| Chairman | 14 (40%) | 3 (18%) |
| Unknown | 26 | 22 |
| Specialisation | ||
| more than two | 25 (71%) | 11 (65%) |
| one or two | 10 (29%) | 6 (35%) |
| Unknown | 26 | 22 |
|
1
Statistics presented: n (%); Median (IQR)
|
||
after googling some hours found some packages that can help to analyze Likert data
mydf <- df %>%
select(Journalists_indep:Agenda_written_press)
Please, read the documentation and options of the package here: https://cran.r-project.org/web/packages/sjPlot/sjPlot.pdf
Also you can order by some options, see page 25, the option sort.frq = from the plot_likert function
and you can create different plot for different groups, for example for men and women
:)
Check the survey package, specially designed to analyze data from surveys
http://r-survey.r-forge.r-project.org/survey/
since is quite an old package, there is a tool that allows you to work with dplyr from tidyverse package: