R: HIndiv: this function calculates the Handedness Index of each...
HIndiv
R Documentation
HIndiv: this function calculates the Handedness Index of each individual for each activity and plots the corresponding histogram.
Description
Calculates the Handedness Index of each individual regarding to each task performed and plots the corresponding histogram for each individual. The results can be saved in a .csv file.
Usage
HIndiv(data, catch = "Food", hand = "Hand", indiv = "Indiv",
RightHand = "R", LeftHand = "L", col = 1:length(levels
(data[[catch]])), ylab = "Handedness index",
main = "Hand preference regarding to the performed task by each individual",
cex.main = 1, legend.text = FALSE,
beside = TRUE, ylim = c(-1, 1), vlines = TRUE, hlines = TRUE,
legendlocation = TRUE, cex = 1, pt.cex = 2, pch = 15,
savetable = FALSE, file = "HIperIndiv.csv")
Arguments
data
The object (data.frame) containing your data with at least the qualitative variables concerning the hand used (hand), the individuals (indiv) and the activity performed (catch).
catch
The name/header of the column concerning the activity carried out (by default "Food"), if you made individuals catching different objects (ob1, ob2, ob3, ob4) and named the variale "ObjectCatched", write catch = "ObjectCatched".
hand
The name/header of the column concerning the hand used (by default "Hand").
indiv
The name/header of the column concerning the individuals (by default "Indiv").
RightHand
The code used in the database (and particularly in the "hand" variable) for "RightHand". If "RightHand" is coded as "Right" write RightHand = "Right" (by default "R").
LeftHand
The code used in the database (and particularly in the "hand" variable) for "LeftHand". If "LeftHand" is coded as "Left" write LeftHand = "Left" (by default "L").
col
A list of color for the bars of the histogram. By default it will automatically find the number of colors you need but it's using the 8 colors of the default palette of R. If you need more don't forget to select another palette or to name the color you want to add.
ylab
A title for the y axis.
main
The main title of the graph.
cex.main
A numeric giving the size of the main title characters.
legend.text
If legend.text = TRUE, the legend will be automatically placed on the graph. If legend.text = FALSE, no legend will appear except if legendlocation = TRUE.
beside
If FALSE, the columns of height are portrayed as stacked bars, and if TRUE the columns are portrayed as juxtaposed bars.
ylim
The minimum and maximum value of the y axis. For example ylim = c(0,500). By default (ylim = NULL) the values are automatically selected.
vlines
If vlines = TRUE (by default), vertical lines are drawn between the histogram of each individual.
hlines
If hlines = TRUE (by defaut), horizontal lines are drawn at y = 0 for each histogram.
legendlocation
If TRUE you will have to click where you want to place the legend after the plot is done.
cex
A numeric giving the size of the legend characters.
pt.cex
A numeric giving the size of the legend points.
pch
This can either be a single character or an integer code for one of a set of graphics symbols. This will be applied to the legend. (By default pch = 15 which is square).
savetable
This arguments permits to save directly the results of the function in a .csv file in the workspace of R. If savetable = "csv" there will be "." for the decimal point and a "," for the separator. If savetable = "csv2" there will be "," for the decimal point and a ";" for the separator. (by default savetable = FALSE)
file
This argument will work if savetable = "csv" or "csv2". It gives the name of the csv file saved (by default file = "HIperIndiv.csv")
Value
The function returns results of class "matrix".
Author(s)
Borel A., Pouydebat E., Reghem E. <antony.borel@gmail.com>
Examples
## With arguments corresponding to the default ones:
data(laterdata)
str(laterdata)
Data<-laterdata
HIndiv(Data, catch="Food", hand="Hand", indiv = "Indiv",
RightHand = "R", LeftHand = "L", legendlocation=FALSE, legend.text=TRUE)
## or
HIndiv(Data, legendlocation=FALSE, legend.text=TRUE)
## With arguments different from the default ones:
data(lateradata)
str(lateradata)
Data<-lateradata
HIndiv(Data, catch="Act", hand="HandPref", indiv = "Individual",
RightHand = "Right", LeftHand = "Left", legendlocation=FALSE, legend.text=TRUE)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Laterality)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Laterality/HIndiv.Rd_%03d_medium.png", width=480, height=480)
> ### Name: HIndiv
> ### Title: HIndiv: this function calculates the Handedness Index of each
> ### individual for each activity and plots the corresponding histogram.
> ### Aliases: HIndiv
> ### Keywords: HI handedness index zscore laterality manual preference
>
> ### ** Examples
>
> ## With arguments corresponding to the default ones:
> data(laterdata)
> str(laterdata)
'data.frame': 674 obs. of 5 variables:
$ Indiv : Factor w/ 11 levels "Airly","Biwa",..: 11 9 6 8 3 11 9 6 11 10 ...
$ Sex : Factor w/ 2 levels "f","m": 2 2 1 1 1 2 2 1 2 1 ...
$ Food : Factor w/ 3 levels "Apple","Cricket",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Hand : Factor w/ 3 levels "Bi","L","R": 3 3 1 2 2 1 3 3 3 3 ...
$ PostureCorp: Factor w/ 7 levels "A","Bip","BipGrill",..: 6 7 2 7 6 1 6 6 6 6 ...
> Data<-laterdata
> HIndiv(Data, catch="Food", hand="Hand", indiv = "Indiv",
+ RightHand = "R", LeftHand = "L", legendlocation=FALSE, legend.text=TRUE)
Airly Biwa Doma Dudy Gogo Neil Olix
Apple -0.03030303 -0.4000000 0.2000000 0.1666667 -1 0.3513514 -0.50
Cricket -1.00000000 -0.3333333 -0.4545455 NaN NaN -1.0000000 -0.20
Worm -0.60000000 -0.8620690 -0.1063830 -1.0000000 -1 -0.5000000 -0.25
Rali Raps Rexen Titi
Apple 0.4358974 0.08108108 -0.09090909 0.2800000
Cricket NaN -0.25000000 -0.78947368 1.0000000
Worm 0.4285714 -0.45454545 -0.72916667 -0.2222222
> ## or
> HIndiv(Data, legendlocation=FALSE, legend.text=TRUE)
Airly Biwa Doma Dudy Gogo Neil Olix
Apple -0.03030303 -0.4000000 0.2000000 0.1666667 -1 0.3513514 -0.50
Cricket -1.00000000 -0.3333333 -0.4545455 NaN NaN -1.0000000 -0.20
Worm -0.60000000 -0.8620690 -0.1063830 -1.0000000 -1 -0.5000000 -0.25
Rali Raps Rexen Titi
Apple 0.4358974 0.08108108 -0.09090909 0.2800000
Cricket NaN -0.25000000 -0.78947368 1.0000000
Worm 0.4285714 -0.45454545 -0.72916667 -0.2222222
>
> ## With arguments different from the default ones:
> data(lateradata)
> str(lateradata)
'data.frame': 674 obs. of 5 variables:
$ Individual : Factor w/ 11 levels "Airly","Biwa",..: 11 9 6 8 3 11 9 6 11 10 ...
$ Sex : Factor w/ 2 levels "f","m": 2 2 1 1 1 2 2 1 2 1 ...
$ Act : Factor w/ 3 levels "Catching","Grasping",..: 2 2 2 2 2 2 2 2 2 2 ...
$ HandPref : Factor w/ 3 levels "Bimanual","Left",..: 3 3 1 2 2 1 3 3 3 3 ...
$ PostureCorp: Factor w/ 7 levels "A","Bip","BipGrill",..: 6 7 2 7 6 1 6 6 6 6 ...
> Data<-lateradata
> HIndiv(Data, catch="Act", hand="HandPref", indiv = "Individual",
+ RightHand = "Right", LeftHand = "Left", legendlocation=FALSE, legend.text=TRUE)
Airly Biwa Doma Dudy Gogo Neil Olix
Catching -0.60000000 -0.8620690 -0.1063830 -1.0000000 -1 -0.5000000 -0.25
Grasping -0.03030303 -0.4000000 0.2000000 0.1666667 -1 0.3513514 -0.50
Hunting -1.00000000 -0.3333333 -0.4545455 NaN NaN -1.0000000 -0.20
Rali Raps Rexen Titi
Catching 0.4285714 -0.45454545 -0.72916667 -0.2222222
Grasping 0.4358974 0.08108108 -0.09090909 0.2800000
Hunting NaN -0.25000000 -0.78947368 1.0000000
>
>
>
>
>
> dev.off()
null device
1
>