I have a dataframe in this format
employee <- c('JohnDoe','PeterGynn','laughter','laughter','happiness')
filename <- c('myfile_1','myfile_1','myfile_1','myfile_2','myfile_2')
input <- data.frame(employee, filename)
employee filename
JohnDoe myfile_1
PeterGynn myfile_1
laughter myfile_1
laughter myfile_2
happiness myfile_2
I would like to create a new dataframe in which every column will be the string of the employee column of input dataframe and have the binary if exist or not for the specific id.
Here is an example of output:
filename <- c('myfile_1','myfile_2')
JonhDoe <- c(1,0)
PeterGynn <- c(1,0)
laughter <- c(1,1)
happiness <- c(0,1)
output <- data.frame(filename, JonhDoe, PeterGynn, laughter, happiness)
filename JonhDoe PeterGynn laughter happiness
myfile_1 1 1 1 0
myfile_2 0 0 1 1
How can I make it?