Re: [R] how to replace NA values

2014-01-21 Thread kingsly
First of all I thank all the friends.

Though I  have written zero to replace NA in  previous email, I will replace 
with extreme value (9).



On Tuesday, 21 January 2014 7:05 AM, jwd [via R] 
ml-node+s789695n4683894...@n4.nabble.com wrote:
  
On Sun, 19 Jan 2014 11:39:43 -0800 (PST) 

kingsly [hidden email] wrote: 



The age variable is being read in as a factor because of the 
.  If you were to replace it with NA, the type becomes numerical: 

Before replacement: 

str(Elder1) 
'data.frame':   5 obs. of  2 variables: 
 $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5 
 $ age: Factor w/ 3 levels ,35,38: 3 2 1 NA NA 

Notice that the  is treated as a factor level. 

After: 

str(Elder1) 
'data.frame':   5 obs. of  2 variables: 
 $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5 
 $ age: num  38 35 NA NA NA 

SO, the question, is what do you want to do with that column?  An NA
value tells you honestly that the information is missing.  Replacing it 
with a zero can be misleading and can bias some basic parameter 
estimates. 

After you know how you want to treat the data in that field, you may 
have a better idea of how to handle the missing data. 

JWD 

__ 
[hidden email] 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. 






If you reply to this email, your message will be added to the discussion below: 
http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683894.html  
To start a new topic under R help, email ml-node+s789695n78969...@n4.nabble.com 
To unsubscribe from R help, click here.
NAML



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683896.html
Sent from the R help mailing list archive at Nabble.com.
[[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] how to replace NA values

2014-01-19 Thread kingsly
Dear R community
 
I have a large data set contain some empty cells. Because of that,  may be I 
am wrong, NA values are produced.
Now I want replace both empty and NA values with zero.
 
Elder1 - data.frame(
  ID=c(ID1,ID2,ID3,ID6,ID8),
  age=c(38,35,,NA,NA))
Output I am expecting
 
ID   age
ID1  38
ID2  35
ID3  0
ID6  0
ID8  0
 
In advance I thank your help.



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831.html
Sent from the R help mailing list archive at Nabble.com.
[[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] Doubt in simple merge

2014-01-16 Thread kingsly
Dear R community

I have a two data set called Elder and Younger.
This is my code for simple merge.

Elder - data.frame(
  ID=c(ID1,ID2,ID3),
  age=c(38,35,31))
Younger - data.frame(
  ID=c(ID4,ID5,ID3),
  age=c(29,21,31))

mer - merge(Elder,Younger,by=ID, all=T)

Output I am expecting:

ID    age
ID1  38
ID2  35
ID3  31
ID4  29
ID5  21

It looks very simple.  But I need help.  
When I run the code it gives me age.x and age.y.
thank you




--
View this message in context: 
http://r.789695.n4.nabble.com/Doubt-in-simple-merge-tp4683671.html
Sent from the R help mailing list archive at Nabble.com.
[[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] Doubt in simple merge

2014-01-16 Thread kingsly
Thank you dear friends.  You have cleared my first doubt.  

My second doubt:
I have the same data sets Elder and Younger. Elder - data.frame(
  ID=c(ID1,ID2,ID3),
  age=c(38,35,31))
Younger - data.frame(
  ID=c(ID4,ID5,ID3),
  age=c(29,21,NA))


 Row ID3 comes in both data set. It has a value (31) in Elder while NA in 
Younger.

I need output like this.

ID    age
ID1  38
ID2  35
ID3  31
ID4  29
ID5  21 

Kindly help me.



On Thursday, 16 January 2014 9:16 PM, Marc Schwartz-3 [via R] 
ml-node+s789695n4683682...@n4.nabble.com wrote:
 
Not quite: 

 rbind(Elder, Younger) 
   ID age 
1 ID1  38 
2 ID2  35 
3 ID3  31 
4 ID4  29 
5 ID5  21 
6 ID3  31 

Note that ID3 is duplicated. 


Should be: 

 merge(Elder, Younger, by = c(ID, age), all = TRUE) 
   ID age 
1 ID1  38 
2 ID2  35 
3 ID3  31 
4 ID4  29 
5 ID5  21 


He wants to do a join on both ID and age to avoid duplications of rows when 
the same ID and age occur in both data frames. If the same column names (eg 
Var) appears in both data frames and are not part of the 'by' argument, you 
end up with Var.x and Var.y in the result. 

In the case of two occurrences of the same ID but two different ages, if that 
is possible, both rows would be added to the result using the above code. 

Regards, 

Marc Schwartz 


On Jan 16, 2014, at 9:04 AM, Frede Aakmann Tøgersen [hidden email] wrote: 



__ 
[hidden email] 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. 






If you reply to this email, your message will be added to the discussion below: 
http://r.789695.n4.nabble.com/Doubt-in-simple-merge-tp4683671p4683682.html 
To start a new topic under R help, email ml-node+s789695n78969...@n4.nabble.com 
To unsubscribe from R help, click here.
NAML



--
View this message in context: 
http://r.789695.n4.nabble.com/Doubt-in-simple-merge-tp4683671p4683718.html
Sent from the R help mailing list archive at Nabble.com.
[[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] How to evaluate sequence of strings like this

2013-12-08 Thread kingsly
Hello Dear R community,
 This is my problem.  I have a data set (dataframe) called mydat. It 
consist of 3 numerical variable.  They are Centrecode, FSUSN and Round. I 
want to create unique ID by combining these 3 variables.
Follwing commands gives me what I need.

mydat1 - paste(mydat$Centrecode, mydat$FSUSN,mydat$Round,sep=)
newds - data.frame(mydat1)
 
 For a large data set, I don't want to write like this ...    
mydat$Centrecode, mydat$FSUSN,mydat$Round. So,  I tried to automate using 
following code.
 
nvar - paste(mydat,$,names(mydat)[1:3],sep=)
mydat1 - paste(eval(parse(text=nvar)))
newds - data.frame(mydat1_u)
 
I am finding problem in the second line. Please help me. 
Thank you for your kind help.



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-evaluate-sequence-of-strings-like-this-tp4681823.html
Sent from the R help mailing list archive at Nabble.com.
[[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] How to evaluate sequence of strings like this

2013-12-08 Thread kingsly
Thank you.  It is working well.



On Sunday, 8 December 2013 11:13 PM, arun kirshna [via R] 
ml-node+s789695n4681833...@n4.nabble.com wrote:
  
Hi, 
You could do without eval(parse(.. 

mydat - 
data.frame(Centercode=letters[1:5],FSUSN=letters[6:10],Round=letters[11:15],stringsAsFactors=FALSE)
 
mydat1 - paste(mydat$Centercode, mydat$FSUSN,mydat$Round,sep=) 
 mydat2 - as.character(interaction(mydat,sep=)) 
 identical(mydat1,mydat2) 
#[1] TRUE 
#or 
mydat3 - do.call(paste0,mydat) 
identical(mydat1,mydat2) 
#[1] TRUE 
A.K. 



On Sunday, December 8, 2013 8:58 AM, kingsly [hidden email] wrote: 
Hello Dear R community, 
 This is my problem.  I have a data set (dataframe) called mydat. It 
consist of 3 numerical variable.  They are Centrecode, FSUSN and Round. I 
want to create unique ID by combining these 3 variables. 
Follwing commands gives me what I need. 

mydat1 - paste(mydat$Centrecode, mydat$FSUSN,mydat$Round,sep=) 
newds - data.frame(mydat1) 
  
 For a large data set, I don't want to write like this ...    
mydat$Centrecode, mydat$FSUSN,mydat$Round. So,  I tried to automate using 
following code. 
  
nvar - paste(mydat,$,names(mydat)[1:3],sep=) 
mydat1 - paste(eval(parse(text=nvar))) 
newds - data.frame(mydat1_u) 
  
I am finding problem in the second line. Please help me.  
Thank you for your kind help. 



-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-evaluate-sequence-of-strings-like-this-tp4681823.html
Sent from the R help mailing list archive at Nabble.com. 
    [[alternative HTML version deleted]] 

__ 
[hidden email] 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. 


__ 
[hidden email] 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. 






If you reply to this email, your message will be added to the discussion below: 
http://r.789695.n4.nabble.com/How-to-evaluate-sequence-of-strings-like-this-tp4681823p4681833.html
  
To start a new topic under R help, email ml-node+s789695n78969...@n4.nabble.com 
To unsubscribe from R help, click here.
NAML



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-evaluate-sequence-of-strings-like-this-tp4681823p4681841.html
Sent from the R help mailing list archive at Nabble.com.
[[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] How to start R in maximized size???

2012-03-17 Thread kingsly
I think what ever I say applicable to window (operating system).  Start R, 
In Rgui menu, click open edit, you will find GUI preference, clik open 
it. You will find Rgui configuration editor. According to  ur wish, change 
the columns to around 90 (it is a small exercise).  Then click  save . ( 
It will automatically save file with the name of Rconsole(modified), and 
system will ask you show the location to save that file.).  Then you have to 
replace this file with  default Rconsole , available in etc folder. That, 
you can find it, where you have saved your R installation.  
 
Suppose location of R installation is in D:\Soft Area  then probably you can 
find your default Rconsole in D:\Soft Area\R-2.14.1\etc

  


 From: Duncan Murdoch-2 [via R] ml-node+s789695n4478353...@n4.nabble.com

Sent: Friday, 16 March 2012 8:12 PM
Subject: Re: How to start R in maximized size???
  

On 16/03/2012 10:35 AM, Christofer Bogaso wrote: 
 No no, I meant to say the console window, where we type the syntax etc. 
 
 BTW, what is the official name of this window? 

I think console window is good enough. 

Duncan Murdoch 



__ 
[hidden email] 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. 






If you reply to this email, your message will be added to the discussion below: 
http://r.789695.n4.nabble.com/How-to-start-R-in-maximized-size-tp4478313p4478353.html
  
To start a new topic under R help, email ml-node+s789695n78969...@n4.nabble.com 
To unsubscribe from R help, click here.
NAML

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-start-R-in-maximized-size-tp4478313p4480103.html
Sent from the R help mailing list archive at Nabble.com.
[[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] cryptic error message: Error in embed(y, lag) : wrong embedding dimension

2012-01-27 Thread kingsly
According to the source code of embed function, it will stop work if
dimention is 1 or n .  Part of the embed source code is mention below for
your reference. 
if ((dimension  1) | (dimension  n))
stop (wrong embedding dimension)
I have also give the link of the source file of embed funciton
svn.r-project.org/R/trunk/src/library/stats/R/embed.R


--
View this message in context: 
http://r.789695.n4.nabble.com/cryptic-error-message-Error-in-embed-y-lag-wrong-embedding-dimension-tp868230p4333224.html
Sent from the R help mailing list archive at Nabble.com.

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