Quantcast
Channel: The which function in R is not giving the desired output - Stack Overflow
Browsing latest articles
Browse All 6 View Live

Answer by Arun for The which function in R is not giving the desired output

Here's how I'd approach using data.table. Hopefully @MartinMorgan finds this easier to understand :-).require(data.table) # v1.9.6+dt = as.data.table(df) # or use setDT(df) to convert by referenceeq =...

View Article



Answer by Martin Morgan for The which function in R is not giving the desired...

Here's a re-write of your original attempt (which() is not necessary; just use the logical vector for sub-setting; with() allows you to refer to variables in the data frame without having to re-type...

View Article

Answer by Bulat for The which function in R is not giving the desired output

You can can implement this with joins, here is an example using data.table:library(data.table)dt <- data.table(df)dt.lookup <- dt[First.Protein == Second.Protein]setkey(dt,"First.Protein"...

View Article

Answer by zx8754 for The which function in R is not giving the desired output

Loop through rows using apply:#computedf$ScoreNorm <- apply(df, 1, function(i){ i[3] / ( sqrt(df[ df$First.Protein == i[1] & df$Second.Protein == i[1], "Score"]) * sqrt(df[ df$First.Protein ==...

View Article

Answer by asb for The which function in R is not giving the desired output

You may be doing this in a very round-about manner. Can you see if this works for you:R> xx First Second Score1 1 1 252 1 2 903 1 3 824 1 4 195 2 1 906 2 2 997 2 3 768 2 4 799 3 1 8210 3 2 7611 3 3...

View Article


The which function in R is not giving the desired output

I have a matrix that contains 3 columns and in total 10,000 elements. First and second columns are indexes and third column is the score. I want to normalize the score column based on this...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images