[R] Extracting only multiple occurrences

2013-08-08 Thread Kevin Parent
Hoping someone here can help me with this small problem. set.seed(2013) x-sort(c(letters,letters[sample(26,10,1)])) This gives a vector of 36 letters with some muliples (in this case, g,m,s,t,u,v,x,y). Now what I need is to get rid of the ones that only occur once and keep the multiples. I

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread David Winsemius
On Aug 7, 2013, at 10:37 PM, Kevin Parent wrote: Hoping someone here can help me with this small problem. set.seed(2013) x-sort(c(letters,letters[sample(26,10,1)])) This gives a vector of 36 letters with some muliples (in this case, g,m,s,t,u,v,x,y). Now what I need is to get rid of

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread David Winsemius
On Aug 7, 2013, at 11:03 PM, David Winsemius wrote: On Aug 7, 2013, at 10:37 PM, Kevin Parent wrote: Hoping someone here can help me with this small problem. set.seed(2013) x-sort(c(letters,letters[sample(26,10,1)])) This gives a vector of 36 letters with some muliples (in this

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Kevin Parent
Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need the original ones too. So the result I want is: [g,g,m,m,s,s,t,t,u,u,u,v,v,x,x,y,y,y]. What duplicated() gives me is [g,m,s,t,u,u,v,x,y,y]   Playing around

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread David Winsemius
On Aug 7, 2013, at 11:23 PM, Kevin Parent wrote: Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need the original ones too. So the result I want is: [g,g,m,m,s,s,t,t,u,u,u,v,v,x,x,y,y,y]. What

Re: [R] How is a file descriptor stored ?

2013-08-08 Thread mohan . radhakrishnan
Hi, The file handling code sometimes throws this exception. Error in UseMethod(close) : no applicable method for 'close' applied to an object of class c ('integer', 'numeric') Is there a sample based on my code that I can test ? I want to extract the file descriptors from the hashmap and

Re: [R] Running time complexity of Seasonal ARIMA model (forecast package)

2013-08-08 Thread Prof Brian Ripley
On 08/08/2013 05:08, Mohit Dhingra wrote: *Dear All,* I am using Seasonal ARIMA model for predicting cloud workloads. I want to know the running time complexity of building model by the algorithm implemented in R (I am not sure, is it Yule-Walker?). I want to know if it It is not Yule-Walker

[R] diallel analysis question

2013-08-08 Thread waqas shafqat
plz solve this question and send me commands.. this is a question for diallel analysis.. thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] laf_open_fwf

2013-08-08 Thread christian.kamenik
Dear Jan Many thanks for your help. In fact, all lines are shorter than my column width... my.column.widths: 238 range(nchar(lines)):235 237 So, it seems I have an inconsistent file structure... I guess there is no way to handle this in an automated way? Best Regard Christian

[R] Upgrading to R and keeping packages

2013-08-08 Thread Pancho Mulongeni
Hi! I just installed the latest R 3.01. I then wanted to update my packages. I believe the advice given is to take the library folder from the old R version and copy it on top of (overwrite) the library folder of the new R version, in my case the library of R 2.15.2 to library of R 3.01. When I

[R] Problem with na.action within own function

2013-08-08 Thread ivan
Dear R Community, I am trying to build a very simple function which uses lm and coeftest to return a coefficient matrix with heteroskedasticity robust standard errors. The function is the following: reg=function(formula,data,na.action){ res=lm(formula=formula,data=data,na.action=na.action)

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Jim Lemon
On 08/08/2013 04:23 PM, Kevin Parent wrote: Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need the original ones too. So the result I want is: [g,g,m,m,s,s,t,t,u,u,u,v,v,x,x,y,y,y]. What duplicated() gives

Re: [R] Upgrading to R and keeping packages

2013-08-08 Thread Prof Brian Ripley
On 08/08/2013 09:07, Pancho Mulongeni wrote: Hi! I just installed the latest R 3.01. I then wanted to update my packages. I believe the advice given is to take the library folder from the old R version and copy it on top of (overwrite) the library folder of the new R version, in my case the

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Berend Hasselman
On 08-08-2013, at 10:27, Jim Lemon j...@bitwrit.com.au wrote: On 08/08/2013 04:23 PM, Kevin Parent wrote: Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need the original ones too. So the result I want is:

[R] Numercial evaluation of intgral with different bounds

2013-08-08 Thread Carlos Nasher
Hello R helpers, I'm struggling how to apply the integrate function to a data frame. Here is an example of what I'm trying to do: # Create data frame x - 0:4 tx - 10:14 T - 12:16 data - data.frame(x=x, tx=tx, T=T) # Parameter alpha - 10 beta - 11 # Integral integrand - function(y){

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Jim Lemon
On 08/08/2013 06:52 PM, Berend Hasselman wrote: On 08-08-2013, at 10:27, Jim Lemonj...@bitwrit.com.au wrote: On 08/08/2013 04:23 PM, Kevin Parent wrote: Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Rolf Turner
On 08/08/13 20:27, Jim Lemon wrote: On 08/08/2013 04:23 PM, Kevin Parent wrote: Well that almost works, and I didn't know about duplicated() so thanks for that. However, it only gives me the duplicated values. I need the original ones too. So the result I want is:

[R] gnls() and L-BFGS-B in library(nlme)

2013-08-08 Thread Philipp Grueber
Dear R Users, I attempt to estimate a generalized nonlinear least squares model using gnls() from the nlme library. I wish to restrict some of my parameters using the L-BFGS-B method for the optim optimizer. However, in contrast to nls() in the same package, gnls() does not accept any `lower' or

Re: [R] Running time complexity of Seasonal ARIMA model (forecast package)

2013-08-08 Thread Mohit Dhingra
*Dear Sir,* Thanks for your response. Here, I was using 'n' to denote the input size (no. of points in time series using which I am building a Seasonal ARIMA model). I can check the running time myself and I have done that as well (it takes some 1-2 minutes for 50 iterations for my input size),

Re: [R] laf_open_fwf

2013-08-08 Thread Jan van der Laan
Without example data it is difficult to give suggestions on how you might read this file. Are you sure your file is fixed width? Sometimes columns are neatly aligned using whitespace (tabs/spaces). In that case you could use read.table with the default settings. Another possibility

[R] Lack of catalog number referencing for statistical objects

2013-08-08 Thread Jose Iparraguirre
Hi, In Skew-t fits to mortality data - can a Gaussian-related distribution replace the Gompertz-Makeham as the basis for mortality studies? (J Gerontol A Biol Sci Med Sci 2013 August ;68(8):903-913; doi:10.1093/Gerona/gls239) Clark et al compares the fit of several distributions to mortality

Re: [R] Problem with na.action within own function

2013-08-08 Thread ivan
I found the solution. coeftest does not work with na.exclude but with na.omit only, i.e. one needs to omit missing values from the residual matrix. Cheers! On Thu, Aug 8, 2013 at 10:19 AM, ivan i.pet...@gmail.com wrote: Dear R Community, I am trying to build a very simple function which

Re: [R] p values for partial correlations

2013-08-08 Thread Demetrio Luis Guadagnin
Dear Tal: Thank you for your help. Thats what I run: install.packages(corpcor) require(corpcor) correlations=cor(mydata) pcorrrel = cor2pcor(correlations); pcorrrel 2013/8/7 Tal Galili tal.gal...@gmail.com A short self contained code would help us help you. You can try using str on

[R] [R-pkgs] New package about migration indices

2013-08-08 Thread Gergely Daróczi
Dear useRs, me and my colleague (cc) have recently released a new package on CRAN about computing various migration indices like the Crude Migration Rate, the Effectiveness and Connectivity Index, different Gini indices or the Coefficient of Variation. I hope that some of you dealing with

[R] Add column to dataframe based on code in other column

2013-08-08 Thread Dark
Hi all, I have a dataframe of users which contain US-state codes. Now I want to add a column named REGION based on the state code. I have already done a mapping: NorthEast - c(07, 20, 22, 30, 31, 33, 39, 41, 47) MidWest - c(14, 15, 16, 17, 23, 24, 26, 28, 35, 36, 43, 52) South - c(01, 04, 08,

[R] Explaining variance in a univariate time series

2013-08-08 Thread john rre
Dear List, I am looking to reveal the combination of environmental factors that bets explain the observed variance in a uni-variate time series of a population. I have approached this using two methods, and have different results, therefore i was hoping somebody may have done something

[R] Varying statistical significance in estimates of linear model

2013-08-08 Thread Stathis Kamperis
Hi everyone, I have a response variable 'y' and several predictor variables 'x_i'. I start with a linear model: m1 - lm(y ~ x1); summary(m1) and I get a statistically significant estimate for 'x1'. Then, I modify my model as: m2 - lm(y ~ x1 + x2); summary(m2) At this moment, the estimate for

Re: [R] Varying statistical significance in estimates of linear model

2013-08-08 Thread ONKELINX, Thierry
Dear Stathis, I recommend that you try to get some advice from a local statistician or read an introductory book on statistics. This kind of question is beyond the scope of a mailing list. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for

Re: [R] Varying statistical significance in estimates of linear model

2013-08-08 Thread Bert Gunter
Stathis: 1. This has nothing to do with R. Post on a statistics list, like stats.stackexchange.com 2. Read a basic regression/linear models text. You need to educate yourself. -- Bert On Thu, Aug 8, 2013 at 3:43 AM, Stathis Kamperis ekamp...@gmail.com wrote: Hi everyone, I have a response

Re: [R] Add column to dataframe based on code in other column

2013-08-08 Thread Berend Hasselman
On 08-08-2013, at 11:33, Dark i...@software-solutions.nl wrote: Hi all, I have a dataframe of users which contain US-state codes. Now I want to add a column named REGION based on the state code. I have already done a mapping: NorthEast - c(07, 20, 22, 30, 31, 33, 39, 41, 47) MidWest -

[R] Revolutions blog roundup: July 2013

2013-08-08 Thread David Smith
Revolution Analytics staff write about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles related to R from

[R] Reason for difference in singular value decomposition produced by function La.svd (via prcomp)?

2013-08-08 Thread Ulrike Grömping
Dear expeRts, I have run some simulations under R 2.15.1 on a Mac, and I have rerun a sample of them under R 3.0.1 on Windows (and also for comparison under R2.14.1 on Windows). For most cases, I get exactly the same results in all three runs. However, for those cases that depend on principal

[R] Mac Os X 10.6.8, R and edit/vi

2013-08-08 Thread David Epstein
I tried using various versions of the 'edit' command. Here is an account of how this failed. I hope I have included all relevant information. I haven't used R for a couple of years. Before restarting with R, I downloaded the latest version I could find in its binary version, and installed it

Re: [R] Problem with dea.boot under R 3.0.1

2013-08-08 Thread greatest.possible.newbie
Dear Vera, I had a similar problem once and as far as I can remember the reason were some negative inputs or outputs. # Check for negative values x1a.neg - apply(x1a, 1, function(x) any(x0)) y1.neg - apply(y1, 1, function(x) any(x0)) exclude - x1a.neg | y1.neg # Exclude negative rows x1a.neg -

Re: [R] Add column to dataframe based on code in other column

2013-08-08 Thread Bert Gunter
Dark: 1. In future, please use dput() to post data to enable us to more easily read them from your email. 2. As Berend demonstrates, using a more appropriate data structure is what's required. Here is a slightly shorter, but perhaps trickier alternative to his solution: df ## Your example

Re: [R] How is a file descriptor stored ?

2013-08-08 Thread William Dunlap
I cannot reproduce your problem. You will have to give more details. (I assume you have already made the suggested changes to your code - either label the 3rd argument to your assign call 'envir=' or use the syntax 'cpufile[[key]] - value' instead of assign.) To start debugging this, have your

Re: [R] Add column to dataframe based on code in other column

2013-08-08 Thread arun
dat1- read.table(text= Name    State_Code Tom  20 Harry    56 Ben    05 Sally  04 ,sep=,header=TRUE,stringsAsFactors=FALSE) dat2- do.call(cbind,list(NorthEast,MidWest,South,West,Other))  colnames(dat2)- c(NorthEast,MidWest,South,West,Other)  dat2- as.data.frame(dat2)

Re: [R] cbind with headers

2013-08-08 Thread arun
Hi, You can save it in file.  I copy and paste: Subtype,Gender,Expression A,m,-0.54 A,f,-0.8 B,f,-1.03 C,m,-0.41 on the gedit and save it as data1.csv.  You might be able to do the same with notepad. x - read.csv(data1.csv,header=T,sep=,) x2 - read.csv(data2N.csv,header=T,sep=,) x3 -

[R] Why is mclappy slower than apply in this case?

2013-08-08 Thread Tomas Reigl
Hello, i'm pretty confused. I want to speed up my algorithm by using mclapply: parallel, but when I compare time efficiency, apply still wins. I'm smoothing log2ratio data by rq.fit.fnb:quantreg which is called by my function quantsm and I'm wrapping my data into matrix/list for apply/lapply

[R] mgcv predict.bam strange results

2013-08-08 Thread fwickler
Dear useR, I don't understand the results of the predict.bam function of mgcv package when constucting a varying-coefficient model with bam instead of gam: library(mgcv) dat - gamSim(4) b - gam(y ~ fac+s(x2,by=fac)+s(x0), data=dat) predict(b, dat[1,], type = terms) with gam everything is fine:

[R] cbind with headers

2013-08-08 Thread Docbanks84
Hi, I can't seem to get this to work: http://www.endmemo.com/program/R/cbind.php Do I save the data as data1.csv in note pad and pull in the file? Do I type data1.csv-Subtype,Gender,Expression,A,m,-0.54,A,f,-0.8,B,f,-1.03,C,m,-0.41?? I can do a simple matrix. But, I want to have headers and

[R] For loop output

2013-08-08 Thread Jenny Williams
I am having difficulty storing the output of a for loop I have generated. All I want to do is find all the files that I have, create a string with all of the names in quotes and separated by commas. This is proving more difficult than I initially anticipated. I am sure it is either very simple

Re: [R] For loop output

2013-08-08 Thread Charles Determan Jr
Hi Jenny, Firstly, to my knowledge you cannot assign the output of cat to an object (i.e. it only prints it). Second, you can just add the 'collapse' option of the paste function. individual.proj.quote - paste(individual.proj, collapse = ,) if you really want the quotes individual.proj.quote -

Re: [R] For loop output

2013-08-08 Thread Jan Kim
On Thu, Aug 08, 2013 at 04:05:57PM +0100, Jenny Williams wrote: I am having difficulty storing the output of a for loop I have generated. All I want to do is find all the files that I have, create a string with all of the names in quotes and separated by commas. This is proving more difficult

Re: [R] Why is mclappy slower than apply in this case?

2013-08-08 Thread Bert Gunter
Tomas: Do some reading on parallelization. Parallelizing code requires the overhead of setting up, keeping track of, synching the separate threads. Whether that overhead is worth the cost depends on the problem,the size, the algorithms, the machines/hardware,... Cheers, Bert On Thu, Aug 8,

Re: [R] For loop output

2013-08-08 Thread Jan Kim
On Thu, Aug 08, 2013 at 11:38:33AM -0500, Charles Determan Jr wrote: Hi Jenny, Firstly, to my knowledge you cannot assign the output of cat to an object (i.e. it only prints it). Second, you can just add the 'collapse' option of the paste function. individual.proj.quote -

Re: [R] For loop output

2013-08-08 Thread David Carlson
It's not clear how you are planning to use this within R, but you don't need a loop. individual.proj.quote - capture.output(write.table(matrix(individual.proj, 1), quote=TRUE, sep=,, row.names=FALSE, col.names=FALSE)) This produces a single character string which consists of the quoted file

[R] [R-pkgs] WriteXLS version 3.2.1 - Bug Fix Release

2013-08-08 Thread Marc Schwartz
Hi all, WriteXLS version 3.2.1 has been submitted to CRAN, with thanks to the CRAN maintainers. This is a bug fix release with the following fixes: 1. When row.names = TRUE, the initial comments row, which contains the comments attributes for the data frame columns and is rbind()ed to the

[R] matrix with standard errors of lm model

2013-08-08 Thread iza.ch1
Hi Can someone give me a hint on how to create a matrix with standard errors from lm model? I have already managed to get the matrix with coefficients: coef-as.data.frame(sapply(seq_len(ncol(es.w)),function( i) {x1- summary(lm(es.w[,i]~es.median[,i]));x1$coef[,1]})) but I can't get the one

Re: [R] Why is mclappy slower than apply in this case?

2013-08-08 Thread Steve Lianoglou
Tomas, Also: please don't send html emails (as is specified in the posting guide[1]). This is what your email looked like on our end of the table: https://stat.ethz.ch/pipermail/r-help/attachments/20130808/74a3c7c2/attachment.pl [1] Posting Guide: http://www.r-project.org/posting-guide.html

Re: [R] matrix with standard errors of lm model

2013-08-08 Thread Bert Gunter
Perhaps ?vcov is what you are looking for. -- Bert On Thu, Aug 8, 2013 at 10:37 AM, iza.ch1 iza@op.pl wrote: Hi Can someone give me a hint on how to create a matrix with standard errors from lm model? I have already managed to get the matrix with coefficients:

[R] Creating new vectors from other dataFrames

2013-08-08 Thread Steven Ranney
I have two data frames data1 - as.data.frame(matrix(data=c(1:4,5:8,9:12,13:24), nrow=4, ncol=6, byrow=F, dimnames=list(c(1:4),c(a,b,c,d,e,z data2 - as.data.frame(matrix(data=c(1:4,5:8,9:12,37:48), nrow=4, ncol=6, byrow=F, dimnames=list(c(1:4),c(a,b,c,f,g,z that have some common column

Re: [R] Creating new vectors from other dataFrames

2013-08-08 Thread Steven Ranney
This is exactly what I'm looking for. Each dataFrame will have those columns that are endemic to the other filled with NA. Thanks. Steven H. Ranney On Thu, Aug 8, 2013 at 12:17 PM, arun smartpink...@yahoo.com wrote: HI, Not sure about your expected result. library(plyr)

Re: [R] Method dispatch in S4

2013-08-08 Thread Martin Morgan
On 08/04/2013 02:13 AM, Simon Zehnder wrote: So, I found a solution: First in the initialize method of class C coerce the C object into a B object. Then call the next method in the list with the B class object. Now, in the initialize method of class B the object is a B object and the respective

Re: [R] matrix with standard errors of lm model

2013-08-08 Thread David Winsemius
On Aug 8, 2013, at 10:54 AM, Bert Gunter wrote: Perhaps ?vcov is what you are looking for. -- Bert On Thu, Aug 8, 2013 at 10:37 AM, iza.ch1 iza@op.pl wrote: Hi Can someone give me a hint on how to create a matrix with standard errors from lm model? I have already managed

Re: [R] matrix with standard errors of lm model

2013-08-08 Thread Bert Gunter
Not quite, David. ... (see inline) On Thu, Aug 8, 2013 at 1:56 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 8, 2013, at 10:54 AM, Bert Gunter wrote: Perhaps ?vcov is what you are looking for. -- Bert On Thu, Aug 8, 2013 at 10:37 AM, iza.ch1 iza@op.pl wrote: Hi Can

Re: [R] Mac Os X 10.6.8, R and edit/vi

2013-08-08 Thread MacQueen, Don
This is a question for R-sig-mac. However, try edit(file=file.choose()) Also, before your edit() command, try getwd() Is the file in that directory?? -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/8/13 7:51

Re: [R] For loop output

2013-08-08 Thread MacQueen, Don
If I understand the request correctly, here is an easy to follow example: (I'm using the first four letters as surrogates for the file names) (and assuming we want quotes at both the beginning and the end) tmp - letters[1:4] tmp [1] a b c d foo - paste( ', paste(tmp,collapse=','), ', sep='')

Re: [R] Add column to dataframe based on code in other column

2013-08-08 Thread MacQueen, Don
Assuming your data frame of users is named 'users', and using your mapping vectors: users$regions - '' users$regions[ users$State_Code) %in% NorthEast ] - 'NorthEast' and repeat for the other regions Or, if you put your mappings in a data frame then it is as simple as merge(yourdataframe,

Re: [R] p values for partial correlations

2013-08-08 Thread Peter Langfelder
I am not an expert on shrinkage estimators of partial correlations (such as the one in corpcor), but my sense is that it is difficult to provide a good estimate of a p-value. You could try to email the authors of the package and ask them, but this may be more of a statistics rather than R

Re: [R] Extracting only multiple occurrences

2013-08-08 Thread Kevin Parent
A lot of helpful solutions that pretty much all work. Thanks, everyone!   _ Kevin Parent, Ph.D Korea Maritime University From: Rolf Turner rolf.tur...@xtra.co.nz To: Jim Lemon j...@bitwrit.com.au ject.org Sent: Thursday, August 8, 2013 6:26 PM Subject:

[R] t.test error

2013-08-08 Thread iza.ch1
Hi I receive a very strange error message after trying to do t-test. When I write the code t.test(x) I get an error message: error in t.test(x) : function sqr not found I don't understand this problem. Can someone help me how to do it right? Thanks a lot :)

Re: [R] t.test error

2013-08-08 Thread David Winsemius
On Aug 8, 2013, at 6:09 PM, iza.ch1 wrote: Hi I receive a very strange error message after trying to do t-test. When I write the code t.test(x) I get an error message: error in t.test(x) : function sqr not found I don't understand this problem. Can someone help me how to do it right?

Re: [R] Creating new vectors from other dataFrames

2013-08-08 Thread arun
HI, Not sure about your expected result. library(plyr) data2New-join_all(lapply(setdiff(names(data1), names(data2)),function(x) {data2[,x]-NA; data2})) data1New-join_all(lapply(setdiff(names(data2), names(data1)),function(x){data1[,x]-NA;data1}))  data1New #  a b  c  d  e  z  f  g #1 1 5  9

Re: [R] Creating new vectors from other dataFrames

2013-08-08 Thread arun
Also, a more compact solution would be:library(plyr) #Creating a different dataframe as data2 columns were having almost the same as data1 set.seed(24)  data3- as.data.frame(matrix(sample(1:40,6*4,replace=TRUE),ncol=6))  colnames(data3)- colnames(data2)  join(data3,data1) #Joining by: a, b, c,