R coding has some loop problem
2
0
Entering edit mode
3.7 years ago
roysense • 0
    > 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 • 1.2k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

I got it!!!

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
3.7 years ago

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.

ADD COMMENT
1
Entering edit mode
3.7 years ago
KH ▴ 80

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) {

ADD COMMENT
0
Entering edit mode

Thank you so much. Have a great day

ADD REPLY

Login before adding your answer.

Traffic: 1845 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6