Search
 
SCRIPT & CODE EXAMPLE
 

PERL

mean data frame columns by group R

d <- read.table(text=
'Name     Month  Rate1     Rate2
Aira       1      12        23
Aira       2      18        73
Aira       3      19        45
Ben        1      53        19
Ben        2      22        87
Ben        3      19        45
Cat        1      22        87
Cat        2      67        43
Cat        3      45        32', header=TRUE)

aggregate(d[, 3:4], list(d$Name), mean)

  Group.1    Rate1    Rate2
1    Aira 16.33333 47.00000
2     Ben 31.33333 50.33333
3     Cat 44.66667 54.00000
Comment

PREVIOUS NEXT
Code Example
Perl :: perl mechanize check mirror response for errors 
Perl :: perl format decimal 2 places not rounding 
Perl :: perl exit loop example 
Perl :: how to initialize an array 
Pascal :: pascal readln() 
Pascal :: wait in pascal 
Pascal :: comment in pascal 
Powershell :: CMD & Powershell History 
Powershell :: Download attachment from Jira task to local filesystem 
Gdscript :: godot get root node 
Gdscript :: godot saving enum names in variable 
Abap :: comments in abap 
Erlang :: tcp server erlang 
Assembly :: install retroarch on Linux 
Assembly :: assembly language loop example masm 
Assembly :: import pyautogui Traceback (most recent call last): File "<stdin", line 1, in <module ImportError: No module named pyautogui 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: map range of numbers to another range 
Javascript :: jest cache clear 
Javascript :: javascript replace spaces with dashes 
Javascript :: import redux thunk 
Javascript :: jquery refresh page 
Javascript :: delete session javascript 
Javascript :: get week day name in javascript 
Javascript :: how to remove checked attribute of checkbox in jquery 
Javascript :: loop array backwards javascript 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: jquery remove and add class 
Javascript :: how to use another port in angular 
Javascript :: How to get current URL with Javascript or React 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =