我的R中的data.frame看起来像这样
> mydata=data.frame(id=c(rep("gene1",3),rep("gene2",4),rep("gene3",1),rep("gene4",2)),description=c(rep("protein1",3),rep("protein2",4),rep("protein3",1),rep("protein4",2)),type=c(rep("coding",10)),name=c("nucleus","binding","ribosome","transcription factor","regulation of transcription","DNA","sequence-specific binding","hydrolase","transporter","ion transport"),definition=paste(rep("blabla",10),1:10))
> mydata
id description type name definition
1 gene1 protein1 coding nucleus blabla 1
2 gene1 protein1 coding binding blabla 2
3 gene1 protein1 coding ribosome blabla 3
4 gene2 protein2 coding transcription factor blabla 4
5 gene2 protein2 coding regulation of transcription blabla 5
6 gene2 protein2 coding DNA blabla 6
7 gene2 protein2 coding sequence-specific binding blabla 7
8 gene3 protein3 coding hydrolase blabla 8
9 gene4 protein4 coding transporter blabla 9
10 gene4 protein4 coding ion transport blabla 10
我需要像这样转换它
> mydata2=data.frame(id=c("gene1","gene2","gene3","gene4"),description=c("protein1","protein2","protein3","protein4"),type=c(rep("coding",4)),name=c("nucleus,binding,ribosome","transcription factor,regulation of transcription,DNA","sequence-specific binding","hydrolase,transporter,ion transport"),definition=paste(rep("blabla",4),c(3,7,8,10)))
> mydata2
id description type name definition
1 gene1 protein1 coding nucleus,binding,ribosome blabla 3
2 gene2 protein2 coding transcription factor,regulation of transcription,DNA blabla 7
3 gene3 protein3 coding sequence-specific binding blabla 8
4 gene4 protein4 coding hydrolase,transporter,ion transport blabla 10
我尝试了几个功能
dcast
reshape2
spread
但我没有得到我需要的东西。例如,对于reshape2,它为$ name中的每个不同条目创建一个新列。
有人可以帮忙吗?非常感谢
PS:第一篇文章,我希望编辑没问题,原谅我否则
答案 0 :(得分:1)
这对你有用吗?它按ID,描述和类型拆分数据。对于每个子集,它将名称粘贴在一起并选择最后一个定义。
var options = new ConfigurationOptions
{
EndPoints = { "your_endpoint:port" },
Proxy = Proxy.Twemproxy
};
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(options);