Save plots using ggplot2

This is how you save plots to hard drive when using gglpot. Uisng 300 dpi as resolution should be enough for publication. You have to give the height and width (five is good but use what fits you). You don’t need to scale it down to 0.8.

ggsave("~/gitlab/moralisk.org/p1.png", dpi = 300, scale = 0.8, height = 5, width = 5)

New film on SPSS

I usually don’t use SPSS. My main program for doing statistics is R. But when teaching I sometimes need to use SPSS. SPSS can be quite hard to use since there are so many options, and you need to use i a lot be familiar with the program. I there made a video showing various kind of things that can be done in SPSS.

Emacs — how I use it

I use Emacs — every day. Emacs is a text editor that is complex, in fact so complex that it is more of an environment. It is in general an environment for programming. So why do I use Emacs? I am not a programmer, I am a social scientist. Well, I originally used Emacs as an environment to program i R, and doing statistics. I rather soon found out that it can be configured. I started to use org-mode as a note taker. Later on I started to use org-mode as a calendar and as planning tool for my work.

Somewhat later I started to use Emacs when writing in latex, and why not markdown (which I use rather seldom since org-mode is so much better). I discovered mu4e, which handles e-mails inside Emacs. By the way, I use Emacs as a file manager. In fact — I use Emacs for almost everything I do on my computer, except web browsing. I even use Emacs to do my presentations, via ox-reveal.

For me Emacs is super effective, not just to do statistics in R, but to handle e-mails and organizing my work in general. Would I recommend Emacs for other social scientist? Probably not. Not because it is bad, but because I seldom recommend programs — but also that I don’t think the kind of work flow I have suits everyone. But I don’t know, so I have decided to write about my set up and what Emacs allows me to do. If you are impatient you can check out my config file here.

A nice theme for the desktop?

A nice theme for the desktop is not super important. OK, it has to look decent, but on my main computer I hardly see the desktop theming, or the icons. I just see the application I use. When the main application is Emacs, and the second a web browser, themes of the desktop does not matter much. However I found this, and I must say it looks really good. I checked the config files, and saw that the owner of the destop has developed the theme used. So I downloaded it on one of my old computer, which has xfce4 as desktop environment.

Here you can see the result — pretty nice.

2017 coming to an end

2017 is coming to and end. Usually I don’t care much about these things, but this year it is symbolic — 2017 was a really bad year. The picture above represents it rather well. One crisis after another followed each other. I further had more teaching than planed. In total I did not had much time for research. I really hope 2017 becomes better. Here are something I plan to do:

  • representation among populist right-wing politicians
  • working class values and represenation among local politicians

Besides these main research topics I will do some research on the self-employed. I and two colleges have collected data among the self-employed with the help of ”Företagarna”, who organizes the small and middle sized self-employed in Sweden. I will also apply for research grants. But as a social scientist it is hard, really hard to get funding. I will also write and organize this internet site more than I have done for several years.

Markdown is a practical tool

Introduction

Markdown is a simplified way of writing HTML-code. I have not engaged myself especially much in markdown. Yes, I have heard about, especially in relation to RStuido. However, I don’t use RStudio, except when I am teaching. And to be honest, it is here I find most use of Markdown. For example, in a couple of weeks I will be teaching on a module to a course on Criminology. The module I will be teaching on is about statistical methods. In the module we use R statistics. Good to know is that the students are not experienced with methods, and using R and writing codes can be overwellming. I have had this module two times now, so I know by fact that it works. But for some students it is of course hard and frustrating to write code — especially if not done that before. Which is the case for most of the students.

So one Saturday I sat down and started to learn Markdown. As I have said in previous posts I use Emacs. But in this case I actually started by using RStudio, since evertyhing is already set up. In Emacs additional packages must be installed.

One of the best features of Markdown is the possibility to use code boxes (of course also available in HTML). For example like this:

install.packages("haven")
library(haven)
wd <- read_sav("data_file.sav")

Another very good feature (works very well when using RStudio) is the possbility to run the r code and get the output presented in the document. Markdown is also available in WordPress. Here I have used wp-markdown.

Can you use Linux as your main work computer?


… I don’t know – but I have used Linux as my main system for more than a year now. My first computer  was a Commodore 64 which was mainly used for playing games. Back in the 1990’s, before we had Internet, my family bought an Olivetti, which had Windows. Ever since then I have used Windows. But back in 2012 I changed OS toOSX, when I bought a Macbook Pro (mid 2012). As a secondary machine I have used Linux since 2010 – mainly Ubuntu. So I have been familiar with Linux for some time now. I never had an idea to change my main system to Linux. But in the early autumn I was starting think about building a server, so I went to the store and bought some computer parts. But then the workload increased massively and there was no time to go further with the project.

In November/December that year the workload decreased some and one weekend I set up the server using Ubuntu as the operative system. During the same autumn Apple upgraded OSX from Yosemite to El Capitan, and with El Capitan Apple introduced System Integrity Protection (SIP), which prevents any user, even the root user, to modify certain files in the system. I had modified ‘certain’ files in Yosemite, especially config files related to Finder. Thus, suddenly Finder did not work as I was used to. I know that SIP can be overrided, and I did. But every time the system updated I had to override it again and do the again do the changes I wanted. So in December the main computer (by then a Macbook pro mid 2014) followed the server and I installed ubuntu, or to be more precise xubuntu, on the computer.

In spring 2016 I changed distro to Fedora, which I use today. There has mainly been no problems at all. The wifi does not work out of the box, but after installing the correct drivers that is not either an issue. As desktop I use Gnome, and after some tweaking really like it. In the picture you can see how my desktop look like.

My Desktop using Gnome

Workspaces to Dock extension.

Gnome is not that useful if you are not using extensions. So one of the first things to do is to install gnome-tweak-tool and start installing extensions. As you can see I have a lot of extensions going on my system. I have temperature and fan-speed, a to-do list extension and caffein (which can prevent your computer from going into sleep). I further have places, which list directories on the hard-drive, making it easy to quickly find what I need. I use a dock on the left and a dock up top that displays the workspaces.

Dash to Dock extension

One of the problems using a Linux system is that not to many uses Linux, especially not at work, and that a lot of the software used in Windows don’t run in Linux. Of course you can use Wine, but that is cumbersome and you miss the point by using open source/free alternatives. In my work this is most noticeable regarding the office packages. The alternative I use I LibreOffice. A lot of people say that the compatibility between Microsoft office package and LibreOffice is problematic. That is not my experience. I work with people using Microsoft Office all time. But for it to work you have to use .doc, not .docx. The only problem I have with LibreOffice is that the alternative to Powerpoint (Impress) is not good. It is almost not possible to use. Instead I use WPS. I actually have the whole WPS package just to use it for presentation. But sometimes I have also used WPS if the compatibility is bad using LibreOffice writer – which can happen if there is a lot going on in the document. For statistics I use R in Emacs (using ESS). Takes some time to get used to Emacs, but when you have it works really nice. I have Virtual Box installed and in VB I have Windows 10 installed. Some system applications that I quite seldom need to use just works in Windows.

Does Linux make me more productive? I don’t know, but the main advantage is that I can have a system of my own liking. So for me Linux works just fine. Should you use Linux as your main work computer? If you are perfectly fine with the system you use and if you are not interested in computers and technology you should probably not use Linux – not yet anyway. But if you want to try I would recommend installing Virtual Box and trying out some of the many distributions.