Re: [R] function: as.integer

2012-01-31 Thread Rainer Schuermann
 as.numeric(A)
[1] 4.4 1.9 4.1

Integers are just integers...


On Tuesday 31 January 2012 12:21:48 Marion Wenty wrote:
 dear r-helpers,
 
 i created an object named A, which looks like this:
 
 A - c(4.4,1.9,4.1)
 
 now i needed to get numbers instead of characters and for this i used the
 function:
 
 as.integer(A)
 
 
 which resulted in:
 
 
 [1] 4 1 4
 
 
 My question is, why the numbers are rounded or more impotantly if
 there is a way to keep the decimal numbers?
 
 
 Thank you very much for your help in advance!
 
 
 Marion
 
   [[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] function: as.integer

2012-01-31 Thread R. Michael Weylandt michael.weyla...@gmail.com
They are rounded to integers because you used as.integer(). Perhaps you meant 
to use as.double()

Michael

On Jan 31, 2012, at 6:21 AM, Marion Wenty marion.we...@gmail.com wrote:

 dear r-helpers,
 
 i created an object named A, which looks like this:
 
 A - c(4.4,1.9,4.1)
 
 now i needed to get numbers instead of characters and for this i used the
 function:
 
 as.integer(A)
 
 
 which resulted in:
 
 
 [1] 4 1 4
 
 
 My question is, why the numbers are rounded or more impotantly if
 there is a way to keep the decimal numbers?
 
 
 Thank you very much for your help in advance!
 
 
 Marion
 
[[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] function: as.integer

2012-01-31 Thread Marion Wenty
Thank you very much for your help!

I was under the impression that numeric vectors and integer vectors are the
same!

Reading about integers just now I did not understand, what integer vectors
are. However, for my problem, I didn't need them, and used as.numeric
respectively as.double().

Thanks again

Regards,
Marion

2012/1/31 Marion Wenty marion.we...@gmail.com

 dear r-helpers,

 i created an object named A, which looks like this:

 A - c(4.4,1.9,4.1)

 now i needed to get numbers instead of characters and for this i used the
 function:

 as.integer(A)


 which resulted in:


 [1] 4 1 4


 My question is, why the numbers are rounded or more impotantly if there is a 
 way to keep the decimal numbers?


 Thank you very much for your help in advance!


 Marion



[[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.