Skip to content

Instantly share code, notes, and snippets.

erzk / rename_and_join_raw_files.bat
Last active Aug 29, 2015
Prepare raw .res files
View rename_and_join_raw_files.bat
rename *.res *.csv
copy *.csv all_results_native_chinese.csv
erzk / addPercentagesLMTool
Created Jan 12, 2015
adds percentages to new columns of the raw data file exported from LM Tool
View addPercentagesLMTool
Sub addPercentagesLMTool()
ActiveCell.FormulaR1C1 = "percPreApproved"
ActiveCell.FormulaR1C1 = "percApproved"
ActiveCell.FormulaR1C1 = "percPreRejected"
ActiveCell.FormulaR1C1 = "percRejected"
erzk / DATEPARSE_from_DataSift
Created Jan 14, 2015
Tableau - Calculated field - Date parse data from DataSift
View DATEPARSE_from_DataSift
DATEPARSE("EEE, dd MMM yyy HH:mm:ss" ,[Interaction.Created At])
erzk / copy_all.bat
Last active Aug 29, 2015
copy all files of a certain type from subfolders to another folder
View copy_all.bat
for /R H:\... %%f in (*.csv) do copy %%f H:\...
erzk / append_at_the_beginning.bat
Created Jan 25, 2015
Adds 'text' at the beginning of file names
View append_at_the_beginning.bat
REM adds 'abc' at the beginning of each txt file
FOR %v IN (*.txt) DO REN %v abc%v
erzk / copy_all_no_subfolder_structure.bat
Last active Aug 29, 2015
Copy all files of a certain type from the source path (including subfolders) to the destination path (no subfolder structure)
View copy_all_no_subfolder_structure.bat
REM copy all pdfs from the source path (including subfolders) to the destination path (no subfolder structure)
xcopy <source path>\*.pdf <destination path> /s
View heatmap_spectral.R
# make the heatmap
# based on
myPalette <- colorRampPalette(rev(brewer.pal(11, "Spectral")), space="Lab")
zp1 <- ggplot(foreign_victims_long,
aes(x = Year, y = Country, fill = Victims))
zp1 <- zp1 + geom_tile()
zp1 <- zp1 + scale_fill_gradientn(colours = myPalette(100))
erzk / wide_to_long.R
Created May 11, 2015
change format from wide to long
View wide_to_long.R
foreign_victims_wide <- read.csv("foreign_victims_wide.csv")
# reshape to long format
foreign_victims_long <- gather(foreign_victims_wide, Year, Victims, X1998:X2012)
# remove Xs
# could be omitted if using check.names=FALSE in read.csv()
foreign_victims_long$Year <- gsub("X", "", paste(foreign_victims_long$Year))
write.csv(foreign_victims_long, file = "foreign_victims_long.csv", row.names=FALSE)
erzk / annotate_split.bat
Last active Aug 29, 2015
Annotates and splits a continuous wav file using Speech Filing System
View annotate_split.bat
REM define the working directory
set location=%cd%
REM define the participant
set participant=NAME
REM define the trial
set trial=01
REM define the condition
set condition=FAF-Up
REM define the file name, e.g. 01-NAME-FAF-Up.wav
set filename=%trial%-%participant%-%condition%
erzk / get_mean_pitch.R
Created May 31, 2015
extracts duration and mean pitch
View get_mean_pitch.R
# Get mean pitch and duration
# Frequency altered feedback study
# PraatR documentation:
# loop through all the files in a directory
# define the partcipant/folder/output file name
participant <- "NAME"