tirsdag den 21. februar 2017

Windturbines and Shiny app

My good colleage Cathrine Ulla Jensen have just made a shiny app  that ranks the windturbines sites based on their net present value (NPV) in a part of Denmark. The app is the first attempt in my research group to communicate our research results using shiny. 

Chek out the app here: https://cathrineujensen.shinyapps.io/wheretoplaceturbine/  

You can find our report here - it is in danish. We will soon be able to present a working paper in english on the subject: report 
Cheers Toke

tirsdag den 25. oktober 2016

creating dummy variables

I some times have to create a bunch of dummy variables from a character variable. It is tedious bussiness to create dummy variables one at the time. Some time ago I came accross this blog post dummies-for-dummies  by Alan Fernihough.  The little function he have create have saved me a lot of time.

### start script ###

# Dummy variable function
datdum <- function(x, data, name){
  data$rv <- rnorm(dim(data)[1],1,1)
  mm <- data.frame(model.matrix(lm(data$rv~-1+factor(data[,x]))))
  names(mm) <- paste(name)
  data$rv <- NULL
  data <- cbind(data,mm)
  return(data)
}

# Creating a simple example dataframe "dat" with one column "dat1" consisting of the values "A","B","C".
dat1 <- c("A","B","C")
dat <- data.frame(dat1)

# Using the dummy variable function:
datdum(x="dat1",data=dat, name=dat1)

### end script ###

Maybe it will save you time too. 

Cheers Toke 

tirsdag den 27. september 2016

Hallo World

This blog is dedicated to my exploration of the R environment. I have been using R for the better part of eight years and have recently build a packages - PanJen - and started a small summer course on data management – course link

At the moment I am working as a postdoc at Copenhagen University at department for food and resource economics. My main research area has been to develop urban planning models based property value models. Needless to say, I have spent a lot of time working on spatial data as a defining property of a property is its location. You can find reference to my publications here:google scholar profile

I hope with this blog to structure my thoughts and share my R innovation with readers.

Here is some links to stuff people have been sharing with me and the web  which I find to be interesting.

Get inspired 

Get Help &Learn R


Cool data management 

From Excel,sas, stata to R 

On data science 

GIS related links 

R plots

Online course and other lists

Cool data analysis

R books