Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20110525/4926c5ee/attachment.pl>
transpose ?
3 messages · Mohamed Lajnef, Jeff Newmiller, Dennis Murphy
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110525/2234d037/attachment.pl>
Hi:
Does this work?
dd <- read.table(textConnection("
C C C C T T G G A A C C G G C C
G G T T A A A A T A T T C C G G
C C C C T T G G A A C C G G C C
"), stringsAsFactors = FALSE)
# Convert the data frame to a character matrix
# To do this, you need to make sure that the variables in
# your data frame are character rather than factor
dm <- as.matrix(dd)
dm # elements should be quoted if character
# Create an empty list of nrow(dm) components
mm <- vector('list', nrow(dm))
# Create a two-row matrix from each row of dm
for(i in seq_len(nrow(dm))) mm[[i]] <- matrix(dm[i, ], nrow = 2)
mm
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "C" "C" "T" "G" "A" "C" "G" "C"
[2,] "C" "C" "T" "G" "A" "C" "G" "C"
[[2]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "G" "T" "A" "A" "T" "T" "C" "G"
[2,] "G" "T" "A" "A" "A" "T" "C" "G"
[[3]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "C" "C" "T" "G" "A" "C" "G" "C"
[2,] "C" "C" "T" "G" "A" "C" "G" "C"
HTH,
Dennis
On Wed, May 25, 2011 at 7:19 AM, Mohamed Lajnef
<Mohamed.lajnef at inserm.fr> wrote:
Dear All, Sorry for the previous mail,suppose this data.frame D V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 C ?C ?C ? C ? T ? T ? G ? G ? A ? A ? C ? C ? G ? G ? C ? C G ?G ?T ? T ? A ? A ? A ? A ? T ? A ? T ? T ? C ? C ? G ? G C ?C ?C ? C ? T ? T ? G ? G ? A ? A ? C ? C ? G ? G ? C ? C I would translate D as follow ( just for the first line) C C T G A C G C C C T G A C G C (V8 under V7) (V9 under V10) ... Any help would be appreciated Regards M ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.