Re: [R] Import multiple data frames and combine them using cbind

2012-12-05 Thread David Winsemius


On Dec 4, 2012, at 8:56 PM, Gyanendra Pokharel wrote:


Thanks Dennis,
Your code also produces same as Jim's but I am not looking that one,  
I need
to use cbind so that finally I will get the data frame of size  
200X320

(i,e, 200 X(16X20)).
Thanks


Here we are a day later and your question risks sinking beneath the  
waves because you have not realized that you are implicitly making  
impossible demands on your volunteer consultants. Please review your  
postings and responses and try to put yourself in the position of  
someone who doesn't have the capacity to read your mind or see your  
screen.


--
David.



On Tue, Dec 4, 2012 at 10:46 PM, Dennis Murphy djmu...@gmail.com  
wrote:



In addition to Jim's reply, had you used the plyr package, you could
have done this in one shot:

library(plyr)

DF - ldply(llply(temp, read.table), rbind)

The inner llply call is equivalent to your lapply() and the outer
ldply() is equivalent to Jim's do.call() code.

Dennis

On Tue, Dec 4, 2012 at 6:37 PM, Gyanendra Pokharel
gyanendra.pokha...@gmail.com wrote:

Hi group,

I imported  16 data frames using the function list.files

temp - list.files(path=...)
myfiles = lapply(temp, read.table,sep = )

Now I have 16 data set imported in R window.

I want to combine them by row and tried some thing like (Here I am
considering only 20 columns)

for(i in 1:16){
   data- cbind(myfiles[[i]][,1:20])

}


but it returns only first data set. I can combine them using

data - cbind(myfiles[[1]][,1:20],myfiles[[2]] 
[1:20],...)


But  I want in a loop so that I can make the efficient code.

Any kind of suggestion will be great for me.

Thanks

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




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


David Winsemius, MD
Alameda, CA, USA

__
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] Import multiple data frames and combine them using cbind

2012-12-05 Thread Gyanendra Pokharel
I am sorry David, I don't mean to give the answer of the impossible
questions. Just you can say impossible. If there is no way to do what I
explained, that's fine, we do have other alternatives what I wrote in the
beginning.

Thank you so much.



On Wed, Dec 5, 2012 at 1:12 PM, David Winsemius dwinsem...@comcast.netwrote:

 beneath

[[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] Import multiple data frames and combine them using cbind

2012-12-05 Thread David Winsemius

On Dec 5, 2012, at 10:36 AM, Gyanendra Pokharel wrote:

 I am sorry David, I don't mean to give the answer of the impossible  
 questions. Just you can say impossible. If there is no way to do  
 what I explained, that's fine, we do have other alternatives what I  
 wrote in the beginning.


I did not say it was impossible to do what you are thinking you want  
to do, only that it is impossible to read your mind. You need to to  
describe what you are thinking in greater detail.

 Thank you so much.



 On Wed, Dec 5, 2012 at 1:12 PM, David Winsemius dwinsem...@comcast.net 
  wrote:
 beneath


David Winsemius, MD
Alameda, CA, USA


[[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] Import multiple data frames and combine them using cbind

2012-12-05 Thread Berend Hasselman

On 05-12-2012, at 03:37, Gyanendra Pokharel wrote:

 Hi group,
 
 I imported  16 data frames using the function list.files
 
 temp - list.files(path=...)
 myfiles = lapply(temp, read.table,sep = )
 
 Now I have 16 data set imported in R window.
 
 I want to combine them by row and tried some thing like (Here I am
 considering only 20 columns)
 
 for(i in 1:16){
data- cbind(myfiles[[i]][,1:20])
 
 }
 
 
 but it returns only first data set. I can combine them using
 
 data - cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...)
 
 But  I want in a loop so that I can make the efficient code.

Slightly guessing what you want.
Toy example

set.seed(123)
mydf - lapply(1:4,FUN=function(dname) data.frame(x=round(runif(10),2), 
y=round(runif(10),2),z=round(runif(10),2)))
mydf

do.call(cbind,lapply(mydf, function(df) df[,1:2]))


Berend

__
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] Import multiple data frames and combine them using cbind

2012-12-05 Thread Gyanendra Pokharel
Thanks Berend, your Idea is great, that,s what I was looking.

Thanks again

On Wed, Dec 5, 2012 at 2:06 PM, Berend Hasselman b...@xs4all.nl wrote:

 do.call(cbind,lapply(mydf, function(df) df[,1:2]))

[[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] Import multiple data frames and combine them using cbind

2012-12-04 Thread Gyanendra Pokharel
Hi group,

I imported  16 data frames using the function list.files

temp - list.files(path=...)
myfiles = lapply(temp, read.table,sep = )

Now I have 16 data set imported in R window.

I want to combine them by row and tried some thing like (Here I am
considering only 20 columns)

for(i in 1:16){
data- cbind(myfiles[[i]][,1:20])

}


but it returns only first data set. I can combine them using

data - cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...)

But  I want in a loop so that I can make the efficient code.

Any kind of suggestion will be great for me.

Thanks

[[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] Import multiple data frames and combine them using cbind

2012-12-04 Thread jim holtman
try::

do.call(rbind, myfiles)

On Tue, Dec 4, 2012 at 9:37 PM, Gyanendra Pokharel
gyanendra.pokha...@gmail.com wrote:
 Hi group,

 I imported  16 data frames using the function list.files

 temp - list.files(path=...)
 myfiles = lapply(temp, read.table,sep = )

 Now I have 16 data set imported in R window.

 I want to combine them by row and tried some thing like (Here I am
 considering only 20 columns)

 for(i in 1:16){
 data- cbind(myfiles[[i]][,1:20])

 }


 but it returns only first data set. I can combine them using

 data - cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...)

 But  I want in a loop so that I can make the efficient code.

 Any kind of suggestion will be great for me.

 Thanks

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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
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] Import multiple data frames and combine them using cbind

2012-12-04 Thread Gyanendra Pokharel
Thanks Jim but I need to use cbind otherwise I will not get the correct
information from the data. Also each data set has the dimension 200X365 but
I only need 200X20 each.

Thanks

On Tue, Dec 4, 2012 at 10:22 PM, jim holtman jholt...@gmail.com wrote:

 try::

 do.call(rbind, myfiles)

 On Tue, Dec 4, 2012 at 9:37 PM, Gyanendra Pokharel
 gyanendra.pokha...@gmail.com wrote:
  Hi group,
 
  I imported  16 data frames using the function list.files
 
  temp - list.files(path=...)
  myfiles = lapply(temp, read.table,sep = )
 
  Now I have 16 data set imported in R window.
 
  I want to combine them by row and tried some thing like (Here I am
  considering only 20 columns)
 
  for(i in 1:16){
  data- cbind(myfiles[[i]][,1:20])
 
  }
 
 
  but it returns only first data set. I can combine them using
 
  data - cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...)
 
  But  I want in a loop so that I can make the efficient code.
 
  Any kind of suggestion will be great for me.
 
  Thanks
 
  [[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.



 --
 Jim Holtman
 Data Munger Guru

 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.


[[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] Import multiple data frames and combine them using cbind

2012-12-04 Thread Gyanendra Pokharel
Thanks Dennis,
Your code also produces same as Jim's but I am not looking that one, I need
to use cbind so that finally I will get the data frame of size 200X320
(i,e, 200 X(16X20)).
Thanks


On Tue, Dec 4, 2012 at 10:46 PM, Dennis Murphy djmu...@gmail.com wrote:

 In addition to Jim's reply, had you used the plyr package, you could
 have done this in one shot:

 library(plyr)

 DF - ldply(llply(temp, read.table), rbind)

 The inner llply call is equivalent to your lapply() and the outer
 ldply() is equivalent to Jim's do.call() code.

 Dennis

 On Tue, Dec 4, 2012 at 6:37 PM, Gyanendra Pokharel
 gyanendra.pokha...@gmail.com wrote:
  Hi group,
 
  I imported  16 data frames using the function list.files
 
  temp - list.files(path=...)
  myfiles = lapply(temp, read.table,sep = )
 
  Now I have 16 data set imported in R window.
 
  I want to combine them by row and tried some thing like (Here I am
  considering only 20 columns)
 
  for(i in 1:16){
  data- cbind(myfiles[[i]][,1:20])
 
  }
 
 
  but it returns only first data set. I can combine them using
 
  data - cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...)
 
  But  I want in a loop so that I can make the efficient code.
 
  Any kind of suggestion will be great for me.
 
  Thanks
 
  [[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.


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