Thank you very much Jim and David for your scripts and accompanying
explanations.
I was intrigued at the results that came from David's script. As seen
below where I have taken a small piece of his DataTable:
AT1G69490 AT1G29860 AT4G18170 *AT5G46350*
AT1G01560 0 0 0 1
*AT1G02920
Hi again,
Just noticed that the NA fill in the original solution is unnecessary, thus:
# split the second column at the commas
hitsplit<-strsplit(mmdf$hits,",")
# get all the sorted hits
allhits<-sort(unique(unlist(hitsplit)))
tmmdf<-as.data.frame(matrix(NA,ncol=length(hitsplit),nrow=length(allhit
Hi Matthew,
I'm not sure whether you want something like your initial request or
David's solution. The result of this can be transformed into the
latter:
mmdf<-read.table(text="Regulator hits
AT1G69490
AT4G31950,AT5G24110,AT1G26380,AT1G05675,AT3G12910,AT5G64905,AT1G22810,AT1G79680,AT3G02840,AT5G2
We still have only the toy version of your data from your first email. The
second email used dput() as I suggested, but you truncated the results so it is
useless for testing purposes.
Use the following code after creating DataList (up to mx <- ... ) in my earlier
answer:
n <- sapply(DataList,
Thank you very much, David and Jim for your work and solutions.
I have been working through both of them to better learn R. They both
proceed through a similar logic except David's starts with a character
matrix and Jim's with a dataframe, and both end with equivalent
dataframes ( identical(tm
If you read the data frame with read.csv() or one of the other read()
functions, use the asis=TRUE argument to prevent conversion to factors. If not
do the conversion first:
# Convert factors to characters
DataMatrix <- sapply(TF2list, as.character)
# Split the vector of hits
DataList <- sapply(
6 matches
Mail list logo