[R] Converting character to numeric: Error: (list) object cannot be coerced to type 'double'

2012-12-07 Thread Vikram Bahure
Dear R users,

I am facing a pretty a unusual problem while converting character to
numeric. Any input would be appreciated.

Below is the code and error faced:
---
* str(cmie.dts)*
*'data.frame': 4397 obs. of  1 variable:*
* $ INE001A01036: chr  1482181740.00 1482181740.00
1482181740.00 1482181740.00 ...*
* f1 - as.numeric(f)*
*Error: (list) object cannot be coerced to type 'double'*
*-*
*
*
Thanks in advance.

Regards
Vikram

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Converting character to numeric: Error: (list) object cannot be coerced to type 'double'

2012-12-07 Thread Sarah Goslee
Hi,

You need to use as.numeric on the column, not the entire data frame.



On Fri, Dec 7, 2012 at 9:23 AM, Vikram Bahure
economics.vik...@gmail.com wrote:
 Dear R users,

 I am facing a pretty a unusual problem while converting character to
 numeric. Any input would be appreciated.

 Below is the code and error faced:
 ---
 * str(cmie.dts)*
 *'data.frame': 4397 obs. of  1 variable:*
 * $ INE001A01036: chr  1482181740.00 1482181740.00
 1482181740.00 1482181740.00 ...*
 * f1 - as.numeric(f)*
 *Error: (list) object cannot be coerced to type 'double'*

What's f? You showed us str(cmie.dts), but then tried to do something with f.

But assuming they're similar, see:

 fakedata - data.frame(col1 = c(100.01, 20.01, 30.05), 
 stringsAsFactors=FALSE)
 str(fakedata)
'data.frame':3 obs. of  1 variable:
 $ col1: chr  100.01 20.01 30.05
 as.numeric(fakedata)
Error: (list) object cannot be coerced to type 'double'
 as.numeric(fakedata$col1)
[1] 100.01  20.01  30.05



--
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org 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] Converting character to numeric: Error: (list) object cannot be coerced to type 'double'

2012-12-07 Thread Rui Barradas

Hello,

It's the column that you want to convert, not the data.frame.

f1 - as.numeric(f$INE001A01036)

Hope this helps,
Rui Barradas
Em 07-12-2012 14:23, Vikram Bahure escreveu:

Dear R users,

I am facing a pretty a unusual problem while converting character to
numeric. Any input would be appreciated.

Below is the code and error faced:
---
* str(cmie.dts)*
*'data.frame': 4397 obs. of  1 variable:*
* $ INE001A01036: chr  1482181740.00 1482181740.00
1482181740.00 1482181740.00 ...*
* f1 - as.numeric(f)*
*Error: (list) object cannot be coerced to type 'double'*
*-*
*
*
Thanks in advance.

Regards
Vikram

[[alternative HTML version deleted]]

__
R-help@r-project.org 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-help@r-project.org 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] Converting character to numeric: Error: (list) object cannot be coerced to type 'double'

2012-12-07 Thread Vikram Bahure
Thanks a lot. That was helpful.
My apologize, as both cmie.dts and 'f are same.


On Fri, Dec 7, 2012 at 8:46 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 It's the column that you want to convert, not the data.frame.

 f1 - as.numeric(f$INE001A01036)

 Hope this helps,
 Rui Barradas
 Em 07-12-2012 14:23, Vikram Bahure escreveu:

 Dear R users,

 I am facing a pretty a unusual problem while converting character to
 numeric. Any input would be appreciated.

 Below is the code and error faced:
 --**-
 * str(cmie.dts)*
 *'data.frame': 4397 obs. of  1 variable:*
 * $ INE001A01036: chr  1482181740.00 1482181740.00
 1482181740.00 1482181740.00 ...*
 * f1 - as.numeric(f)*
 *Error: (list) object cannot be coerced to type 'double'*
 *-***
 *

 *
 Thanks in advance.

 Regards
 Vikram

 [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

__
R-help@r-project.org 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.