[R] Help with decimal points

2010-09-07 Thread Amit Patel
Hi


I have found a little problem with an R script. I am trying to merge some data 
and am finding something unusual going on. As shown below I am trying to 
assign (MatchedValues[Value2,Value]) to  (ClusteredData[k,Value]) which are two 
separate dataframes.

1) By the following command you can see that the value im transferring 
is 481844.03

 MatchedValues[Value2,Value]
[1] 481844.03
6618 Levels: 1.00E+07 1.01E+07 1.02E+07 1.04E+07 1.05E+07 1.06E+07 ... Raw


2) But when I try to replace the values using the command i get a value of 4420


ClusteredData[k,Value] - MatchedValues[Value2,Value]

 ClusteredData[k,Value]
[1] 4420


3) So what am I not doing. How can I keep that same value of 481844.03
I have tried


 as.double(MatchedValues[Value2,Value])
[1] 4420


 as.numeric(MatchedValues[Value2,Value])
[1] 4420




__
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] Help with decimal points

2010-09-07 Thread Sarah Goslee
MatchedValues is a factor rather than numeric, and so is giving you
results you don't expect. 4420 is the level of the factor, out of the 6618
total levels.

Probably the best thing to do is figure out why your data are factors
when you expect numbers.

Sarah

On Tue, Sep 7, 2010 at 4:38 PM, Amit Patel amitrh...@yahoo.co.uk wrote:
 Hi


 I have found a little problem with an R script. I am trying to merge some data
 and am finding something unusual going on. As shown below I am trying to
 assign (MatchedValues[Value2,Value]) to  (ClusteredData[k,Value]) which are 
 two
 separate dataframes.

 1) By the following command you can see that the value im transferring
 is 481844.03

 MatchedValues[Value2,Value]
 [1] 481844.03
 6618 Levels: 1.00E+07 1.01E+07 1.02E+07 1.04E+07 1.05E+07 1.06E+07 ... Raw


 2) But when I try to replace the values using the command i get a value of 
 4420


ClusteredData[k,Value] - MatchedValues[Value2,Value]

 ClusteredData[k,Value]
 [1] 4420


 3) So what am I not doing. How can I keep that same value of 481844.03
 I have tried


 as.double(MatchedValues[Value2,Value])
 [1] 4420


 as.numeric(MatchedValues[Value2,Value])
 [1] 4420





-- 
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] Help with decimal points

2010-09-07 Thread Ista Zahn
Hi Amit,
MatchedValues$Value is a factor. Converting factors to numeric is a
FAQ: see 
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

Best,
Ista

On Tue, Sep 7, 2010 at 4:38 PM, Amit Patel amitrh...@yahoo.co.uk wrote:
 Hi


 I have found a little problem with an R script. I am trying to merge some data
 and am finding something unusual going on. As shown below I am trying to
 assign (MatchedValues[Value2,Value]) to  (ClusteredData[k,Value]) which are 
 two
 separate dataframes.

 1) By the following command you can see that the value im transferring
 is 481844.03

 MatchedValues[Value2,Value]
 [1] 481844.03
 6618 Levels: 1.00E+07 1.01E+07 1.02E+07 1.04E+07 1.05E+07 1.06E+07 ... Raw


 2) But when I try to replace the values using the command i get a value of 
 4420


ClusteredData[k,Value] - MatchedValues[Value2,Value]

 ClusteredData[k,Value]
 [1] 4420


 3) So what am I not doing. How can I keep that same value of 481844.03
 I have tried


 as.double(MatchedValues[Value2,Value])
 [1] 4420


 as.numeric(MatchedValues[Value2,Value])
 [1] 4420




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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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] Help with decimal points

2010-09-07 Thread David Winsemius


On Sep 7, 2010, at 4:38 PM, Amit Patel wrote:

I have found a little problem with an R script. I am trying to merge  
some data
and am finding something unusual going on. As shown below I am  
trying to
assign (MatchedValues[Value2,Value]) to  (ClusteredData[k,Value])  
which are two

separate dataframes.

1) By the following command you can see that the value im transferring
is 481844.03


MatchedValues[Value2,Value]

[1] 481844.03
6618 Levels: 1.00E+07 1.01E+07 1.02E+07 1.04E+07 1.05E+07 1.06E 
+07 ... Raw


This shows you that MatchValues' column eval(Value) is a factor  
represented internally by one of 6618 integers with various level  
labels. The label of the item in row eval(Value2) is 481844.03. The  
label is a character object.




2) But when I try to replace the values using the command i get a  
value of 4420



ClusteredData[k,Value] - MatchedValues[Value2,Value]



ClusteredData[k,Value]

[1] 4420


3) So what am I not doing. How can I keep that same value of 481844.03
I have tried


Read FAQ 7.10:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

--
David.




as.double(MatchedValues[Value2,Value])

[1] 4420


as.numeric(MatchedValues[Value2,Value])

[1] 4420


--

David Winsemius, MD
West Hartford, CT

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