[R] Import multiple files into R

2014-03-20 Thread ajaykumar
Hi I want to import around 75 files. Each file has a name and a time and is comma separated. For example some of my file names are Asheville_Dec.txt Asheville_Jan.txt Asheville_Feb.txt Charlotte_Dec.txt Chapelhill_Jan.txt The time months are only Dec Jan and Feb. The locations are different. I

[R] randomForest warning: The response has five or fewer unique values. Are you sure you want to do regression?

2014-03-20 Thread Sean Porter
Hello everyone, Im relatively new to R and new to the randomForest package and have scoured the archives for help with no luck. I am trying to perform a regression on a set of predictors and response variables to determine the most important predictors. I have 100 response variables collected

Re: [R] Import multiple files into R

2014-03-20 Thread PIKAL Petr
Hi Best way is to put those files in one directory and start R from this directory or set this directory as working one. ?set.wd Then you can use list.files() to get file names. ?list.files myfiles-list.files() Than strip txt. E.g. by filenames-strsplit(list.files(), \\.)) After that you

Re: [R] Import multiple files into R

2014-03-20 Thread PIKAL Petr
Hm. We also do not know what will be done with those files. Save/load is an option but in that case nothing prevents you to use original file and read.* function interactively. I understood that OP wanted to load all files as 75 objects into one R session environment. In that case having one

Re: [R] [Re: Does a survival probability(the probability not, experiencing an event) have to be non-increasing?

2014-03-20 Thread Therneau, Terry M., Ph.D.
On 03/20/2014 06:00 AM, r-help-requ...@r-project.org wrote: My question is related to a cox model with time-dependent variable. When I think about it more, I get a little confused about non-increasing assumption for survival probability for an individual. For example, for a time-dependent ,say

[R] dnearneigh::spdep: undesired behaviour with SpatialPoints object: bug or feature? Please confirm.

2014-03-20 Thread Jan Holstein
I noticed that dnearneigh::spdep shows diverging behaviour with matrix and SpatialPoints objects respectively: reproducible example: library(spdep) set.seed(5) spdf-SpatialPointsDataFrame(cbind(lon=runif(1000,2,8),lat=runif(1000,53,56)), data=data.frame(par=runif(1000,0,1)),coords.nrs =

[R] ASReml-R Course - Chicago APRIL 24/25

2014-03-20 Thread Carey Biggs
Dear Sirs I would like to make you aware of the following training taking place in Chicago next month. Analysis of experiments using ASReml-R, Chicago, 24/25th April This workshop is aimed at scientist/practitioners that are interested in analyzing complex datasets by fitting linear mixed

[R] How to make a code last until a condition is completed ?

2014-03-20 Thread Gwennaël Bataille
# Dear all, # I simulate individual paths in a landscape (let's say coordinates in x and y range # from -100 to 100 both) and would like to replace each individual going outside the # landscape by a new simulation... until none of them goes outside the landscape. # For example, I simulate

Re: [R] Import multiple files into R

2014-03-20 Thread Lisa S
But I don't think a list can contain that much data - we dont know how big each txt file is. So I'd like to do: city.set - c('Asheville','Charlotte') month.set - c('Dec', 'Jan', 'Feb') comb.set - expand.grid(city.set,month.set) comb.set$filename = paste(comb.set[,1],comb.set[,2],sep = '_') for

Re: [R] Fwd: cforest sampling methods

2014-03-20 Thread Torsten Hothorn
Hi all, I've been using the randomForest package and I'm trying to make the switch over to party. My problem is that I have an extremely unbalanced outcome (only 1% of the data has a positive outcome) which makes resampling methods necessary. randomForest has a very useful argument that is

Re: [R] How to make a code last until a condition is completed ?

2014-03-20 Thread PIKAL Petr
Hi I have a strong suspiction that you want to reinvent wheel. does functions ?chull (grDevices) and ?pip (splancs) do what you want? Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Gwennaël Bataille Sent:

Re: [R] How to make a code last until a condition is completed ?

2014-03-20 Thread PIKAL Petr
Hi It seems to me that it is task for while loop with break but I never used it. see ?for something like counter-0 is.outside - TRUE while(is.outside) { counter-counter+1 {do what you want here and set some.test/another.test} is.outside - some.test another.test if (counter100) break # just to

[R] Error: cannot allocate vector of size 5.2 Gb

2014-03-20 Thread eliza botto
Dear R family, I am trying to read a real large dataset in R (~ 2Gb). Its in binary format. When i tried to read it by using following command readBin(DAT.dat.nc, numeric(), n=9e8, size=4, signed=TRUE, endian='little') I got the following error Error: cannot allocate vector of size 5.2 Gb I have

[R] smoothing a plot in r

2014-03-20 Thread Babak Bastan
Hi friends Iwould like to smooth my plot. I have a plot which is wiggly and I want to smooth it. here is my data 539, 532, 531, 538, 544, 554, 575, 571, 543, 559, 511, 525, 512, 540, 535, 514, 524, 527, 532, 547, 564, 548, 572, 564, 549, 532, 519, 520, 520, 543, 550, 542, 528, 523, 531, 548,

Re: [R] Error: cannot allocate vector of size 5.2 Gb

2014-03-20 Thread Clint Bowman
5.2 won't go into 4 but there may be more problems. 32-bit or 64 bit operating system? RAM is cheap but will your motherboard support more than 4 GB? And don't forget there are other processes that need to run while you are using R. Clint BowmanINTERNET:

Re: [R] smoothing a plot in r

2014-03-20 Thread MacQueen, Don
Perhaps you will understand the meaning better if you try the following sequence: plot(datalist, ylab='Value') lines(lowess(datalist),col=blue, lwd=2) lines(lowess(datalist,f=1/3),col=red, lwd=2) lines(lowess(datalist,f=1/10),col=green, lwd=2) -Don -- Don MacQueen Lawrence Livermore National

Re: [R] smoothing a plot in r

2014-03-20 Thread Babak Bastan
thanks you so much On Thu, Mar 20, 2014 at 10:25 AM, MacQueen, Don macque...@llnl.gov wrote: Perhaps you will understand the meaning better if you try the following sequence: plot(datalist, ylab='Value') lines(lowess(datalist),col=blue, lwd=2) lines(lowess(datalist,f=1/3),col=red, lwd=2)

Re: [R] How to make a code last until a condition is completed ?

2014-03-20 Thread Gwennaël Bataille
Dear Petr, Thank you for your answer. This will probably save me three lines of script, which is appreciable. Unfortunately, this does not solve my main issue, that is: If my condition is not fulfilled (some points are outside the landscape), I have to go back in the script to the first step,

Re: [R] R help

2014-03-20 Thread arun
Hi, Another way would be: dat11 -  transform(dat[rep(1:nrow(dat),each=12),1:2], weekdatesunday=rep(0:11,3), RevenueWeekN00=as.vector(t(dat[,-c(1:2)]))) row.names(dat11) - 1:nrow(dat11)   dat22 - unsplit(lapply(split(dat11, with(dat11,list(customer_id,CountryName)),drop=TRUE),function(x) {m1 -

[R] Fw: 2013-06-28 coverts to 15884?

2014-03-20 Thread arun
Hi, Not sure if this helps or not: vec1 - c(MaxUpdated_row, as.Date(c(2013-06-28,2013-06-29), %Y-%m-%d)) + as.Date(1970-01-01) vec1 #[1] 2013-06-28 2013-06-29 str(vec1)  #Date[1:2], format: 2013-06-28 2013-06-29 rbind(MaxUpdated_row, as.Date(c(2013-06-28,2013-06-29), %Y-%m-%d)) +

Re: [R] R help

2014-03-20 Thread arun
Hi, It is better to use ?dput() to show the data.dput(dataset) dat - structure(list(customer_id = c(8L, 33L, 12L), CountryName = c(US, CA, UK), RevenueWeekN00 = c(2.28, 0, 30.18), RevenueWeekN01 = c(9.57, 14.69, 43.9), RevenueWeekN02 = c(7.54, 3.31, 90.4), RevenueWeekN03 = c(8.99, 5.21, 45),

[R] LOOKING FOR CODE REPOSITORY

2014-03-20 Thread Subhabrata Banerjee
Dear Group, I am bit new in R. I am looking for a code repository of few projects developed in R. I want to see them to learn more. If any one of the esteemed members of the group may kindly help. Regards, Subhabrata Banerjee. [[alternative HTML version deleted]]

Re: [R] LOOKING FOR CODE REPOSITORY

2014-03-20 Thread Greg Snow
Please read the posting guide (there is a link at the bottom of every post) and post in plain text, not HTML, and also avoid all caps. The biggest repository of R code is probably CRAN which is linked from the main R page. There are also R-forge and Bioconductor and many R packages on Github.

Re: [R] How to make a code last until a condition is completed ?

2014-03-20 Thread William Dunlap
Look into the while() statement. E.g., f - function(n, absLimit) { x - rep(absLimit+1, n) # start with all x,y outside limits y - x while(any(isOutside - abs(x)absLimit | abs(y)absLimit)) { x[isOutside] - rnorm(sum(isOutside), 0, 100) y[isOutside] -

Re: [R] Calculations with aggregate data: mean +/- standard deviation

2014-03-20 Thread Rui Barradas
Hello, Try res[order(res[,1]), ] Hope this helps, Rui Barradas Em 20-03-2014 17:48, Luigi Marongiu escreveu: Dear Rui, Thnak you very much: this works exactly as I requested, but the merged vetor (res) order the variables by alphabetical order rather than by the factors I indicated during

[R] Setting plot() parameters

2014-03-20 Thread Rich Shepard
For time series plots using zoo I want the layout to be horizontal rectangles rather than squares. When I specify par(pin=5,2.5) an error is returned: Error in par(pin = 5,2.5) : graphical parameter pin has the wrong length In addition: Warning message: In par(pin = 5,2.5) : NAs introduced

Re: [R] Setting plot() parameters

2014-03-20 Thread Rui Barradas
Hello, Use c(), not par(pin = c(5, 2.5)) Hope this helps, Rui Barradas Em 20-03-2014 19:30, Rich Shepard escreveu: For time series plots using zoo I want the layout to be horizontal rectangles rather than squares. When I specify par(pin=5,2.5) an error is returned: Error in

Re: [R] Setting plot() parameters

2014-03-20 Thread Sarah Goslee
You're specifying a string rather than two numbers. Try c(5, 2.5) instead. Sarah On Thu, Mar 20, 2014 at 3:30 PM, Rich Shepard rshep...@appl-ecosys.com wrote: For time series plots using zoo I want the layout to be horizontal rectangles rather than squares. When I specify par(pin=5,2.5) an

[R] rounding to whole number

2014-03-20 Thread Kristi Glover
Hi R User, I was trying to convert a decimal value into integral (whole number). I used round function but some of the cells have the value less than 0.5 and it converted into 0. But I wanted these cell to have 1 instead of 0. Another way, I could multiply by 10. But l did not want it because

Re: [R] rounding to whole number

2014-03-20 Thread Sarah Goslee
What about: ceiling(data[,2:3]) A B 1 0 1 2 3 1 3 3 3 4 2 3 Note that ceiling is referenced in ?round Thanks for the clear reproducible example. Sarah On Thu, Mar 20, 2014 at 3:42 PM, Kristi Glover kristi.glo...@hotmail.com wrote: Hi R User, I was trying to convert a decimal value into

Re: [R] rounding to whole number

2014-03-20 Thread Ted Harding
On 20-Mar-2014 19:42:35 Kristi Glover wrote: Hi R User, I was trying to convert a decimal value into integral (whole number). I used round function but some of the cells have the value less than 0.5 and it converted into 0. But I wanted these cell to have 1 instead of 0. Another way, I could

Re: [R] Setting plot() parameters

2014-03-20 Thread Rich Shepard
On Thu, 20 Mar 2014, Rui Barradas wrote: Use c(), not par(pin = c(5, 2.5)) Rui/Sarah, Thank you both. I did not pick up on that even though that's how plt is described. Rich __ R-help@r-project.org mailing list

Re: [R] survfit question - Q1 and Q3 survival time?

2014-03-20 Thread Lucy Leigh
Excellent! Thank you for your help. -Original Message- From: Therneau, Terry M., Ph.D. [mailto:thern...@mayo.edu] Sent: Monday, 17 March 2014 11:15 PM To: Lucy Leigh; r-help@R-project.org Cc: David Winsemius Subject: Re: survfit question - Q1 and Q3 survival time? Try

Re: [R] Setting plot() parameters

2014-03-20 Thread Rich Shepard
On Thu, 20 Mar 2014, Rich Shepard wrote: For time series plots using zoo I want the layout to be horizontal rectangles rather than squares. When I specify par(pin = c(5,2.5)) nothing happens; the plot frame is square regardless of specifying pin within the plot command or prior to issuing the

Re: [R] Error: cannot allocate vector of size 5.2 Gb

2014-03-20 Thread Pascal Oettli
Hello, It is not the right way to read a NetCDF file (according to the extension) in R. Please have a look at the ncdf4 package. The raster package is also able to read this kind of files. Regards, Pascal On Fri, Mar 21, 2014 at 1:25 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear R

Re: [R] LOOKING FOR CODE REPOSITORY

2014-03-20 Thread Jeff Newmiller
Although there is a great deal of value to be gained by understanding how package code is written, most of my R projects consist of a file with 10-100 lines of code working with data in the global environment that call on packages. Such code is not typically posted online. I do find it

Re: [R] Setting plot() parameters

2014-03-20 Thread Gabor Grothendieck
On Thu, Mar 20, 2014 at 7:13 PM, Rich Shepard rshep...@appl-ecosys.com wrote: On Thu, 20 Mar 2014, Rich Shepard wrote: For time series plots using zoo I want the layout to be horizontal rectangles rather than squares. When I specify par(pin = c(5,2.5)) nothing happens; the plot frame is

Re: [R] Expanding matrix

2014-03-20 Thread arun
Hi,You could do: m1 - as.matrix(read.table(text=3 0.9 1 5 0.5 0.7 7 0.1 0.3,sep=,header=FALSE)) dimnames(m1) - NULL d2 - data.frame(V1=1:10) d1 - as.data.frame(m1) library(zoo) res - na.locf(merge(d1,d2,all=TRUE)) res[is.na(res)] - 1  res #or vec1 - 1:10 indx - vec1[!vec1 %in% m1[,1]] res2 -

Re: [R] How to make a code last until a condition is completed ?

2014-03-20 Thread Boris Steipe
This is really a question of programming logic - not of R per se. If I understand your problem correctly, the preferred approach is not to create your paths all at once, but individually, and check that they fulfil your requirements as you generate them. Keep on doing this until you have enough

Re: [R] Import multiple files into R

2014-03-20 Thread Marc Girondot
You can check the function read_folder() in the package phenology. read_folder(folder = try(file.choose(), silent = TRUE), wildcard = *.*, read = read.delim, ...) Arguments folder Where to search for files; can be or a file path or a folder path wildcard Define which files are to be read

Re: [R] rounding to whole number

2014-03-20 Thread Boris Steipe
Try ?ceiling ceiling(0.4) [1] 1 B. On 2014-03-20, at 3:42 PM, Kristi Glover wrote: Hi R User, I was trying to convert a decimal value into integral (whole number). I used round function but some of the cells have the value less than 0.5 and it converted into 0. But I wanted these

[R] How to importing a CVS file with multiple tables?

2014-03-20 Thread jcrosbie
I'm trying to figure out how to import data into a dataframe in R. The table I'm trying to import is: HistoricalTradingReportServlet.csv http://r.789695.n4.nabble.com/file/n4687246/HistoricalTradingReportServlet.csv I would like to add two more column for each block of data to have the

Re: [R] how to write a regular expression for this?

2014-03-20 Thread arun
Hi, May be this helps: strsplit(sub((.*)(\\|.*),\\1 \\2,test), )[[1]] #[1] comp99810_c0_seq1 |m.8409   sub((.*)\\|.*,\\1,test) #[1] comp99810_c0_seq1  sub(.*(\\|.*),\\1,test) #[1] |m.8409    A.K. Hi Could some one help me regular expression for this. I am really struggling. Basically i