[R] csv file with two header rows

2013-04-26 Thread analys...@hotmail.com
Is there a way to use read.csv() on such a file without deleting one of the header rows? Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] C50 package in R

2013-04-26 Thread Indrajit Sen Gupta
Hi All, I am trying to use the C50 package to build classification trees in R. Unfortunately there is not enought documentation around its use. Can anyone explain to me - how to prune the decision trees? Regards, Indrajit [[alternative HTML version deleted]]

[R] Help with dataEllipse function

2013-04-26 Thread Jana Makedonska
Hi Everyone, I am working with the R function dataEllipse. I plot the 95% confidence ellipses for several different samples in the same plot and I color-code the ellipse of each sample, but I do not know how to specify a different line pattern for each ellipse. I can only modify the pattern for

[R] nls: example code throws error

2013-04-26 Thread Steven LeBlanc
Greets, I'm trying to learn to use nls and was running the example code for an exponential model: x - -(1:100)/10 y - 100 + 10 * exp(x / 2) + rnorm(x)/10 nlmod - nls(y ~ Const + A * exp(B * x)) Error in B * x : non-numeric argument to binary operator In addition: Warning message: In nls(y ~

Re: [R] nls: example code throws error

2013-04-26 Thread Gabor Grothendieck
On Thu, Apr 25, 2013 at 7:16 PM, Steven LeBlanc ores...@gmail.com wrote: Greets, I'm trying to learn to use nls and was running the example code for an exponential model: x - -(1:100)/10 y - 100 + 10 * exp(x / 2) + rnorm(x)/10 nlmod - nls(y ~ Const + A * exp(B * x)) Error in B * x :

Re: [R] split number into array

2013-04-26 Thread arun
Hi,Not sure about the criteria for deciding number of zeros.  vec1- c(23,244,1343,45,153555,546899,75)  lst1- strsplit(as.character(vec1),) m1-max(sapply(lst1,length)) res- t(sapply(lst1,function(x) as.numeric(c(rep(0,m1-length(x)),x  res  #    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]

Re: [R] Distance matrices Combinations

2013-04-26 Thread arun
Hi, Do you want this? el- matrix(1:100,ncol=20)  set.seed(25)  el1- matrix(sample(1:100,20,replace=TRUE),ncol=1) indx-sort(el1,index.return=TRUE)$ix[1:3]  list(el[,indx],sort(el1)[1:3]) #[[1]]  #    [,1] [,2] [,3] #[1,]   41   21   11 #[2,]   42   22   12 #[3,]   43   23   13 #[4,]   44   24  

Re: [R] Reading data from a text file conditionally skipping lines

2013-04-26 Thread arun
Hi, It would be better to give an example. If your dataset is like the one attached: con-file(Trial1.txt)  Lines1- readLines(con)  close(con) #If the data you wanted to extract is numeric and the header and footer are characters,

Re: [R] Scheirer-Ray-Hare

2013-04-26 Thread nguyenkinh
You can take a look at this, in Vietnamese but you can Gtranslate it http://www.ytecongcong.com/2013/04/scheirer-ray-hare-test-kiem-dinh-phi-tham-so-two-way-anova/ -- View this message in context: http://r.789695.n4.nabble.com/Scheirer-Ray-Hare-tp3818476p4665439.html Sent from the R help

[R] Looping through names of both dataframes and column-names

2013-04-26 Thread Daniel Egan
Hello all, This seems like a pretty standard question - suppose I want to loop through a set of similar data-frames, with similar variables, and create new variables within them: nl-seq(1,5)for (i in nl) { assign(paste0(df_,nl[i]),data.frame(x=seq(1:10),y=rnorm(10)))} ls()[grep(df_,ls())]

[R] Error installing boss package

2013-04-26 Thread Pramod Anugu
I am trying to install the package boss but i am getting error below: Please advice install.packages(boss) --- Please select a CRAN mirror for use in this session --- CRAN mirror 1: 0-Cloud 2: Argentina (La Plata) 3: Argentina (Mendoza) 4: Australia

Re: [R] Selecting and then joining data blocks

2013-04-26 Thread arun
In addition, If your matrix names do not follow any particular pattern: tiger- matrix(1:20,ncol=5) cat- matrix(21:40,ncol=5)  dog- matrix(41:60,ncol=5)  wolf- matrix(61:80,ncol=5) vec- c(1,2,4,3,2,3,1) vec2- c(tiger,cat,dog,wolf) #Suppose, you wanted the order to be tiger, cat, dog, wolf  vec2-

Re: [R] connecting matrices

2013-04-26 Thread arun
Dear Elisa, Try this: el- matrix(1:100,ncol=20)  set.seed(25)  el1- matrix(sample(1:100,20,replace=TRUE),ncol=1) In the example you showed, there were no column names.   list(el[,sort(el1)[1:3]],sort(el1,index.return=TRUE)$ix[1:3]) #[[1]]  #    [,1] [,2] [,3] #[1,]   31   61   71 #[2,]   32  

Re: [R] connecting matrices

2013-04-26 Thread arun
HI Elisa, I guess there is a mistake. Check whether this is what you wanted. indx-sort(el1,index.return=TRUE)$ix[1:3] list(el[,indx],indx) #[[1]]  #    [,1] [,2] [,3] #[1,]   41   21   11 #[2,]   42   22   12 #[3,]   43   23   13 #[4,]   44   24   14 #[5,]   45   25   15 # #[[2]] #[1] 9 5 3 A.K.

[R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Ravi Varadhan
Hi, I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution that avoids the `for' loops to the following code: n - 1000 Kacmat - matrix(0, n+1, n+1) for (i in 1:n) Kacmat[i, i+1] - n - i + 1 for (i

Re: [R] Make R 3.0 open .RData files

2013-04-26 Thread Indrajit Sen Gupta
Another thing that you can try is changing the Path. Make sure the PATH environment variable has the path to R 3.0 before R 2.15.3 in the string. Regards, Indrajit On Thu, 25 Apr 2013 22:10:52 +0530 wrote a) See FAQ 2.17 b) Methods for configuring operating systems are off topic

[R] time series plot: x-axis problem

2013-04-26 Thread Jerry
Hi, I'm trying to plot a simple time series. I'm running into an issue with x-axis The codes below will produce a plot with correct x-axis showing from Jan to Dec rr=c(3,2,4,5,4,5,3,3,6,2,4,2) (rr=ts(rr,start=c(2012,1),frequency=12)) win.graph(width=6.5, height=2.5,pointsize=8) plot(rr,

[R] Can a column of a list be called?

2013-04-26 Thread Jana Makedonska
Hello Everyone, I would like to know if I can call one of the columns of a list, to use it as a variable in a function. Thanks in advance for any advice! Jana -- Jana Makedonska, B.Sc. Biology, Universite Paul Sabatier Toulouse III M.Sc. Paleontology, Paleobiology and Phylogeny, Universite

Re: [R] nls: example code throws error

2013-04-26 Thread Duncan Mackay
Hi Try x - -(1:100)/10 set.seed(1) y - 100 + 10 * exp(x / 2) + rnorm(x)/10 short cut to starting values lm(log(y) ~-log(x+10)) Call: lm(formula = log(y) ~ -log(x + 10)) Coefficients: (Intercept) 4.624 nlmod - nls(y ~ A + B * exp(C * x), start=list(A=90, B=5,C=0.1)) Formula: y ~ A + B

Re: [R] Looping through names of both dataframes and column-names

2013-04-26 Thread Blaser Nello
Here are two possible ways to do it: This would simplify your code a bit. But it changes the names of x_cs to cs.x. for (df in nls) { assign(df, cbind(get(df), cs=apply(get(df), 2, cumsum))) } This is closer to what you have done. for (df in nls) { print(df) for (var in names(get(df)))

Re: [R] Transferring R to another computer, R_HOME_DIR

2013-04-26 Thread Prof Brian Ripley
This is really an R-devel topic: it is not about using R. R is usually (but not always) built so that everything except Rscript is relocatable by editing the 'R' script (and R_HOME and R_HOME_DIR are ignored in the environment, intentionally). So you could edit the script, but not having

Re: [R] Sum up column values according to row id

2013-04-26 Thread Matteo Mura
Thank you very much Doct. Carlson!!! The function you suggest me wors perfectely!!! Thanks a lot again, Best whishes sincerely Mt M 2013/4/24 David Carlson dcarl...@tamu.edu Something like this? mean6 - function(x) { if (length(x) 6) { mn - mean(x) } else {

[R] Remove reciprocal data from a grouped animal social contact dataset

2013-04-26 Thread Cat Cowie
Hi r-help forum, I have been collecting contact data (with proximity logger collars) between a few different species of animal. All animals wear the collars, and any contact between the animals should be detected and recorded by both collars. However, this isn't always the case and more contacts

Re: [R] time series plot: x-axis problem

2013-04-26 Thread Rui Barradas
Hello, Try the following. (rr=ts(rr,start=c(2012,5),frequency=12)) plot(rr, xlab=2012 - 2013, ylab=event freq, xaxt = n, col=blue) labs - format(as.Date(time(rr)), %b-%Y) axis(1, time(rr), labs, cex.axis = .9, tcl = -.5, las = 2) Hope this helps, Rui Barradas Em 25-04-2013 19:11, Jerry

[R] sample size in box plot labels

2013-04-26 Thread Shane Carey
Hi, I would like to put the sample number beside each lable in a boxplot. How do I do this? Essentially, I need to count the sample size for each factor, see below: Thanks boxplot(DATA$K_Merge~factor(DATA$UnitName_1),axes=FALSE,col=colours) title(main=list(Tukey Boxplot by Geology:\n

Re: [R] Error installing boss package

2013-04-26 Thread Jim Lemon
On 04/25/2013 11:42 PM, Pramod Anugu wrote: I am trying to install the package boss but i am getting error below: Please advice ... checking netcdf.h usability... no checking netcdf.h presence... no checking for netcdf.h... no configure: error: netcdf header netcdf.h not found ERROR:

Re: [R] sample size in box plot labels

2013-04-26 Thread PIKAL Petr
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Shane Carey Sent: Friday, April 26, 2013 11:49 AM To: r-help@r-project.org Subject: [R] sample size in box plot labels Hi, I would like to put the sample number beside

Re: [R] sample size in box plot labels

2013-04-26 Thread Rui Barradas
Hello, To count the sample sizes for each factor try tapply(DATA$K_Merge, DATA$UnitName_1, FUN = length) Hope this helps, Rui Barradas Em 26-04-2013 10:48, Shane Carey escreveu: Hi, I would like to put the sample number beside each lable in a boxplot. How do I do this? Essentially, I need

Re: [R] How to make a raster image in R from my own data set

2013-04-26 Thread Jon Olav Skoien
Hi Kristi, it takes a few extra steps to create a raster layer from your example data set, as it is not a gridded map in Lat lon (probably in some projection though). How exactly to do it depends on your data, but here are some hints: 1. If you actually need to read the data set from a

Re: [R] sample size in box plot labels

2013-04-26 Thread Shane Carey
This works, great. Cheers On Fri, Apr 26, 2013 at 12:02 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, To count the sample sizes for each factor try tapply(DATA$K_Merge, DATA$UnitName_1, FUN = length) Hope this helps, Rui Barradas Em 26-04-2013 10:48, Shane Carey escreveu:

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Berend Hasselman
On 25-04-2013, at 17:18, Ravi Varadhan ravi.varad...@jhu.edu wrote: Hi, I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution that avoids the `for' loops to the following code: n - 1000

Re: [R] nls: example code throws error

2013-04-26 Thread Keith Jewell
On 26/04/2013 00:16, Steven LeBlanc wrote: Greets, I'm trying to learn to use nls and was running the example code for an exponential model: snip Perhaps also, a pointer to a comprehensive and correct document that details model formulae syntax if someone has one? Thanks Best

[R] labeling

2013-04-26 Thread Shane Carey
Hi, I have a dataset as follows: Name N Visean limestone calcareous shale 2 Visean sandstone, mudstone evaporite 2 Westphalian shale, sandstone, siltstone coal How do I combine them so that I can label a plot with Visean limestone calcareous shale

Re: [R] Weighted Principle Components analysis

2013-04-26 Thread Dimitri Liakhovitski
The reason for my asking is because I have to replicate the same analysis done in SPSS and SAS. Again, to make it clear - it's respondent-weighted Factor Analysis with a desired number of factors. Method of extraction: Principal Components. Rotation: Varimax. The only solution I can think of is

Re: [R] Trouble Computing Type III SS in a Cox Regression

2013-04-26 Thread Paul Miller
Sigh. Message: 50 Date: Fri, 26 Apr 2013 10:13:52 +1200 From: Rolf Turner rolf.tur...@xtra.co.nz To: Terry Therneau thern...@mayo.edu Cc: r-help@r-project.org, Achim Zeileis achim.zeil...@uibk.ac.at Subject: Re: [R] Trouble Computing Type III SS in a Cox Regression Message-ID:

Re: [R] Help with dataEllipse function

2013-04-26 Thread John Fox
Dear Jana, The lty argument to dataEllipse() (in the car package) isn't vectorized. It could be, and I'll add that as a feature request. Actually, lty isn't an explicit argument to dataEllipse(); it's simply passed through to the lines() function, which draws the ellipses. You should be able

Re: [R] labeling

2013-04-26 Thread Jim Lemon
On 04/26/2013 10:15 PM, Shane Carey wrote: Hi, I have a dataset as follows: Name N Visean limestone calcareous shale 2 Visean sandstone, mudstone evaporite 2 Westphalian shale, sandstone, siltstone coal How do I combine them so that I can label

Re: [R] csv file with two header rows

2013-04-26 Thread John Kane
I don't think so. read.csv is a striped down version of read.table. You should be able to do this with the skip option there. John Kane Kingston ON Canada -Original Message- From: analys...@hotmail.com Sent: Thu, 25 Apr 2013 18:35:42 -0700 (PDT) To: r-help@r-project.org Subject:

Re: [R] Can a column of a list be called?

2013-04-26 Thread Charles Determan Jr
If you are using the list as simply a collection of data frames a simple example to accomplish what you are describing is this: data(iris) data(mtcars) y=list(iris, mtcars) #return Sepal.Length column from first data frame in list #list[[number of list component]][number of column] y[[1]][1]

[R] How to export graph value in R

2013-04-26 Thread Anup khanal
Dear exports,I have created a hypsometric curve (area-elevation curve) for my watershed by using simple command hypsometric(X,main=Hypsometric Curve, xlab=Relative Area above Elevation, (a/A),ylab=Relative Elevation, (h/H), col=blue)It plots the hypsometric curve in

[R] Splitting data.frame and saving to csv files

2013-04-26 Thread Katherine Gobin
Dear R Forum, I have a data.frame as df = data.frame(date = c(2013-04-15, 2013-04-14, 2013-04-13, 2013-04-12, 2013-04-11), ABC_f = c(62.80739769,81.04525895,84.65712455,12.78237251,57.61345256), LMN_d = c(21.16794336,54.6580401,63.8923307,87.59880367,87.07693716), XYZ_p =

Re: [R] Help with dataEllipse function

2013-04-26 Thread Michael Friendly
On 4/25/2013 8:00 PM, Jana Makedonska wrote: Hi Everyone, I am working with the R function dataEllipse. I plot the 95% confidence ellipses for several different samples in the same plot and I color-code the ellipse of each sample, but I do not know how to specify a different line pattern for

Re: [R] sample size in box plot labels

2013-04-26 Thread PIKAL Petr
Hi actually it shall be the same result as table(DATA$UnitName_1) Both approaches does not work if there are NAs in your data. tapply(DATA$K_Merge, DATA$UnitName_1, FUN = function(x) sum(!is.na(x))) consideres also NA values. Regards Petr ---Original Message- From:

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Enrico Schumann
On Thu, 25 Apr 2013, Ravi Varadhan ravi.varad...@jhu.edu writes: Hi, I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution that avoids the `for' loops to the following code: n - 1000 Kacmat -

Re: [R] Trouble Computing Type III SS in a Cox Regression

2013-04-26 Thread John Kane
Seconded John Kane Kingston ON Canada -Original Message- From: rolf.tur...@xtra.co.nz Sent: Fri, 26 Apr 2013 10:13:52 +1200 To: thern...@mayo.edu Subject: Re: [R] Trouble Computing Type III SS in a Cox Regression On 26/04/13 03:40, Terry Therneau wrote: (In response to a

Re: [R] Can a column of a list be called?

2013-04-26 Thread Bert Gunter
Please read An Introduction to R or other basic R tutorial to learn basic R operations before posting. Please read the posting guide (link at bottom) or other similar online guides for how to post a coherent question that will elicit an accurate and helpful answer. -- Bert On Thu, Apr 25, 2013

Re: [R] Splitting data.frame and saving to csv files

2013-04-26 Thread Bert Gunter
Hint: nm - substring(names(df). 1,3) gives the first 3 letters of the names, assuming this is the info needed for classifying the names -- you were not explicit about this. If some sort of pattern is used, ?grep may be what you need. You can then pick columns from df by e.g. loopingt through

Re: [R] Remove reciprocal data from a grouped animal social contact dataset

2013-04-26 Thread Adams, Jean
Cat, It seems risky to me to assume that one collar is always outperforming another one. I would think there would be some cases where one collar picked up on a contact that the other one missed AND that the other picked up on a contact that the one missed. If so, it may be best to keep all of

[R] Stepwise regression for multivariate case in R?

2013-04-26 Thread Jonathan Jansson
Hi! I am trying to make a stepwise regression in the multivariate case, using Wilks' Lambda test. I've tried this: greedy.wilks(cbind(Y1,Y2) ~ . , data=my.data ) But it only returns: Error in model.frame.default(formula = X[, j] ~ grouping, drop.unused.levels = TRUE) : variable lengths

Re: [R] Remove reciprocal data from a grouped animal social contact dataset

2013-04-26 Thread skywalker atl
Hi See https://github.com/hongqin/RCompBio/blob/master/48states/48states-permutation-igraph.r and http://www.youtube.com/watch?v=GE2l3LYDQG0 Hope they are useful, Hong Qin On Fri, Apr 26, 2013 at 5:08 AM, Cat Cowie cat.e.co...@gmail.com wrote: Hi r-help forum, I have been collecting

Re: [R] Looping through names of both dataframes and column-names

2013-04-26 Thread Daniel Egan
Much thanks Blaser. That worked perfectly. This will improve my code considerably. Greatly appreciated. Regards, Dan On Fri, Apr 26, 2013 at 3:48 AM, Blaser Nello nbla...@ispm.unibe.ch wrote: Here are two possible ways to do it: This would simplify your code a bit. But it changes the names

Re: [R] time series plot: x-axis problem

2013-04-26 Thread arun
Hi, labs - format(as.Date(time(rr)), %b-%Y) #Error in as.Date.default(time(rr)) :  # do not know how to convert 'time(rr)' to class “Date” #I guess this needs library(zoo) library(zoo)  labs - format(as.Date(time(rr)), %b-%Y) sessionInfo() R version 3.0.0 (2013-04-03) Platform:

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Berend Hasselman
On 26-04-2013, at 14:42, Enrico Schumann e...@enricoschumann.net wrote: On Thu, 25 Apr 2013, Ravi Varadhan ravi.varad...@jhu.edu writes: Hi, I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution

Re: [R] nls: example code throws error

2013-04-26 Thread Ben Bolker
Keith Jewell k.jewell at campden.co.uk writes: Others have pointed out that the error is probably from an unclean environment. Completely OT, but an unclean environment sounds sort of scary to me. Like it contains zombies or something. I don't know a better, short way to express the idea

Re: [R] Weighted Principle Components analysis

2013-04-26 Thread David Carlson
When you run an unweighted analysis on all three systems, do the scores agree? I would have expected that replicating the observations would give you similar results. You might be able to run the weighted analysis using princomp() instead of principal since you can supply data and a covariance

Re: [R] nls: example code throws error

2013-04-26 Thread Duncan Murdoch
On 13-04-26 10:14 AM, Ben Bolker wrote: Keith Jewell k.jewell at campden.co.uk writes: Others have pointed out that the error is probably from an unclean environment. Completely OT, but an unclean environment sounds sort of scary to me. Like it contains zombies or something. Isn't that

Re: [R] Print occurrence / positions of words

2013-04-26 Thread S Ellison
I have tried some different packages in order to build a R program which will take as input a text file, produce a list of the words inside that file. Each word should have a vector with all the places that this word exist in the file. How about txt - paste(rep(this is a nice text with

Re: [R] time series plot: x-axis problem

2013-04-26 Thread Rui Barradas
Hello, Em 26-04-2013 14:30, arun escreveu: Hi, labs - format(as.Date(time(rr)), %b-%Y) #Error in as.Date.default(time(rr)) : # do not know how to convert 'time(rr)' to class “Date” #I guess this needs library(zoo) You're right, I forgot because it was already loaded prior to running

Re: [R] the joy of spreadsheets (off-topic)

2013-04-26 Thread S Ellison
One might wonder if the Excel error was indeed THAT or perhaps a way to get the desired results, give the other issues in their analysis? The prior for the incompetence/malice question is usually best set pretty heavily in favour of incompetence ... S

Re: [R] the joy of spreadsheets (off-topic)

2013-04-26 Thread William Dunlap
The prior for the incompetence/malice question is usually best set pretty heavily in favour of incompetence ... The following comment on economic research is from a 2010 article in the Atlantic reviewing John Ioannidis' work.

Re: [R] the joy of spreadsheets (off-topic)

2013-04-26 Thread John Kane
From a quick read, the Excel error prior for incompetence looks high but some of the other issues hint that the prior for the overall findings was remarkably in favor of malice. John Kane Kingston ON Canada -Original Message- From: s.elli...@lgcgroup.com Sent: Fri, 26 Apr 2013

Re: [R] the joy of spreadsheets (off-topic)

2013-04-26 Thread S Ellison
From a quick read, the Excel error prior for incompetence looks high but some of the other issues hint that the prior for the overall findings was remarkably in favor of malice. That's p(malice|evidence), not p(malice); surely that must be the posterior? ;-) 'tain't a great advert for

Re: [R] Decomposing a List

2013-04-26 Thread William Dunlap
You might add vapply() to you repertoire, as it is quicker than sapply but also does some error checking on the your input data. E.g., your f2 returns a matrix whose columns are the elements of the list l and you assume that there each element of l contains 2 character strings. f2 -

Re: [R] Stepwise regression for multivariate case in R?

2013-04-26 Thread Frank Harrell
Since stepwise methods do not work as advertised in the univariate case I'm wondering why they should work in the multivariate case. Frank Jonathan Jansson wrote Hi! I am trying to make a stepwise regression in the multivariate case, using Wilks' Lambda test. I've tried this:

[R] NMDS in Vegan: problems in stressplot, best solution

2013-04-26 Thread Kumar Mainali
Hello, I can draw a basic stress plot for NMDS with the following code in package Vegan. stressplot(parth.mds, parth.dis) When I try to specify the line and point types, it gives me error message. stressplot(parth.mds, parth.dis, pch=1, p.col=gray, lwd=2, l.col=red) Error in plot.xy(xy, type,

[R] Read big data (3G ) methods ?

2013-04-26 Thread Kevin Hao
Hi all scientists, Recently, I am dealing with big data ( 3G txt or csv format ) in my desktop (windows 7 - 64 bit version), but I can not read them faster, thought I search from internet. [define colClasses for read.table, cobycol and limma packages I have use them, but it is not so fast].

Re: [R] Splitting data.frame and saving to csv files

2013-04-26 Thread arun
Hi, You can do this:   lst1-lapply(split(colnames(df)[-1],gsub(_.*,,colnames(df)[-1])),function(x) {x1-cbind(date=df[,1],df[,x]);colnames(x1)[-1]- x;x1})  lst1 #$ABC  #   date    ABC_f    ABC_e    ABC_d    ABC_m #1 2013-04-15 62.80740 11.36784 38.71090 40.28474 #2 2013-04-14 81.04526

Re: [R] Splitting data.frame and saving to csv files

2013-04-26 Thread arun
Hi, Just noticed a mistake: lst1 should be: lst1-lapply(split(colnames(df)[-1],gsub(_.*,,colnames(df)[-1])),function(x) {x1-cbind(date=df[,1],df[,x]); cbind(date=df[,1],df[x])})  lst1 #$ABC  #   date    ABC_f    ABC_e    ABC_d    ABC_m #1 2013-04-15 62.80740 11.36784 38.71090 40.28474 #2

[R] speed of a vector operation question

2013-04-26 Thread Mikhail Umorin
Hello, I am dealing with numeric vectors 10^5 to 10^6 elements long. The values are sorted (with duplicates) in the vector (v). I am obtaining the length of vectors such as (v c) or (v c1 v c2), where c, c1, c2 are some scalar variables. What is the most efficient way to do this? I am

[R] converting character matrix to POSIXct matrix

2013-04-26 Thread hh wt
I thought this is a common question but rseek/google searches don't yield any relevant hit. I have a matrix of character strings, which are time stamps, time.m[1:5,1:5] [,1] [,2] [,3] [,4] [,5] [1,] 08:00:20.799 08:00:20.799 08:00:20.799

[R] Questions about out-of-sample forecast using random walk

2013-04-26 Thread Wandi Zhou
Hi there, I'm a bit confused about which command should I use when performing an out-of-sample forecast using random walk. I have som time sereis data from 1957Q1 to 2011Q4, I want to use a fraction of data from 1960Q1 to 1984Q4 to forecast data from 1985Q1 onwards using random walk model

[R] Help with merge function

2013-04-26 Thread Catarina Ferreira
Dear all, I'm trying to merge 2 dataframes, but I'm not being entirely successful and I can't understand why. Dataframe x1 State_prov Shape_name bob2009 bob 2010 bob2011 Nova ScotiaAnnapolis 0 0 1 Nova ScotiaAntigonish0

Re: [R] Error Installing packages

2013-04-26 Thread Pramod Anugu
I am trying to install the package boss but i am getting error below: Please advice install.packages(boss) --- Please select a CRAN mirror for use in this session --- CRAN mirror 1: 0-Cloud 2: Argentina (La Plata) 3: Argentina (Mendoza) 4: Australia

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Ye Lin
Have you think of build a database then then let R read it thru that db instead of your desktop? On Fri, Apr 26, 2013 at 8:09 AM, Kevin Hao rfans4ch...@gmail.com wrote: Hi all scientists, Recently, I am dealing with big data ( 3G txt or csv format ) in my desktop (windows 7 - 64 bit

Re: [R] C50 package in R

2013-04-26 Thread Max Kuhn
There isn't much out there. Quinlan didn't open source the code until about a year ago. I've been through the code line by line and we have a fairly descriptive summary of the model in our book (that's almost out): http://appliedpredictivemodeling.com/ I will say that the pruning is mostly

Re: [R] Help with merge function

2013-04-26 Thread Rui Barradas
Hello, The following seems to do the trick. x1 - structure(list(State_prov = c(Nova Scotia, Nova Scotia, Nova Scotia ), Shape_name = c(Annapolis, Antigonish, Gly), bob2009 = c(0L, 0L, NA), bob2010 = c(0L, 0L, NA), bob2011 = c(1L, 0L, NA)), .Names = c(State_prov, Shape_name, bob2009, bob2010,

Re: [R] converting character matrix to POSIXct matrix

2013-04-26 Thread Rui Barradas
Hello, Use sapply instead. Hope this helps, Rui Barradas Em 26-04-2013 18:51, hh wt escreveu: I thought this is a common question but rseek/google searches don't yield any relevant hit. I have a matrix of character strings, which are time stamps, time.m[1:5,1:5] [,1]

[R] Stratified Random Sampling Proportional to Size

2013-04-26 Thread Lopez, Dan
Hello R Experts, I kindly request your assistance on figuring out how to get a stratified random sampling proportional to 100. Below is my r code showing what I did and the error I'm getting with sampling::strata # FIRST I summarized count of records by the two variables I want to use as

Re: [R] How to export graph value in R

2013-04-26 Thread Thomas Adams
Anup, You should have provided some additional information, such as that the function 'hypsometric' is found in the hydroTSM contributed package. Nevertheless, here's what I did (maybe not elegant, but it works) : (1) at the R command prompt simply type hypsometric -- the source code for the

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread lcn
Do you really have the need loading all the data into memory? Mostly for large data set, people would just read a chunk of it for developing analysis pipeline, and when that's done, the ready script would just iterate through the entire data set. For example, the read.table function has 'nrow'

Re: [R] [newbie] how to find and combine geographic maps with particular features?

2013-04-26 Thread MacQueen, Don
If someone else hasn't suggested it already, you will probably get more/better help on the R-sig-geo mailing list. (if you decide to repost there, just mention up front that it's a repost and why) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA

Re: [R] speed of a vector operation question

2013-04-26 Thread lcn
I think the sum way is the best. On Fri, Apr 26, 2013 at 9:12 AM, Mikhail Umorin mike...@gmail.com wrote: Hello, I am dealing with numeric vectors 10^5 to 10^6 elements long. The values are sorted (with duplicates) in the vector (v). I am obtaining the length of vectors such as (v c) or

[R] Regression coefficients

2013-04-26 Thread Preetam Pal
Hi all, I have run a ridge regression as follows: reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$g+final$u, lambda=seq(0,10,0.01)) Then I enter : select(reg) and it returns: modified HKB estimator is 19.3409 modified L-W estimator is 36.18617

Re: [R] NMDS in Vegan: problems in stressplot, best solution

2013-04-26 Thread Gavin Simpson
On Fri, 2013-04-26 at 12:42 -0500, Kumar Mainali wrote: Hello, I can draw a basic stress plot for NMDS with the following code in package Vegan. stressplot(parth.mds, parth.dis) When I try to specify the line and point types, it gives me error message. stressplot(parth.mds, parth.dis,

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Martin Morgan
On 04/26/2013 08:09 AM, Kevin Hao wrote: Hi all scientists, Recently, I am dealing with big data ( 3G txt or csv format ) in my desktop (windows 7 - 64 bit version), but I can not read them faster, thought I search from internet. [define colClasses for read.table, cobycol and limma packages I

Re: [R] speed of a vector operation question

2013-04-26 Thread William Dunlap
I think the sum way is the best. On my Linux machine running R-3.0.0 the sum way is slightly faster: x - rexp(1e6, 2) system.time(for(i in 1:100)sum(x.3 x.5)) user system elapsed 4.664 0.340 5.018 system.time(for(i in 1:100)length(which(x.3 x.5))) user system

Re: [R] speed of a vector operation question

2013-04-26 Thread Martin Morgan
A very similar question was asked on StackOverflow (by Mikhail? and then I guess the answers there were somehow not satisfactory...) http://stackoverflow.com/questions/16213029/more-efficient-strategy-for-which-or-match where it turns out that a binary search (implemented in R) on the sorted

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Ye Lin
I can not think of sth better. Maybe try read part of the data that you want to analyze, basically break the large data set into pieces. On Fri, Apr 26, 2013 at 10:58 AM, Ye Lin ye...@lbl.gov wrote: Have you think of build a database then then let R read it thru that db instead of your

Re: [R] speed of a vector operation question

2013-04-26 Thread William Dunlap
R's findInterval can also take advantage of a sorted x vector. E.g., in R-3.0.0 on the same 8-core Linux box: x - rexp(1e6, 2) system.time(for(i in 1:100)tabulate(findInterval(x, c(-Inf, .3, .5, Inf)))[2]) user system elapsed 2.444 0.000 2.446 xs - sort(x) system.time(for(i in

Re: [R] Help with merge function

2013-04-26 Thread Catarina Ferreira
Hello, Thank you for your help. However the dataframes I gave you were only examples, the actual dataframes are very big. Does this mean I have to write every range of data for each variable?? On Fri, Apr 26, 2013 at 2:25 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, The following

Re: [R] Help with merge function

2013-04-26 Thread arun
Hi, The format is bit messed up.  So, not sure this is what you wanted. x1- read.table(text=State_prov,Shape_name,bob2009,bob2010,bob2011 Nova Scotia,Annapolis,0,0,1 Nova Scotia,Antigonish,0,0,0 Nova Scotia,Gly,NA,NA,NA ,sep=,,header=TRUE,stringsAsFactors=FALSE) x2- read.table(text=

[R] example

2013-04-26 Thread Iut Tri Utami
Dear Sir, My name is Iut Tri Utami. i am beginning user. I have a problem about generate data in R. It consists of one disk generated by a Gaussian N(0, 0.167) and one ring generated by a Gaussian N(R, 0.1). The mean R was generated from its polar coordinates. The angle was drawn from a uniform

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Kevin Hao
Thanks lcn, I will try to read data from different chunks. Best, Kevin On Fri, Apr 26, 2013 at 3:05 PM, lcn lcn...@gmail.com wrote: Do you really have the need loading all the data into memory? Mostly for large data set, people would just read a chunk of it for developing analysis

Re: [R] Help with merge function

2013-04-26 Thread Rui Barradas
Hello, I don't understand the question, what range? I've just changed the 'all' argument to 'all.y', without doing anything special to the variables. Can you explain what you mean? Rui Barradas Em 26-04-2013 19:30, Catarina Ferreira escreveu: Hello, Thank you for your help. However the

Re: [R] converting character matrix to POSIXct matrix

2013-04-26 Thread arun
time.m- as.matrix(read.table(text=' 08:00:20.799 08:00:20.799 08:00:20.799 08:00:20.799 08:00:20.799 08:00:21.996 08:00:22.071 08:00:23.821 08:00:24.370 08:00:25.573 08:00:29.200 08:00:29.200 08:00:29.591 08:00:30.368 08:00:30.536 08:00:31.073 08:00:31.372 08:00:31.384 08:00:31.403 08:00:31.867

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Kevin Hao
Thanks. I will try break into pieces to analysis. Kevin On Fri, Apr 26, 2013 at 4:38 PM, Ye Lin ye...@lbl.gov wrote: I can not think of sth better. Maybe try read part of the data that you want to analyze, basically break the large data set into pieces. On Fri, Apr 26, 2013 at 10:58 AM,

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Ravi Varadhan
Thank you, Berend and Enrico, for looking into this. I did not think of Enrico's clever use of cbind() to form the subsetting indices. Best, Ravi From: Berend Hasselman [b...@xs4all.nl] Sent: Friday, April 26, 2013 10:08 AM To: Enrico Schumann Cc: Ravi

Re: [R] Help with merge function

2013-04-26 Thread arun
Hi, From the output you wanted, it looks like: library(plyr) join(x1,x2,type=right) #Joining by: State_prov, Shape_name, bob2009, bob2010  #  State_prov Shape_name bob2009 bob2010 bob2011 FID coy2009 #1 Nova Scotia  Annapolis   0   0   1   0  10 #2 Nova Scotia Antigonish   0

Re: [R] Read big data (3G ) methods ?

2013-04-26 Thread Kevin Hao
Hi Ye, Thanks. That is a good method. have any other methods instead of using database? kevin On Fri, Apr 26, 2013 at 1:58 PM, Ye Lin ye...@lbl.gov wrote: Have you think of build a database then then let R read it thru that db instead of your desktop? On Fri, Apr 26, 2013 at 8:09 AM,

Re: [R] Help with merge function

2013-04-26 Thread arun
Hi, Check whether this works. Lines1-readLines(NS_update.txt) x1-read.table(text=gsub('\',,Lines1),sep=,,header=TRUE,stringsAsFactors=FALSE)  x2- read.table(data.txt,sep=,header=TRUE,stringsAsFactors=FALSE,fill=TRUE)  dim(x2) #[1] 34577   189 library(plyr)  res- join(x1,x2,type=right) #Joining

  1   2   >