Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sequence position finder2
#R version 3.4.4 ################ # Short version # seq <- "--ABC-----DA--" # allchars <- strsplit(seq, "")[[1]] # names(allchars) <- c(1:length(allchars)) # letters <- allchars[allchars!="-"] ###################################################### # Long version with comments and console visualization seq <- "--ABC-----DA--" print("Original sequence") print(seq) # split sequence to a vector char by char allchars <- strsplit(seq, "")[[1]] # create numeric names for each char (to have their position) names(allchars) <- c(1:length(allchars)) # print named vector just to see it, but it's not needed for our final purpose print("Full sequence (indexed)") for(key in names(allchars)){ value <- allchars[key] print(paste(key,'=',value)) } # create another vector without dash characters # this will also remove the non-interesting numeric names while # keeping their original position letters <- allchars[allchars!="-"] # letters is a named vector with the values that we want print("Letters positions in original sequence") for(key in names(letters)){ value <- letters[key] print(paste('The letter',value,'is in position',as.integer(key))) }
run
|
edit
|
history
|
help
0
Ex11-03-21EdsonAmanda
Integracao-Interpolacaa
Tidyverse: Estructuras
Mobile-Sprite-image-Interval
Efeito-Runge-18-03-2021
HOME WORK DATAFRAMES
Linear Regression and log-log Transformation
Chi-squared tests of independence [Seat Belt Yes/No] worked
TEST
Pendulum Experiment