Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread Massimo Bressan
yes, I like this: a very elegant and neat solution (in my very umble opinion) sometime is so difficult to me to think of a solution in such a simple and effective terms: less is more! thank you max Il 03/10/2013 17:12, David Carlson ha scritto: Try this i=which(!sapply(mytest, is.null)) n=d

[R] How to obtain "doubly robust" means and SEs for different levels of a factor in R?

2013-10-03 Thread Andrew Kemp
Hi all, I am using svyglm and svyttest to weight my outcome with propensity scores as per: Ridgeway & colleagues (2013) "Toolkit for Weighting and Analysis of Nonequivalent Groups: A tutorial for the twang package" So after: >glm1 <- svyglm(X ~ Y, design=design.ps) >summary(glm1) or >svyttest

[R] Random Projection

2013-10-03 Thread Monaghan, David
Hello: I was wondering, has anyone has encountered an R package that performs random projection/random mapping? RP is a procedure that is akin to Principal Components Analysis in that it accomplishes dimensionality reduction, but is far more computationally efficient. I have been searching fo

Re: [R] String substitution

2013-10-03 Thread arun
Hi, Try: dat$y<- as.character(dat$y) dat1<- dat dat2<- dat library(stringr)  dat$y[NET]<- substr(word(dat$y[NET],2),1,1)  dat$y #[1] "n" "n" "house" "n" "tree" #or for(i in 1:length(NET)){dat1$y[NET[i]]<- "n"}  dat1$y #[1] "n" "n" "house" "n" "tree" #or dat2$y[NET]<- gsub

Re: [R] Importing odf file into R

2013-10-03 Thread Peter Maclean
Anyone aware of a package or technique to import odf data file into R, I will appreciate his/her help. Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mai

Re: [R] Divide a Time column each K seconds

2013-10-03 Thread arun
Hi, Try:  set.seed(45)  df1<- data.frame(datetime=as.POSIXct("2011-05-25",tz="GMT")+1:200,value=sample(1:40,200,replace=TRUE),value2= sample(45:90,200,replace=TRUE)) res<-  with(df1,aggregate(cbind(value,value2),list(as.POSIXct(cut(datetime,breaks="5 sec"))+4),mean)) colnames(res)[1]<- colname

Re: [R] lattice multi-panel layout

2013-10-03 Thread Duncan Mackay
Hi Have a look at ?print.trellis. Lattice (xyplot) is not like plot Untested. starting at bottom left going across the rows print(plott[[4]], position = c(0,0,1/3,0.5), more = T) print(plott[[5]], position = c(1/3,0,2/3,0.5), more = T) print(plott[[6]], position = c(2/3,0,1,0.5), more = T) pri

Re: [R] (sans objet)

2013-10-03 Thread Jim Lemon
On 10/04/2013 08:42 AM, Jesse Gervais wrote: Hello there, I try to construct a variable with R, but I have some difficulties. Assume that I use a data set named = mydata. I want to create a variable that is the mean (totmean) or the sum (totsum) of 6 variables (var1, var2, var3, var4, var5, var

Re: [R] (sans objet)

2013-10-03 Thread Joshua Wiley
Hi Jesse, Here is one approach: score <- function(dat, minimumN) { # get the number of columns (variables) k <- ncol(dat) # take the row means, excluding missing mean <- rowMeans(dat, na.rm=TRUE) # get the number missing for each row nmiss <- rowSums(is.na(dat)) # if nmiss is great

Re: [R] (sans objet)

2013-10-03 Thread Duncan Murdoch
On 13-10-03 6:42 PM, Jesse Gervais wrote: Hello there, I try to construct a variable with R, but I have some difficulties. Assume that I use a data set named = mydata. I want to create a variable that is the mean (totmean) or the sum (totsum) of 6 variables (var1, var2, var3, var4, var5, var6).

Re: [R] [sm.density.compare] scale up y-axis and additional line type

2013-10-03 Thread Xianwen Chen
Hi Jim, Thanks a lot for your help! Kind regards, Xianwen On 10/02/2013 03:24 AM, Jim Lemon wrote: On 10/02/2013 04:43 AM, Xianwen Chen wrote: Thanks Jim, The picture width is adjusted. That was great help! I really appreciate it. Does lwd mean 'line width'? I'm not exactly sure how that

[R] (sans objet)

2013-10-03 Thread Jesse Gervais
Hello there, I try to construct a variable with R, but I have some difficulties. Assume that I use a data set named = mydata. I want to create a variable that is the mean (totmean) or the sum (totsum) of 6 variables (var1, var2, var3, var4, var5, var6). However, I want only participants who have

Re: [R] time series has no or less than 2 periods

2013-10-03 Thread William Dunlap
> > ts <- ts(data$QtyPerWeek, frequency=52) > > HoltWinters(ts,0.46924,0.05,0.2) > > > > This results in the following error. "Error in decompose(ts(x[1L:wind], > > start = start(x), > frequency = f), seasonal) : time series has no or less than 2 periods" Since you have set the frequency of the t

Re: [R] climstats

2013-10-03 Thread David Winsemius
On Oct 3, 2013, at 10:00 AM, Jenny Williams wrote: > It seems to load now on 3.0.2 32bit and 64bit but NOT 3.0.1. > install.packages("climstats", repos="http://R-Forge.R-project.org";, > type="source") > > I did have to manually install some of the dependencies. > There were 2 of us that tried

Re: [R] time series has no or less than 2 periods

2013-10-03 Thread David Winsemius
On Oct 3, 2013, at 8:32 AM, Daniel Hickman wrote: > Hello, > > > > I have been tasked with taking an excel file that my colleague had > implemented Triple Exponential Smoothing and recreate using R. > > The following image shows the before and after of smoothing out a fixed > interval time

Re: [R] text position with offset

2013-10-03 Thread Duncan Murdoch
On 03/10/2013 12:48 PM, Jinsong Zhao wrote: Hi there, I have draw a scatter plot. Now, I hope to label the points in the plot. For example: plot(1:10) text(1:10, 1:10, LETTERS[1:10]) In the above line, I can set position for each labels with pos, e.g.: text(1:10, 1:10, LETTERS[1:10], pos = sa

[R] SSweibull() : problems with step factor and singular gradient

2013-10-03 Thread aline . frank
SSweibull() :  problems with step factor and singular gradient Hello I am working with growth data of ~4000 tree seedlings and trying to fit non-linear Weibull growth curves through the data of each plant. Since they differ a lot in their shape, initial parameters cannot be set for all pl

Re: [R] When to use RProfile.site or .Rprofile

2013-10-03 Thread Henrik Bengtsson
Unless you're trying to provide your startup settings to multiple users (typically only sysadms do this), stick with .Rprofile (in your home directory). There is no need to have one per working directory, unless they differ, cf. ?Startup ["...a file called ‘.Rprofile’ is searched for in the curren

Re: [R] text position with offset

2013-10-03 Thread Greg Snow
You can use the mapply function (or Vectorize) to call text with multiple values for arguments that only take a single value, like adj and offset. On Thu, Oct 3, 2013 at 10:48 AM, Jinsong Zhao wrote: > Hi there, > > I have draw a scatter plot. Now, I hope to label the points in the plot. > For

Re: [R] vif

2013-10-03 Thread arun
Hi Eliza, Then, "res" needs a slight modification library(car)  res<- lapply(colnames(h),function(x) {x1<- h[,x];dat1<- do.call(rbind,lapply(seq_len(ncol(mat1)),function(i){ x2<- m[,mat1[,i]];GG<- lm(x1~x2[,1]+x2[,2]+x2[,3]+x2[,4]);GGsum<- summary(GG); data.frame( Models=paste(colnames(x2),co

Re: [R] climstats

2013-10-03 Thread Jenny Williams
It seems to load now on 3.0.2 32bit and 64bit but NOT 3.0.1. install.packages("climstats", repos="http://R-Forge.R-project.org";, type="source") I did have to manually install some of the dependencies. There were 2 of us that tried loading climstats on different machines so there must have been

Re: [R] Save intermediate result in a same file

2013-10-03 Thread Greg Snow
Open a connection to the file (and leave it open), then just use the cat function with the file option. Or use append=TRUE argument to cat. On Tue, Oct 1, 2013 at 8:13 AM, Matthew wrote: > Hello everybody, > > i have to save a 100 iteration computation in a file every 5 iterations > until the

[R] text position with offset

2013-10-03 Thread Jinsong Zhao
Hi there, I have draw a scatter plot. Now, I hope to label the points in the plot. For example: plot(1:10) text(1:10, 1:10, LETTERS[1:10]) In the above line, I can set position for each labels with pos, e.g.: text(1:10, 1:10, LETTERS[1:10], pos = sample(1:4, 10, replace = TRUE)) as what you

[R] time series has no or less than 2 periods

2013-10-03 Thread Daniel Hickman
Hello, I have been tasked with taking an excel file that my colleague had implemented Triple Exponential Smoothing and recreate using R. The following image shows the before and after of smoothing out a fixed interval time series data using Triple Exponential Smoothing inside of Excel. ente

Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread arun
Hi, You may try: names(mytest)<- 1:length(mytest) mat1<-  do.call(rbind,mytest) dat1<-data.frame(i=row.names(mat1),n=mat1[,1])  row.names(dat1)<- 1:nrow(dat1)  dat1 #  i  n #1 1 45 #2 3 18 #3 5 99 A.K. - Original Message - From: Massimo Bressan To: "r-help@r-project.org" Cc: Sent: Thu

[R] Testing custom linear contrasts with Welch correction (anova function)

2013-10-03 Thread Michael Cantinotti
Dear R users, I am doing custom contrasts with R (comparison of group means). Everything works fine, but I would like to test the 3 contrasts with and without a Welch correction for unequal variances. I can replicate SPSS results when equal variances are assumed, but I do not manage to test the

[R] lattice multi-panel layout

2013-10-03 Thread efx
Dear, I seem to be unable to work out a solution for multi-panel layout using xyplot. I have tried with layout, grid.layout (latticeExtra), but unsuccessfully. I can produce all plots individually, but just can't figure out how to put them all in the same panel! Here is a piece of the code. vlayo

Re: [R] Java requested System.exit(130)

2013-10-03 Thread Joe Byers
Ed Siefker gmail.com> writes: > > I'm used to using ctrl-c to end operations without killing R. But I've used > xlsx in this session, which loads Java, which apparently intercepts the > ctrl-C. Accordingly, I hit ctrl-C, R died, and I lost a lot of work. > > I did some looking, and found a >

Re: [R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
Thanks for answering. I already started hunting. But my first doubt was if I used prcomp correctly (and this is in the moment my most important point). So far as I understood your answer is yes. Is that correct? I am puzzled by the fact that these "columns" are more or less in the middle of my sn

[R] spatialprobit

2013-10-03 Thread Riccardo Marzano
Hi. I'm a new user of R and I'm trying to run a spatial probit model using the spatialprobit package. I've a dataset of 15677 obs (municipalities followed up from 2001 to 2012). My depvar is the decision to outsource a particular service (binary) and my indepvar of interest is "shareholder" (equa

[R] When to use RProfile.site or .Rprofile

2013-10-03 Thread jroyrobertson
I would appreciate some advice on what the preferred contents of RProfile.site vs. .Rprofile should be. A .First() function can reside in either one, but is it preferred to place it in .Rprofile? I currently use .First() in .Rprofile files placed in separate directories used for different RStudi

Re: [R] a simple question

2013-10-03 Thread arun
Hi, Try: set.seed(494)  h<- matrix(sample(1:40,4*124,replace=TRUE),ncol=4)  set.seed(39)  m<- matrix(sample(1:100,10*124,replace=TRUE),ncol=10)  colnames(h)<- paste0("h",1:4)  colnames(m)<- paste0("m",1:10) mat1<-combn(colnames(m),4)  res<- lapply(colnames(h),function(x) {x1<- h[,x];dat1<- do.

Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread Massimo Bressan
the list I'm dealing with is the follow-up of an lapply() not a "native" data structure I've been set up for storing data originally; the list it's a data structure I have to manage as a consequence of my previous operations, something like: path<-"./" files <-list.files(path, pattern=".csv") my

Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread David Carlson
Try this > i=which(!sapply(mytest, is.null)) > n=do.call(rbind, mytest[i]) > mydf <- data.frame(i, n) > mydf i n 1 1 45 2 3 18 3 5 99 - David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Mes

Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread Sarah Goslee
Hi, Something like this, maybe: > mytest.df <- data.frame(i=seq_along(mytest)[!sapply(mytest, is.null)], > n=unlist(mytest)) > mytest.df i n 1 1 45 2 3 18 3 5 99 It took me a couple of tries, because I wasn't expecting unlist() to drop the NULL values: > unlist(mytest) [1] 45 18 99 Sarah O

Re: [R] storing element number of a list in a column data frame

2013-10-03 Thread Bert Gunter
Have you read An Introduction to R (ships with R) or another of the many excellent R tutorials on the web? I ask, because you do not appear to be using a sensible data structure. As your list appears to be of a single type (probably numeric, maybe integer), it would be preferable to use a vector, l

[R] storing element number of a list in a column data frame

2013-10-03 Thread Massimo Bressan
#let's suppose I have a list like this mytest<-list(45, NULL, 18, NULL, 99) #to note that this is just an amended example because in fact #I'm dealing with a long list (more than 400 elements) #with no evident pattern of the NULL values #I want to end up with a data frame like the following d

Re: [R] prcomp - surprising structure

2013-10-03 Thread peter dalgaard
It's not so obvious to me that this is an artifact. What prcomp() says is that some of the eigenvectors have a lot of "activity" in some relatively narrow ranges of SNPs (on the same chromosome, perhaps?). If something artificial is going on, I could imagine effects not so much of centering colu

Re: [R] How to extract the error flag from 'try'

2013-10-03 Thread Duncan Murdoch
On 03/10/2013 9:09 AM, Dimitri Liakhovitski wrote: Thank you very much! inherits(res, "try-error") is what I was looking for! I would have expected to see this in the ?try examples section, but it's really hidden. I'll look into making it more obvious. Duncan Murdoch On Thu, Oct 3, 2013

Re: [R] How to extract the error flag from 'try'

2013-10-03 Thread Dimitri Liakhovitski
Thank you very much! inherits(res, "try-error") is what I was looking for! On Thu, Oct 3, 2013 at 9:07 AM, Gabor Grothendieck wrote: > On Thu, Oct 3, 2013 at 8:57 AM, Dimitri Liakhovitski > wrote: > > Hello! > > > > I need to flag my operation as an error if it produces an error. > > > > For ex

Re: [R] How to extract the error flag from 'try'

2013-10-03 Thread Gabor Grothendieck
On Thu, Oct 3, 2013 at 8:57 AM, Dimitri Liakhovitski wrote: > Hello! > > I need to flag my operation as an error if it produces an error. > > For example, this expression produces an error: > test<-try(log("a")) > str(test) > > However, how can I proceed using the information contained in test obj

[R] How to extract the error flag from 'try'

2013-10-03 Thread Dimitri Liakhovitski
Hello! I need to flag my operation as an error if it produces an error. For example, this expression produces an error: test<-try(log("a")) str(test) However, how can I proceed using the information contained in test object? I am looking for something like: if test is an error {do this and this}

Re: [R] Status of installing XML package on widows

2013-10-03 Thread Milan Bouchet-Valat
Le jeudi 03 octobre 2013 à 10:35 +0200, rolf.kem...@renesas.com a écrit : > > Hello Experts, > > I would like to utilize the XML package which is obviously quite new. > > There are tons of messages in the web dealing with issues on that. > But I did not see any clear up to date solution. > On to

Re: [R] Status of installing XML package on widows

2013-10-03 Thread Milan Bouchet-Valat
Le jeudi 03 octobre 2013 à 10:35 +0200, rolf.kem...@renesas.com a écrit : > > Hello Experts, > > I would like to utilize the XML package which is obviously quite new. > > There are tons of messages in the web dealing with issues on that. > But I did not see any clear up to date solution. > On to

Re: [R] Status of installing XML package on widows

2013-10-03 Thread Milan Bouchet-Valat
Le jeudi 03 octobre 2013 à 10:35 +0200, rolf.kem...@renesas.com a écrit : > > Hello Experts, > > I would like to utilize the XML package which is obviously quite new. > > There are tons of messages in the web dealing with issues on that. > But I did not see any clear up to date solution. > On to

Re: [R] update.packages fails on pdf write - CSAgent

2013-10-03 Thread Tim Howard
For the archives, the solution I've come up with is to complete the install in a location where write permissions are allowed for exe files and then simply copy the extracted files from this folder to R's library folder, using the components of update.packages as follows: #get a list of old pa

Re: [R] Status of installing XML package on widows

2013-10-03 Thread Ista Zahn
Hi Rolf, On Thu, Oct 3, 2013 at 4:35 AM, wrote: > > > Hello Experts, > > I would like to utilize the XML package which is obviously quite new. I think it's been around for quite some time actually. The ReadMe file says it was originally developed in 1999. > > There are tons of messages in the

Re: [R] Interpreting the result of a Wilcoxon (Mann-Whitney U) test

2013-10-03 Thread S Ellison
> I'm having some trouble interpreting the results of a Wilcoxon > (Mann-Whitney U) test. Hope you can help. Two-tailed and one tailed tests generally give different p-values, with the two-tailed p-value twice (one of) the one-tailed values for rather obvious reasons. You need to sort out whic

Re: [R] Problem with makePSOCKcluster R3.0.1

2013-10-03 Thread Prof Brian Ripley
On 03/10/2013 09:13, Anna Longari wrote: Hello, I am using function makePSOCKcluster to make parallel computation on 3 EC2 Amazon machines. I have a passwordless between machines and ssh is correct. In the R 2.15.1 release this function works correctly. Installing R 3.0.1 on my EC2 machines makeP

[R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
Hello, I did a pca with over 20 snps for 340 observations (ids). If I plot the eigenvectors (called rotation in prcomp) 2,3 and 4 (e.g. plot (rotation[,2]) I see a strange "column" in my data (see attachment). I suggest it is an artefact (but of what?). Suggestion: I used prcomp this way: prc

[R] Problem with makePSOCKcluster R3.0.1

2013-10-03 Thread Anna Longari
Hello, I am using function makePSOCKcluster to make parallel computation on 3 EC2 Amazon machines. I have a passwordless between machines and ssh is correct. In the R 2.15.1 release this function works correctly. Installing R 3.0.1 on my EC2 machines makePSOCKcluster does not produce the cluster. I

[R] tilting procedure in tilting library hangs or errors

2013-10-03 Thread Todd Morley
I have a data frame named all_cars containing 1082 rows and 1583 columns. Each row represents an observation; each column represents a variable. Every data value is an integer or decimal value; there are no nulls or non-numeric strings. I want to use the tilting library to do variable selecti

Re: [R] Interpreting the result of a Wilcoxon (Mann-Whitney U) test

2013-10-03 Thread Filipe Correia
Hi Petr, On Thu, Oct 3, 2013 at 8:01 AM, PIKAL Petr wrote: >> Well, I guess I'm asking all of the three... :) Not with the intent to >> choose which one fits, but because I was experimenting and making sure >> I really understand how I could use R's implementation of the Wilcoxon >> test. But I'm

[R] Status of installing XML package on widows

2013-10-03 Thread rolf . kemper
Hello Experts, I would like to utilize the XML package which is obviously quite new. There are tons of messages in the web dealing with issues on that. But I did not see any clear up to date solution. On top my R on windows tell me that this is not available fro 3.01 which is quite puzzling fo

Re: [R] plot multiple graphs in one graph and in multiple windows

2013-10-03 Thread Patrick Connolly
On Thu, 26-Sep-2013 at 04:47PM +, Hui Du wrote: |> |> Hi All, |> |> I have a question about plotting graphs. Supposedly, I want to plot |> 12 graphs. Putting 12 graphs to one window seems too |> crowded. Ideally, I want to put 4 pictures in one window and plot |> them in three separate wind

Re: [R] Interpreting the result of a Wilcoxon (Mann-Whitney U) test

2013-10-03 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Filipe Correia > Sent: Wednesday, October 02, 2013 10:32 PM > To: Charles Determan Jr > Cc: r-help@r-project.org > Subject: Re: [R] Interpreting the result of a Wilcoxon (Mann