Hi everyone,
I am writing a simple script to read in a data file, search through the data
file for an exact character match for a microRNA name, subset those rows,
and aggregrate a dataframe with those subselections all in a for loop. This
is what I have so far:
#READ IN DATA
file1 = "C:/Desktop/
Nevermind, I knew it was a simple fix, just needed to take a break from R:
for(i in 1:length(mirs))
{
holder = subset(data, data$mir==mirs[i])
table = rbind(table, holder)
}
--
View this message in context:
http://r.789695.n4.nabble.com/Filling-dataframe-incorrectly-in-for-loop-tp4648545p4648
Hi everyone,
I am somewhat new to R and I am trying to write a permutation function such
that it inputs a character vector and from an arbitrary length "n" which is
the length of the combinations for the character vector. I know there are R
packages for permutation but this is for an assignment.
Thanks for the input everyone!
So far this is the updated code that I have:
alphabet = c("a","b","c","d")
holder = c()
permute = function(alphabet,n){
for (i in 1:1000){
perm = sample(alphabet, replace=F, size=n)
holder = rbind(holder, perm, deparse.level=0)
}
data2 = unique(holder)
data3
Thanks for all the suggestions. This is my final code that seems to be
working:
alphabet = c("a","b","c","d")
holder = c()
permute = function(alphabet,n){
while((length(unique(holder))/n)<(length(alphabet)^n)){
perm = sample(alphabet, replace=T, size=n)
holder = rbind(holder, perm, deparse
5 matches
Mail list logo