이 사용하여 작업을 수행 할 수 있습니다
이 데이터 구축 : 목록에서
AllCy3MeansDNA1bind1uM <- data.frame(Molarity=c("10" ,"100", "25", "5" ,"50", "10" ,"100",
"25", "5", "50", "10", "100", "25", "5",
"50", "10", "100", "25", "5", "50", "Control", "Control", "Control",
"Control"), fake_col = rep(1,24) , stringsAsFactors=F)
AllCy3MeansDNA2bind1uM <- data.frame(Molarity=c("10" ,"100", "25", "5" ,"50", "10" ,"100",
"25", "5", "50", "10", "100", "25", "5",
"50", "10", "100", "25", "5", "50", "Control", "Control", "Control",
"Control"), fake_col = rep(1,24), stringsAsFactors=F)
AllCy3MeansDNA1bind10nM <- data.frame(Molarity=c("10" ,"100", "25", "5" ,"50", "10" ,"100",
"25", "5", "50", "10", "100", "25", "5",
"50", "10", "100", "25", "5", "50", "Control", "Control", "Control",
"Control"), fake_col = rep(1,24), stringsAsFactors=F)
스토어를 (필자는 list
기능을 사용할 수 있습니다하지 c
)
Cy3list<-list(AllCy3MeansDNA1bind1uM=AllCy3MeansDNA1bind1uM,AllCy3MeansDNA2bind1uM=AllCy3MeansDNA2bind1uM,
AllCy3MeansDNA1bind10nM=AllCy3MeansDNA1bind10nM)
다음 시도해주세요 function
:
library(gtools) #you need to load this library for mixedsort
new_df<-lapply(Cy3list,function(x) {
x["Molarity"]<-mixedsort(x[["Molarity"]]) #notice the double brackets
return(x)
})
양극성 칼럼에 숫자 데이터가 있어야하는지 모르겠습니다. 문자 데이터가있을 때 이해가되지 않습니다. 당신이 정말로 다음이 사용해야하는 경우 : 루프에
x["Molarity"]<- as.numeric(mixedsort(x[["Molarity"]]))
을하지만, 모든 문자 데이터는 NA로 변환됩니다 것을 알 수 있으며 해당 너무 경고를 얻을 것이다.
의 유효성을 검사하는 코드가 작동합니다
> new_df$AllCy3MeansDNA1bind1uM[['Molarity']]
[1] "5" "5" "5" "5" "10" "10" "10" "10" "25" "25" "25"
[12] "25" "50" "50" "50" "50" "100" "100" "100" "100" "Control" "Control"
[23] "Control" "Control"
열이 정렬됩니다!
희망이 있습니다.
감사합니다. 몇 가지 질문이 있습니다. 왜 목록을 만들 때 ','대신 '='를 사용합니까? – MRF
문제 없습니다. 내가 도왔 기 때문에 기쁘다. 목록에 이름을 전달하려면 '='가 있어야합니다. – LyzandeR