Re: [R] "Best" way to merge 300+ .5MB dataframes?

2014-08-11 Thread Prof Brian Ripley
On 12/08/2014 07:07, David Winsemius wrote: On Aug 11, 2014, at 8:01 PM, John McKown wrote: On Mon, Aug 11, 2014 at 9:43 PM, Thomas Adams wrote: Grant, Assuming all your filenames are something like file1.txt, file2.txt,file3.txt... And using the Mac OSX terminal app (after you cd to the di

Re: [R] "Best" way to merge 300+ .5MB dataframes?

2014-08-11 Thread David Winsemius
On Aug 11, 2014, at 8:01 PM, John McKown wrote: > On Mon, Aug 11, 2014 at 9:43 PM, Thomas Adams wrote: >> Grant, >> >> Assuming all your filenames are something like file1.txt, >> file2.txt,file3.txt... And using the Mac OSX terminal app (after you cd to >> the directory where your files are lo

Re: [R] "Best" way to merge 300+ .5MB dataframes?

2014-08-11 Thread John McKown
On Mon, Aug 11, 2014 at 9:43 PM, Thomas Adams wrote: > Grant, > > Assuming all your filenames are something like file1.txt, > file2.txt,file3.txt... And using the Mac OSX terminal app (after you cd to > the directory where your files are located... > > This will strip off the 1st lines, that is, y

Re: [R] "Best" way to merge 300+ .5MB dataframes?

2014-08-11 Thread Thomas Adams
Grant, Assuming all your filenames are something like file1.txt, file2.txt,file3.txt... And using the Mac OSX terminal app (after you cd to the directory where your files are located... This will strip off the 1st lines, that is, your header lines: for file in *.txt;do sed -i '1d'${file}; done

Re: [R] "Best" way to merge 300+ .5MB dataframes?

2014-08-11 Thread Grant Rettke
On Sun, Aug 10, 2014 at 6:50 PM, John McKown wrote: > OK, I assume this results in a vector of file names in a variable, > like you'd get from list.files(); Yes. > Why? Do you need them in separate data frames? I do not. > The meat of the question. If you don't need the files in separate data

Re: [R] Reading chunks of data from a file more efficiently

2014-08-11 Thread peter salzman
Scott, there is a package called ff that '... provides data structures that are stored on disk but behave (almost) as if they were in RAM ...' i hope it helps peter On Sat, Aug 9, 2014 at 6:31 PM, Waichler, Scott R wrote: > Hi, > > I have some very large (~1.1 GB) output files from a groundwa

Re: [R] Superimposing graphs

2014-08-11 Thread Duncan Mackay
Hi If you want a 1 package and 1 function approach try this xyplot(conc ~ time | factor(subject, levels = c(2,1,3)), data = data.d, par.settings = list(strip.background = list(col = "transparent")), layout = c(3,1), aspect = 1, type = c("b","g"), scales =

Re: [R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread David Winsemius
On Aug 11, 2014, at 3:27 PM, Jinsong Zhao wrote: > On 2014/8/11 14:50, William Dunlap wrote: >> You can use >> m[m > 0 & m <= 1.0] <- 1 >> m[m > 1 ] <- 2 >> or, if you have lots of intervals, something based on findInterval(). E.g., >> m[] <- findInterval(m, c(-Inf, 0, 1, Inf)) - 1 >

Re: [R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread Jinsong Zhao
On 2014/8/11 14:50, William Dunlap wrote: You can use m[m > 0 & m <= 1.0] <- 1 m[m > 1 ] <- 2 or, if you have lots of intervals, something based on findInterval(). E.g., m[] <- findInterval(m, c(-Inf, 0, 1, Inf)) - 1 (What do you want to do with non-positive numbers?) Bill Dunla

Re: [R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread William Dunlap
You can use m[m > 0 & m <= 1.0] <- 1 m[m > 1 ] <- 2 or, if you have lots of intervals, something based on findInterval(). E.g., m[] <- findInterval(m, c(-Inf, 0, 1, Inf)) - 1 (What do you want to do with non-positive numbers?) Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Au

Re: [R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread Richard M. Heiberger
(m>1)+1 On Mon, Aug 11, 2014 at 5:40 PM, Jinsong Zhao wrote: > Hi there, > > I hope to replace a range of numeric in a matrix with a integer. For > example, in the following matrix, I want to use 1 to replace the elements > range from 0.0 to 1.0, and all larger than 1. with 2. > >> (m <- matrix(r

[R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread Jinsong Zhao
Hi there, I hope to replace a range of numeric in a matrix with a integer. For example, in the following matrix, I want to use 1 to replace the elements range from 0.0 to 1.0, and all larger than 1. with 2. > (m <- matrix(runif(16, 0, 2), nrow = 4)) [,1] [,2] [,3] [,4

Re: [R] how to process multiple data files using R loop

2014-08-11 Thread Greg Snow
In addition to the solution and comments that you have already received, here are a couple of additional comments: This is a variant on FAQ 7.21, if you had found that FAQ then it would have told you about the get function. The most important part of the answer in FAQ 7.21 is the last part where

Re: [R] loops with assign() and get()

2014-08-11 Thread William Dunlap
That code will not work. get() and assign() are troublesome for a variety of reasons. E.g., * adding made-up names to the current environment is dangerous. They may clobber fixed names in the environment. You may be confused about what the current environment is (especially when refactoring co

Re: [R] Superimposing graphs

2014-08-11 Thread Rmh
whoops P1<- plot(grouped.data) Sent from my iPhone > On Aug 11, 2014, at 5:06, Naser Jamil wrote: > > Dear R-user, > May I seek your help to sort out a little problem. I have the following > codes > to draw two graphs. I want to superimpose the second one on each of the > first one. > > #

Re: [R] Just stumbled across this: Advanced R programming text & code - from Hadley

2014-08-11 Thread PO SU
The book is absolutely helpful to me. Any R newusers should read the book. Now I am reading the Section Rcpp. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU At 2014-08-11 09:02:53, "Mitchell Maltenfort" wrote: >Ah, what do you know anyway? -- as the book critic said t

Re: [R] Problem with assignment 1 part 1

2014-08-11 Thread John McKown
On Mon, Aug 11, 2014 at 9:00 AM, michelle maurin wrote: > see code below > > > pollutantmean <- function(directory, pollutant, id = 1:332) { > files_list <- list.files(directory, full.names=TRUE) #creates a list of > files > dat <- data.frame()#creates an empty data frame > for (i in 1:332)

Re: [R] Superimposing graphs

2014-08-11 Thread Richard M. Heiberger
I think this is what you are looking for. library(latticeExtra) t.tmp <-seq(0,30, .01) P1 + layer(panel.xyplot(y=f1(0.5,0.5,0.06, t.tmp), x=t.tmp, type="l", col="black")) Notice that t is a very bad name for your variable as it is the name of a function. I used t.tmp instead. Rich On Mon, Aug

[R] building a BIGLM model from three tables (related)

2014-08-11 Thread Farewell, Timothy
Hi all, I wonder if you can help me. THE PROBLEM I want to train and test a GLM with some large datasets. I am running into some problems when I flatten my tables together to feed into the GLM model, as it produces a very large table which is far too big for the memory on my computer. THREE T

[R] [vegan]Envfit, pvalues and ggplot2

2014-08-11 Thread Tim Richter-Heitmann
Good Morning, first let me thank you very much for answering my first two questions on this list. Currently, i do vegan's EnvFit to simple PCA ordinations. When drawing the biplot, one can set a cutoff to just fit the parameters with significant p-values (via p.max=0.05 in the plot command).

[R] Superimposing graphs

2014-08-11 Thread Naser Jamil
Dear R-user, May I seek your help to sort out a little problem. I have the following codes to draw two graphs. I want to superimpose the second one on each of the first one. library(nlme) subject<-c(1,1,1,2,2,2,3,3,3) time<-c(0.0,5.4,21.0,0.0,5.4,21.0,0.0,

Re: [R] Just stumbled across this: Advanced R programming text & code - from Hadley

2014-08-11 Thread Mitchell Maltenfort
Ah, what do you know anyway? -- as the book critic said to the author. Ersatzistician and Chutzpahthologist I can answer any question. "I don't know" is an answer. "I don't know yet" is a better answer. "I can write better than anybody who can write faster, and I can

Re: [R] Just stumbled across this: Advanced R programming text & code - from Hadley

2014-08-11 Thread Hadley Wickham
Or just go to http://adv-r.had.co.nz/ ... Hadley On Sun, Aug 10, 2014 at 9:34 PM, John McKown wrote: > Well, it says that it's from Hadley Wickham. > > https://github.com/hadley/adv-r > > > This is code and text behind the Advanced R programming book. > > The site is built using jekyll, with a

Re: [R] C.D.F

2014-08-11 Thread Rolf Turner
On 11/08/14 20:17, pari hesabi wrote: Hello everybody, Can anybody help me to write a program for the CDF of sum of two independent gamma random variables ( covolution of two gamma distributions) with different amounts of parameters( the shape parameters are the same)? Is this homework? Th

Re: [R] C.D.F

2014-08-11 Thread Prof. Dr. Matthias Kohl
Dear Diba, you could try package distr; eg. library(distr) G1 <- Gammad(scale = 0.7, shape = 0.5) G2 <- Gammad(scale = 2.1, shape = 1.7) G3 <- G1+G2 # convolution G3 For the convolution exact formulas are applied if available, otherwise we use FFT; see also http://www.jstatsoft.org/v59/i04/ (w

[R] Need help in using Rcpp

2014-08-11 Thread PO SU
Dear Rcppusers, I can't figure out what the following codes do: int f4(Function pred, List x) { int n = x.size(); for(int i = 0; i < n; ++i) { LogicalVector res = pred(x[i]); if (res[0]) return i + 1; } return 0; } I investigated it, and understand applying a function to everypart of a lis

Re: [R] loops with assign() and get()

2014-08-11 Thread PO SU
It's a great method, but there is a memory problem, DFS would occupy a large memory. So from this point of view, i prefer the loop. >> for (i in 1 : nrow(unique)){ >> tmp=get(past0("DF",i))[1,] >> assign(paste0("df",i),tmp) >> dfi=dfi[,1:3] >> names(dfi)=names(tmp[c(1,4,5)]) >> dfi=rbind(dfi,tm

[R] GSoC 2014 - an R package for working with RRD files

2014-08-11 Thread Plamen Dimitrov
Hello, I'm taking part in Google Summer of Code 2014 wih Ganglia and I spent the past few months implementing an R package that makes it possible to directly import and work with RRD (http://oss.oetiker.ch/rrdtool/) files in R. There are currently three ways to use the package: - importRRD("file

[R] C.D.F

2014-08-11 Thread pari hesabi
Hello everybody, Can anybody help me to write a program for the CDF of sum of two independent gamma random variables ( covolution of two gamma distributions) with different amounts of parameters( the shape parameters are the same)? Thank you Diba