Pieter
Pieter

Reputation:

Error: unexpected numeric constant in:

I want to read the following dataset:

6398400    6273897   6038777     5810740     5673521     5688332     5669445     5682840        
5723561    5555929   5345696     5321179     5199592     5165409     5130744            
4717909    4925673   4999103     4960733     4840036     4824080     4821902            
7115151    7114401   7039423     6967723     6967513     6901684                
8203359    8286980   8222974     8323470     8067521                    
5930080    5862383   5994123     6017566                        
5558436    5754304   5613530                            
4595506    5074887                              
3443322

So I want it to be a matrix where the lower triangle has the values NA each time.

I got this example code:

Xij <- scan(n=45)

6398400    6273897   6038777     5810740     5673521     5688332     5669445     5682840     5679432    
5723561      5555929     5345696     5321179     5199592     5165409     5130744                
    4717909      4925673     4999103     4960733     4840036     4824080     4821902            
    7115151      7114401     7039423     6967723     6967513     6901684                
    8203359      8286980     8222974     8323470     8067521                    
    5930080      5862383     5994123     6017566                        
    5558436      5754304     5613530                            
    4595506      5074887                                
    3443322                                     

n <- length(Xij); nn <- trunc(sqrt(2*n))
bovendriehoek<-makemat(Xij,nn)

But each time I get the error: Unexpected numeric constant in: (the first two values of the line)

Can somebody help me with this?

Upvotes: 1

Views: 3380

Answers (1)

Jthorpe
Jthorpe

Reputation: 10167

you need to get rid of the blank line between the call to scan() and the text you want to scan, since a blank line will terminate the scan. With a blank line, between scan and the text, the text gets parsed as R code, and hence the error.

Upvotes: 3

Related Questions