X.nm. X.A. variable
<dbl> <dbl> <chr>
300 3.9472 100ng _1_36.712
350 0.2060 100ng _1_36.712
380 0.1118 100ng _1_36.712
400 0.0607 100ng _1_36.712
450 0.0210 100ng _1_36.712
500 0.0129 100ng _1_36.712
300 0.0099 100ng _2_36.712
750 0.0099 100ng _2_36.712
350 0.4060 100ng _2_36.712
300 0.4060 100ng _1_45.712
350 0.6118 100ng _1_45.712
400 0.9607 100ng _1_45.712
I have the dataframe above and I'd like to reshape it so that X.nm. is a column, the observations in variable becomes the column name and X.A. are the observations in that column. How do I do this? Then how can I make that solution a function because I'd like to do this to multiple dataframes and export them as excel files.
I tried doing dcast and spread but the issue is if X.nm. and X.A. become the variable where the other 3 (Reaction.Type_Trial_Actual.Total.Seconds) in the variable column are left as their own column, I get issues with duplicate identifiers. The original dataset has the columns: X.nm., X.A. , Reaction.Type, Trial, Actual.Total.Seconds. I've already tried this code and it doesn't work:
mc5<- orig.df %>% unite(variable,c(Reaction.Type, Trial, Actual.Total.Seconds))
mc6<- dcast(mc5, X.nm.~X.A.+variable, value.var = mc5$X.A.)
Sample of Desired:
X.nm. 100ng _1_36.712 100ng _2_36.712 100ng _1_45.712
300 3.9472 0.0099 0.4060
350 0.2060 0.4060 0.6118
etc.