This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R coding has some loop problem
    > library(cmapR)
> g_file<-system.file("extdata/Elucidata_assignment","PAAD.gct",package="cmapR")
> g<-parse_gctx(g_file)
parsing as GCT v1.3
C:/Users/Praveen Roy D S/Documents/R/win-library/4.0/cmapR/extdata/Elucidata_assignment/PAAD.gct 18465 rows, 183 cols, 0 row descriptors, 124 col descriptors
> rids<-ids(g)
> cids<-ids(g,"column")
> m<-mat(g)
> 
> genes_del<-c()
> rows_del<-c()
> j <- 1
> while (j <= 183){
+    if( sum(is.nan(m[j,]))) > 0) {
Error: unexpected '>' in:
"while (j <= 183){
   if( sum(is.nan(m[j,]))) >"
>     genes_del<-append(genes_del,rids[j])
> rows_del<-append(rows_del,j)
>          }
Error: unexpected '}' in "         }"
> }
Error: unexpected '}' in "}"
> print(genes_del)
[1] "SLC35E2"
> print(rows_del)
rna-seq r cmapr

Hi, can you put your code in a code block by highlighting it and then pressing the button that has 0s and 1s on it? based on the error you are probably missing a parenthesis or bracket somewhere, but I can't tell with the current formatting.

Hi, Thank you so much for trying to solve my issue. I have been struggling with this since morning. Please help

Please include the error messages in original post. Looks like you took those out while formatting the post.

Now I ran this code in R studio. This is what I see. I just dont know what to do. Please help

I got it!!!

There is an extra ')' in the if statement. Thank you for helpin guys.

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

2 answers

First of all, you should try if you can to use sapply or lapply, it's just more R-ry than a for loop.

That said, I don't think you've got the syntax right. Maybe make the row names a separate vector, and then for (j in myvector) {

Since you aren't putting anything in those gene del and row del lists, they are going to stay empty.

On this line:

if( sum(is.nan(m[j,]))) > 0) {

you have one too many closing parentheses ) which is why it is throwing the unexpected ">" error.

I believe it should be if( sum(is.nan(m[j,])) > 0) {

Thank you so much. Have a great day

Log in to answer this question.