How to calculate differences scores with R? -


so have 2 sets of data, each comparing specific category, so:

category : solution 1 : solution 2 1: 5 : 6 2: 7 : 6 3: 4 : 4 4: 8 : 9 

how calculate difference scores using r specifically? somehow need load data them calculate solution1 - solution2 believe.

we 'read' dataset using read.table/read.csv appropriate delimiter. based on example showed, :. after 'data.frame' object created ('df1'), can use transform or within create 'diff' column (i.e. difference of "solution" columns

 df1 <- read.table('file.txt', sep=':', strip.white=true, header=true)  transform(df1, diff= solution.1-solution.2)  #   category solution.1 solution.2 diff  #1        1          5          6   -1  #2        2          7          6    1  #3        3          4          4    0  #4        4          8          9   -1 

or

 df1$diff <- with(df1, solution.1-solution.2) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -