Entering edit mode
5.5 years ago
ishackm
▴
110
Hi everyone,
I have this list of data frames:
$ABI3BP
Gene.Name TGEClass peptide ID
150588 ABI3BP TGEClass=5prime_extended IYLSDSLTGK 150588
150589 ABI3BP TGEClass=5prime_extended VSEPVSAGR 150589
150590 ABI3BP TGEClass=5prime_extended IQSTYDQDHTVPAYVPR 150590
150591 ABI3BP TGEClass=5prime_extended DNVEGGIWSK 150591
I have a data frame like this for 91 different genes.
I want to apply this function on every data frame and export each one as a csv
What I have done so far:
tge1<-split (data, data$Gene.Name) # split each gene name into seperate df
library(reshape2)
for(i in tge1)
{
dcast(tge1[[i]],ID ~ TGEClass , value.var="peptide")
print(i)
}
Error:
Error in tge1[[i]] : invalid subscript type 'list'
How can fix this please?, I have tried to solve this problem by searching but I haven't got the solution yet so any help will be greatly appreciated.
Thanks
Try changing from
for(i in tge1)
tofor (i in names(tge1))
.Thanks for replying, that removed the error but how to apply the function for each element in tge1 list and export each one as csv please?
The output when I changed to names(tge1)