Re: [R] Question about error of non-numeric argument to binary operator

2006-10-11 Thread Yulei Gong
Thanks, Marc,
I tried it and it didn't really work.
 x.num-as.numeric(x)
 is.numeric(x.num)
[1] TRUE
 x.num-readClipboard()
 is.numeric(x.num)
[1] FALSE
 is.character(x.num)
[1] TRUE

I use readClipboard to take in data, and it seems after the data is taken
in, x.num changed to character.

I just start using R, not familiar with the data import/export
functions...besides of that, I have a question about read.table, can this
function read in spreadsheet data? if so, is the excel file supposed to put
in the same directory with the R-2.4.0 folder?? Which is what I did, but I
got the following error
 read.table(bra5y.xls,header = TRUE, row.names = 2)
Error in read.table(bra5y.xls, header = TRUE, row.names = 2) :
object bra5y.xls not found

Pls help.

Thanks!


On 10/10/06, Marc Schwartz [EMAIL PROTECTED] wrote:

 On Tue, 2006-10-10 at 22:35 -0400, Yulei Gong wrote:
  Hi,
  I have the following data and there is no binary operator contained,
  however, I still receive the error message when running unitrootTest
  function, could someone give me a guidance on it??
 
  readClipboard()
[1] 245246261.5  275.5  307284.5  289
 313.5
  323.75 334 312.5  325305.5  322.5  317310.5
   [17] 302301305287277.5  271 271.5  
 278.5
  279271263262262271262257
   [33] 251.5  258 252.5  254.5  253251.5  255
  253253243238.5  234229.5  230.5   237.5
   
  235.5
   [49] 238225227.5  233236.5  236.5  231.5
  225221.5  221.5   221.5  221.5  221.5  221.25 221
  206
   [65] 207.5  196192.5  193.5  186 197.5  193.5
  201195183185.5  181.5
   179177173
  169.5
   [81] 173178169173167 158.5  169.5
  164145127.5  132131131120120.5
   
  120.25
   [97] 120 112.5  114.5  106113111113
 118.5
  131131146.5  133.5  128132 130.5  122
  [113] 122.5  123.5  126140132140143
  148168162.5   152.5  148144144150.5
  151
  [129] 156156156152156 153.5  137
  135140135138.5  139130131125
  125
  [145] 121.5   125.5  128128129.5  133129.5
  140154.5  167.5  156179 178.5  174188
  214
  [161] 197.5  181.5  181.5  197.5  191.5  179189.5
  184.5  183182
  182.5  177191198191180.5
  [177] 182183.5  183182 189.5  195208
  203194176.5  173173174165.5
   163
  162.5
  [193] 159162.5  171168.5  164158147
  149149.5  144141 138.5  138136138
  140
  [209] 135132.5  130.75 129129.5  126127
 128.5
  127.5  124117119120.5  122129133
  [225] 136137133133127123122
  117122126126133 127.5  129130
  125
  [241] 122126.5  136148147150.5  143.5
  138.5  134135
  135.75 136.5  132129127.5  118.5
   x-readClipboard()
   unitrootTest(x)
  Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] :
  non-numeric argument to binary operator
 
  I also try to do simple code with it, and getting error message as
  well, such as
  for(j in 1:length(x)){w-x/1}
  Error in x/1 : non-numeric argument to binary operator
 
  Thanks for your help!
 
  Yulei

 Your 'x' is a character vector, not numeric. The tip is that the values
 are surrounded by double quotes.  Thus, you are trying to use operators
 intended for numerics on characters.

 For example:

  x - c(122, 126.5, 136, 148, 147, 150.5, 143.5)

  x
 [1] 122   126.5 136   148   147   150.5 143.5

  x / 1
 Error in x/1 : non-numeric argument to binary operator

  is.numeric(x)
 [1] FALSE

  is.character(x)
 [1] TRUE


 It's not clear from your post how you read in the data originally.  You
 should review that process or alternatively, coerce 'x' to numeric:

  x.num - as.numeric(x)

  x.num
 [1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5

  x.num / 1
 [1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5


 HTH,

 Marc Schwartz




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question about error of non-numeric argument to binary operator

2006-10-11 Thread Marc Schwartz
Yulei,

It would appear that the default mechanism for the function (which
appears to be Windows specific) is to read in the data from the current
system clipboard as a _character vector_. Thus, perhaps something like:

  x.num - as.numeric(readClipboard())

would be helpful. 

With respect to reading in Excel files, you cannot directly import Excel
files using read.table() and friends. You can export from Excel to an
ASCII delimited file and then use these functions.

Alternatively, there is the read.xls() function in the 'gdata' CRAN
package, which can directly read such files.

I would strongly advise reviewing the R Import/Export Manual, which is
available from the menus in the Windows GUI, as it will provide guidance
in this area.

HTH,

Marc

On Wed, 2006-10-11 at 14:25 -0400, Yulei Gong wrote:
 Thanks, Marc, 
 I tried it and it didn't really work. 
  x.num-as.numeric(x)
  is.numeric(x.num)
 [1] TRUE
  x.num-readClipboard()
  is.numeric(x.num)
 [1] FALSE
  is.character(x.num)
 [1] TRUE
 
 I use readClipboard to take in data, and it seems after the data is
 taken in, x.num changed to character. 
  
 I just start using R, not familiar with the data import/export
 functions...besides of that, I have a question about read.table, can
 this function read in spreadsheet data? if so, is the excel file
 supposed to put in the same directory with the R-2.4.0 folder?? Which
 is what I did, but I got the following error
  read.table(bra5y.xls,header = TRUE, row.names = 2)
 Error in read.table(bra5y.xls, header = TRUE, row.names = 2) : 
 object bra5y.xls not found
  
 Pls help. 
  
 Thanks!

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question about error of non-numeric argument to binary operator

2006-10-11 Thread Yulei Gong
  Marc, Thanks! x.num - as.numeric(readClipboard()) works perfect.
  Meanwhile, I have tried to use odbcConnectExcel from RODBC pack. It seems
to work as well. I am able to read in the data, but I need to construct a
sql table from the data, and use sqlFetch to retrieve and assign them to
variable. More steps.

On 10/11/06, Marc Schwartz [EMAIL PROTECTED] wrote:

 Yulei,

 It would appear that the default mechanism for the function (which
 appears to be Windows specific) is to read in the data from the current
 system clipboard as a _character vector_. Thus, perhaps something like:

 x.num - as.numeric(readClipboard())

 would be helpful.

 With respect to reading in Excel files, you cannot directly import Excel
 files using read.table() and friends. You can export from Excel to an
 ASCII delimited file and then use these functions.

 Alternatively, there is the read.xls() function in the 'gdata' CRAN
 package, which can directly read such files.

 I would strongly advise reviewing the R Import/Export Manual, which is
 available from the menus in the Windows GUI, as it will provide guidance
 in this area.

 HTH,

 Marc

 On Wed, 2006-10-11 at 14:25 -0400, Yulei Gong wrote:
  Thanks, Marc,
  I tried it and it didn't really work.
   x.num-as.numeric(x)
   is.numeric(x.num)
  [1] TRUE
   x.num-readClipboard()
   is.numeric(x.num)
  [1] FALSE
   is.character(x.num)
  [1] TRUE
 
  I use readClipboard to take in data, and it seems after the data is
  taken in, x.num changed to character.
 
  I just start using R, not familiar with the data import/export
  functions...besides of that, I have a question about read.table, can
  this function read in spreadsheet data? if so, is the excel file
  supposed to put in the same directory with the R-2.4.0 folder?? Which
  is what I did, but I got the following error
   read.table(bra5y.xls,header = TRUE, row.names = 2)
  Error in read.table(bra5y.xls, header = TRUE, row.names = 2) :
  object bra5y.xls not found
 
  Pls help.
 
  Thanks!




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about error of non-numeric argument to binary operator

2006-10-10 Thread Yulei Gong
Hi,
I have the following data and there is no binary operator contained,
however, I still receive the error message when running unitrootTest
function, could someone give me a guidance on it??

readClipboard()
  [1] 245246261.5  275.5  307284.5  289313.5
323.75 334 312.5  325305.5  322.5  317310.5
 [17] 302301305287277.5  271 271.5  278.5
279271263262262271262257
 [33] 251.5  258 252.5  254.5  253251.5  255
253253243238.5  234229.5  230.5   237.5  
235.5
 [49] 238225227.5  233236.5  236.5  231.5
225221.5  221.5   221.5  221.5  221.5  221.25 221
206
 [65] 207.5  196192.5  193.5  186 197.5  193.5
201195183185.5  181.5  179177173
169.5
 [81] 173178169173167 158.5  169.5
164145127.5  132131131120120.5  
120.25
 [97] 120 112.5  114.5  106113111113118.5
131131146.5  133.5  128132 130.5  122
[113] 122.5  123.5  126140132140143
148168162.5   152.5  148144144150.5
151
[129] 156156156152156 153.5  137
135140135138.5  139130131125
125
[145] 121.5   125.5  128128129.5  133129.5
140154.5  167.5  156179 178.5  174188
214
[161] 197.5  181.5  181.5  197.5  191.5  179189.5
184.5  183182
182.5  177191198191180.5
[177] 182183.5  183182 189.5  195208
203194176.5  173173174165.5  163
162.5
[193] 159162.5  171168.5  164158147
149149.5  144141 138.5  138136138
140
[209] 135132.5  130.75 129129.5  126127 128.5
127.5  124117119120.5  122129133
[225] 136137133133127123122
117122126126133 127.5  129130
125
[241] 122126.5  136148147150.5  143.5
138.5  134135
135.75 136.5  132129127.5  118.5
 x-readClipboard()
 unitrootTest(x)
Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] :
non-numeric argument to binary operator

I also try to do simple code with it, and getting error message as
well, such as
for(j in 1:length(x)){w-x/1}
Error in x/1 : non-numeric argument to binary operator

Thanks for your help!

Yulei

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question about error of non-numeric argument to binary operator

2006-10-10 Thread Marc Schwartz
On Tue, 2006-10-10 at 22:35 -0400, Yulei Gong wrote:
 Hi,
 I have the following data and there is no binary operator contained,
 however, I still receive the error message when running unitrootTest
 function, could someone give me a guidance on it??
 
 readClipboard()
   [1] 245246261.5  275.5  307284.5  289313.5
 323.75 334 312.5  325305.5  322.5  317310.5
  [17] 302301305287277.5  271 271.5  278.5
 279271263262262271262257
  [33] 251.5  258 252.5  254.5  253251.5  255
 253253243238.5  234229.5  230.5   237.5  
 235.5
  [49] 238225227.5  233236.5  236.5  231.5
 225221.5  221.5   221.5  221.5  221.5  221.25 221
 206
  [65] 207.5  196192.5  193.5  186 197.5  193.5
 201195183185.5  181.5  179177173
 169.5
  [81] 173178169173167 158.5  169.5
 164145127.5  132131131120120.5  
 120.25
  [97] 120 112.5  114.5  106113111113118.5
 131131146.5  133.5  128132 130.5  122
 [113] 122.5  123.5  126140132140143
 148168162.5   152.5  148144144150.5
 151
 [129] 156156156152156 153.5  137
 135140135138.5  139130131125
 125
 [145] 121.5   125.5  128128129.5  133129.5
 140154.5  167.5  156179 178.5  174188
 214
 [161] 197.5  181.5  181.5  197.5  191.5  179189.5
 184.5  183182
 182.5  177191198191180.5
 [177] 182183.5  183182 189.5  195208
 203194176.5  173173174165.5  163
 162.5
 [193] 159162.5  171168.5  164158147
 149149.5  144141 138.5  138136138
 140
 [209] 135132.5  130.75 129129.5  126127 128.5
 127.5  124117119120.5  122129133
 [225] 136137133133127123122
 117122126126133 127.5  129130
 125
 [241] 122126.5  136148147150.5  143.5
 138.5  134135
 135.75 136.5  132129127.5  118.5
  x-readClipboard()
  unitrootTest(x)
 Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] :
 non-numeric argument to binary operator
 
 I also try to do simple code with it, and getting error message as
 well, such as
 for(j in 1:length(x)){w-x/1}
 Error in x/1 : non-numeric argument to binary operator
 
 Thanks for your help!
 
 Yulei

Your 'x' is a character vector, not numeric. The tip is that the values
are surrounded by double quotes.  Thus, you are trying to use operators
intended for numerics on characters.

For example:

 x - c(122, 126.5, 136, 148, 147, 150.5, 143.5)

 x
[1] 122   126.5 136   148   147   150.5 143.5

 x / 1
Error in x/1 : non-numeric argument to binary operator

 is.numeric(x)
[1] FALSE

 is.character(x)
[1] TRUE


It's not clear from your post how you read in the data originally.  You
should review that process or alternatively, coerce 'x' to numeric:

 x.num - as.numeric(x)

 x.num
[1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5

 x.num / 1
[1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5


HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.