[R] How to optimize or build a better random forest?

2012-10-16 Thread Aaditya Nanduri
Hello Everyone! It's been a while since I last posted a question! Hope everyone has been doing well! ~~~ CONTEXT ~~~ I have recently entered a beginner-level competition on kaggle. The goal of the competition is to build a model that predicts who did/did not survive on the Titanic. I d

Re: [R] extracting and restricting coefficients

2012-10-16 Thread Arne Henningsen
Hi Dereje On 17 October 2012 04:23, Dereje Bacha wrote: > I want to fit two equations simultaneously > EQ1<-Y1~X1+X2 > EQ2<-Y2~X1+X2 > eqsystem<-list(Y1HAT=EQ1,Y2HAT=EQ2) > fitols<-systemfit(eqsystem, > method="OLS", data=BB) > > How do I get coefficients for the first equation? R code coef(fito

[R] Random Forest for multiple categorical variables

2012-10-16 Thread Gyanendra Pokharel
Dear all, I have the following data set. V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 alpha beta 1111 111 111 11111alpha beta1 2122 122 12 2 12212alpha beta1 3133 133 13 3 13 313alpha beta1 41

[R] extracting and restricting coefficients

2012-10-16 Thread Dereje Bacha
Hi  I want to fit two equations simultaneously EQ1<-Y1~X1+X2 EQ2<-Y2~X1+X2 eqsystem<-list(Y1HAT=EQ1,Y2HAT=EQ2) fitols<-systemfit(eqsystem, method="OLS", data=BB) How do I get coefficients for the first equation? R code How do I restrict coefficient of X2 in the first equation (say , restrict it t

Re: [R] frequency table with custom bands

2012-10-16 Thread jim holtman
?cut try this: > seq1 = seq(0, 95, by = 5) > seq2 = seq(100, 1000, by = 100) > Bands = c(seq1, seq2) > Prices = sample(1:1000, 200, replace=F) > table(cut(Prices, breaks = Bands)) (0,5] (5,10] (10,15] (15,20] (20,25] (25,30] (30,35] (35,40] 1 2

Re: [R] how to fit Cox model with time dependent covariates?

2012-10-16 Thread David Winsemius
On Oct 16, 2012, at 10:24 AM, gallon li wrote: I wonder if there is a simple way of doing this? My data is very simple, a right censored outcome (T,delta) and the predictor is simply Z*t, i.e., the cox model is like h(t)=h0(t)exp(beta*Z*t) That looks more like an accelerated time model than

[R] Creating Optimization Constraints

2012-10-16 Thread boylangc
Good afternoon, In the code below, I have a set of functions (m1,m2,m3,s1,s2, and s3) which represent response surface designs for the mean and variance for three response variables, followed by an objective function that uses the "Big M" method to minimize variance (that is, push s1, s2, and

[R] frequency table with custom bands

2012-10-16 Thread jcrosbie
I would like to create a frequency table with custom bands. seq1 = seq(0, 100, by = 5) seq2 = seq(100, 1000, by = 100) Bands = c(seq1, seq2) Prices = sample(1:1000, 200, replace=F) How would I go about find the frequency of prices within each band? -- View this message in context: http:/

Re: [R] "invalid times argument in rep function"

2012-10-16 Thread economicurtis
I came seeking the answer to the same question. Looking over my work, the equation I had to deliver the "times" variable (in rep, the "integer vector giving the (non-negative) number of times to repeat each element" , and seeking to replicate a number NaN times too. Thanks! -- View this mess

Re: [R] How to create a high-dimensional matrix

2012-10-16 Thread lrl
Should it be .Machine$integer.max- 429497 ^2? The matrix is not a sparse matrix, but a symmetric matrix. It's a process of feature selection. I am choosing the most important variables from 439497 variables. Now I am considering divide the whole dataset into several part and process a small part

[R] sliding window analysis with rollapply

2012-10-16 Thread Wang, Li
Dear List members I want to do the sliding window analysis of some specific values. Here is my code: require(zoo) dat <- read.table("chr1.txt", header = TRUE, sep="\t") dat2 <- cbind(dat[1,3]) #The first column is also important. It represents the position of the site on the chromosome. TS <- z

Re: [R] vectors comparison

2012-10-16 Thread Simon Knapp
Your question does not seem to make sense - there is no value of -500 in Y (did you mean -10?). Anyway, I think this might work: which(y==-10 & (x==1 | c(0, x[-length(x)]) == 1 | c(x[-1], 0) == 1)) ... though one would think there is a more elegant way On Wed, Oct 17, 2012 at 10:07 AM, Francesc

[R] vectors comparison

2012-10-16 Thread Francesco Nutini
Dear R-Users, I'd like to have your help on this problem: I have two vectors:x<- c(0,1,0,0,0,0,0,0,0,0,0,1,0)y<- c(0,0,-10,0,0,-10,0,-10,0,0,0,0,0) And I want to know where the value -500 in y have a correspondence value 1 in x.Considering a buffer of one position before and after in x.i.e. in t

Re: [R] se's and CI's for fitted lines in multivariate regression analysis

2012-10-16 Thread Rui Barradas
Hello, If you want confidence intervals for the beta coefficients of the model, try the following. ci_lm <- function(object, level = 0.95){ sfit <- summary(object) beta <- sfit$coefficients[, 1] se <- sfit$coefficients[, 2] df <- sfit$df[1] alpha <- 1 - level lower <- b

Re: [R] Question about use of sort.list(sort.list(x)) in rank.r

2012-10-16 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Tyler Ritchie > Sent: Tuesday, October 16, 2012 2:23 PM > To: r-help@r-project.org > Subject: [R] Question about use of sort.list(sort.list(x)) in rank.r > > I was looking at

[R] Question about use of sort.list(sort.list(x)) in rank.r

2012-10-16 Thread Tyler Ritchie
I was looking at rank() and I came across: ... "first" = sort.list(sort.list(xx)), ... line 32 of rank.r [1] sort.list(x) returns the indices of the values of x in ascending (by default) order. So sort.list(sort.list(x)) returns the same list. So, what am I missing here? -Tyler [1] view-sourc

Re: [R] cannot coerce class '"rle"' into a data.frame

2012-10-16 Thread R. Michael Weylandt
On Tue, Oct 16, 2012 at 7:07 PM, Marc Schwartz wrote: > On Oct 16, 2012, at 12:54 PM, Sam Steingold wrote: > >> why? >> >>> rle >> Run Length Encoding >> lengths: int [1:1650061] 2 2 8 2 4 5 6 3 26 46 ... >> values : chr [1:1650061] "4bbf9e94cbceb70c BG bg" "4fbbf2c67e0fb867 SK sk" >> ... >>>

Re: [R] How to create a high-dimensional matrix

2012-10-16 Thread R. Michael Weylandt
On Tue, Oct 16, 2012 at 8:46 PM, lrl wrote: > Hi, everyone > > I need to create a 429497 x 429497 matrix. > When I use > *matrix(0,429497,429497)* > I got the error information : Error in matrix(0, 429497, 429497) : too many > elements specified > > Then I use "ff" package, try to store this matr

Re: [R] Package survey: Compute standard deviations from complex survey designs

2012-10-16 Thread Thomas Lumley
On Tue, Oct 16, 2012 at 10:40 PM, Sebastian Weirich wrote: > Hello, > > svyvar from the survey package computes variances (with standard errors) > from survey design objects. Is there any way to compute standard deviations > and their standard errors in a similar manner? Usually you can do this s

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread William Dunlap
Duncan wrote > You can override this by setting the R_LIBS_USER variable in Cygwin to > C:/Users/aldi/Documents/R/win-library/2.15 before you start R; then > things should be fine. If you use R_LIBS_USER then you have to be careful when later calling .libPaths to add more libraries: % env

Re: [R] uniq -c

2012-10-16 Thread William Dunlap
You said you wanted the equivalent of the Unix 'uniq -c' but said that xtab's results were roughly right and the rle might be what you want. rle() is the equivalent of 'uniq -c', they both output the lengths of runs of identical elements. if the data is sorted they are equivalent to using table(

Re: [R] cannot open gplots libray

2012-10-16 Thread Uwe Ligges
On 16.10.2012 17:13, Seb wrote: hi all i'm trying to open gplots library but i keep on getting this error: /Loading required package: gdata Error in readRDS(mapfile) : embedded nul in string: 'ref\0\0\002\0\0\0\0' Error : unable to load R code in package ‘gdata’ Error: package ‘gdata’ could not

Re: [R] se's and CI's for fitted lines in multivariate regression analysis

2012-10-16 Thread Sigrid
Okay, I've now tried to the predict function and get the SE, although it seem to calculate SE for each observation from the line (I assume), while I want the CI-interval and SE for each line fitted line for the treatment. I do not really understand what parameter mean these SEs are calculated from

Re: [R] Referring to matrix elements by name, iteratively

2012-10-16 Thread AHJ
Thank you both for the suggestion. So this means that when the vector is one of characters the string inside it is interpreted as itself, rather than as an index. That makes so much sense! Thanks again :) -- View this message in context: http://r.789695.n4.nabble.com/Referring-to-matrix-element

Re: [R] Referring to matrix elements by name, iteratively

2012-10-16 Thread AHJ
You are right! But that was my bad, I was trying to simplify the part of the data I used in the example. The real data have exactly the same IDs as both rows and columns. Thanks for catching that. :) -- View this message in context: http://r.789695.n4.nabble.com/Referring-to-matrix-elements-by-

[R] How to create a high-dimensional matrix

2012-10-16 Thread lrl
Hi, everyone I need to create a 429497 x 429497 matrix. When I use *matrix(0,429497,429497)* I got the error information : Error in matrix(0, 429497, 429497) : too many elements specified Then I use "ff" package, try to store this matrix on disk * x<-ff(0,dim=c(429497,429497)* And I got the err

[R] Penalty function constrained optimization

2012-10-16 Thread hayduke
Hi All, I am trying to use optim() to minimize a function with a penalty function term. This is a simple model bioeconomic model of a fishery. The penalty function constrains the amount of effort (f) at 9. This works fine. The code is: ** nfleets<-2 M<-1 M<-array(M,dim=c(nfleets)) N<-1000 c

Re: [R] uniq -c

2012-10-16 Thread cberry
Sam Steingold writes: > I need an analogue of "uniq -c" for a data frame. The count.rows() function is the R analogue. See http://orgmode.org/worg/org-contrib/babel/examples/Rpackage.html#sec-6-1 No need to install the package - just copy and paste the function into an R session. On cases I

[R] R Kaplan-Meier plotting quirks?

2012-10-16 Thread Michael Rentz
Hello. I apologize in advance for the VERY lengthy e-mail. I endeavor to include enough detail. I have a question about survival curves I have been battling off and on for a few months. No one local seems to be able to help, so I turn here. The issue seems to either be how R calculates Kaplan-

[R] cannot open gplots libray

2012-10-16 Thread Seb
hi all i'm trying to open gplots library but i keep on getting this error: /Loading required package: gdata Error in readRDS(mapfile) : embedded nul in string: 'ref\0\0\002\0\0\0\0' Error : unable to load R code in package ‘gdata’ Error: package ‘gdata’ could not be loaded/ if i run session info

Re: [R] fit a "threshold" function with nls

2012-10-16 Thread Ravi Varadhan
Veronique, Can you write down the likelihood function in R and send it to me (this is very easy to do, but I don't want to do your work)? Also send me the code for simulating the data. I will show you how to fit such models using optimization tools. Best, Ravi _

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Duncan Murdoch
On 16/10/2012 3:02 PM, Aldi Kraja wrote: Thank you all including Bert, In my opinion the library() when is working in cygwin env., does not check the additional libraries, where R installed the additional packages. So the solution for this problem was to define manually in my programs where is

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Aldi Kraja
Thank you all including Bert, In my opinion the library() when is working in cygwin env., does not check the additional libraries, where R installed the additional packages. So the solution for this problem was to define manually in my programs where is located the library of additional packa

Re: [R] uniq -c

2012-10-16 Thread Sam Steingold
> * Duncan Murdoch [2012-10-16 14:22:51 -0400]: > > On 16/10/2012 1:46 PM, Sam Steingold wrote: >> > * Duncan Murdoch [2012-10-16 12:47:36 -0400]: >> > >> > On 16/10/2012 12:29 PM, Sam Steingold wrote: >> >> x is sorted. >> > sparseby(data=x, INDICES=x, FUN=nrow) >> >> this takes forever; apparen

Re: [R] uniq -c

2012-10-16 Thread Duncan Murdoch
On 16/10/2012 1:46 PM, Sam Steingold wrote: > * Duncan Murdoch [2012-10-16 12:47:36 -0400]: > > On 16/10/2012 12:29 PM, Sam Steingold wrote: >> x is sorted. > sparseby(data=x, INDICES=x, FUN=nrow) this takes forever; apparently, it does not use the fact that x is sorted (even then - it should n

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Bert Gunter
I do not think that this has anything to do with the issue at hand, but just to clarify ... On Tue, Oct 16, 2012 at 10:18 AM, Jeff Newmiller wrote: > Probably because when you run it from Cygwin the R_LIBS variable does not > point to the user and install library directories. I don't know how Rg

Re: [R] Problems with xlsx and rjava

2012-10-16 Thread Rui Barradas
Hello, I cannot answer directly to your question, but I had problems with package xlsx and for what I've seen on R-Help so had others. Maybe you are using the wrong architecture of R (32/64 bits). Package XLConnect is more flexible and a bit more complex, but it comes with a vignette that expl

Re: [R] cannot coerce class '"rle"' into a data.frame

2012-10-16 Thread Marc Schwartz
On Oct 16, 2012, at 12:54 PM, Sam Steingold wrote: > why? > >> rle > Run Length Encoding > lengths: int [1:1650061] 2 2 8 2 4 5 6 3 26 46 ... > values : chr [1:1650061] "4bbf9e94cbceb70c BG bg" "4fbbf2c67e0fb867 SK sk" > ... >> as.data.frame(rle) > Error in as.data.frame.default(vertices.rle)

Re: [R] uniq -c

2012-10-16 Thread Sam Steingold
> * Duncan Murdoch [2012-10-16 12:47:36 -0400]: > sparseby(data=x, INDICES=x, FUN=nrow) Error in `[<-.data.frame`(`*tmp*`, index, , value = list(user = c(2L, : missing values are not allowed in subscripted assignments of data frames -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.0

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Aldi Kraja
Here follows also the Sys.getenv(): R Windwos 32bit Rgui run: == R_HOME "D:/RHome" R_LIBS_USER "C:\\Users\\aldi\\Documents/R/win-library/2.15" R_USER "C:\\Users\\aldi\\Documents" R cygwin run: === > Sys.getenv() "/usr/bin/R" BIBINPUTS ".;;D:/RHome/share/texm

Re: [R] cannot coerce class '"rle"' into a data.frame

2012-10-16 Thread arun
Hi, vec1<-c(1,2,3,4,4,5,6)  str(rle(vec1)) #List of 2 # $ lengths: int [1:6] 1 1 1 2 1 1 # $ values : num [1:6] 1 2 3 4 5 6  #- attr(*, "class")= chr "rle" do.call(data.frame,rle(vec1))  # lengths values #1   1  1 #2   1  2 #3   1  3 #4   2  4 #5   1  5 #6  

[R] Problems with xlsx and rjava

2012-10-16 Thread Lopez, Dan
Hi, I keep getting the below error regarding rJava which is required by package xlsx (I have used it in the past to directly import data from Excel 2010). I was on R version 2.15.0 when I was getting this error this morning. So I upgraded to 2.15.1 but still the same problem. I tried unstalling

[R] cannot coerce class '"rle"' into a data.frame

2012-10-16 Thread Sam Steingold
why? > rle Run Length Encoding lengths: int [1:1650061] 2 2 8 2 4 5 6 3 26 46 ... values : chr [1:1650061] "4bbf9e94cbceb70c BG bg" "4fbbf2c67e0fb867 SK sk" ... > as.data.frame(rle) Error in as.data.frame.default(vertices.rle) : cannot coerce class '"rle"' into a data.frame it seems that

Re: [R] uniq -c

2012-10-16 Thread Sam Steingold
> * Duncan Murdoch [2012-10-16 12:47:36 -0400]: > > On 16/10/2012 12:29 PM, Sam Steingold wrote: >> x is sorted. > sparseby(data=x, INDICES=x, FUN=nrow) this takes forever; apparently, it does not use the fact that x is sorted (even then - it should not take more than a few minutes)... -- Sam S

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Aldi Kraja
Thank you Richard and Jeff, There is a difference in the reporting of extra packages in 32bit 64bit, see following: 32bit although it does not report the extra package when I call it with Rgui it has the rgenoud. Instead 64bit Rgui it reports that extra package of rgenoud. More info follows: (in

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Duncan Murdoch
On 16/10/2012 1:14 PM, Aldi Kraja wrote: Thank you Duncan, No I did not install R from cygwin. R is installed with windows 7. I am calling R with a symbolic link from /usr/bin part of cygwin paths, but my symbolic link is pointing to /usr/bin/R -> /cygdrive/d/RHome/bin/R.exe Is it possible R is

[R] how to fit Cox model with time dependent covariates?

2012-10-16 Thread gallon li
I wonder if there is a simple way of doing this? My data is very simple, a right censored outcome (T,delta) and the predictor is simply Z*t, i.e., the cox model is like h(t)=h0(t)exp(beta*Z*t) can this be done with coxph? __ R-help@r-project.org maili

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Richard M. Heiberger
I would guess that you installed rgenoud as user, not as administrator. That would put the file inside c:/Users/YourName/AppData/Local/VirtualStore/Program Files/R instead of where you think it is. I can imagine that could easily cause confusion. Rich On Tue, Oct 16, 2012 at 1:14 PM, Aldi Kraja

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Jeff Newmiller
Probably because when you run it from Cygwin the R_LIBS variable does not point to the user and install library directories. I don't know how Rgui knows where they are (registry?) but you can look in the .Library and .Library.site variables to see the results. In a case like this, posting your

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Aldi Kraja
Thank you Duncan, No I did not install R from cygwin. R is installed with windows 7. I am calling R with a symbolic link from /usr/bin part of cygwin paths, but my symbolic link is pointing to /usr/bin/R -> /cygdrive/d/RHome/bin/R.exe Is it possible R is lost in forward paths recognized by cy

Re: [R] List of Levels for all Factor variables

2012-10-16 Thread arun
HI, You can also try this: set.seed(1) dat1<-data.frame(col1=factor(sample(1:25,10,replace=TRUE)),col2=sample(letters[1:10],10,replace=TRUE),col3=factor(rep(1:5,each=2))) sapply(lapply(mapply(c,lapply(names(sapply(dat1,levels)),function(x) x),sapply(dat1,levels)),function(x) paste(x[1],":",paste(

[R] Test for treatment effect in a logistic regression

2012-10-16 Thread bibek sharma
Dear R usuer, I need to fit logistic regression with binomial response. The objective is to compare treatment groups controlling other categorical and continuous predictors. The GLM procedure with family=binomial(Logit) gives me parameters estimates as well as odd ratios. But objective is to compa

Re: [R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Duncan Murdoch
On 16/10/2012 12:41 PM, Aldi Kraja wrote: Hi, Using R 2.15.1 on Windows 7. Have installed both versions 32 and 64bit. In both of them among others I have installed a package rgenoud When I open R gui of 32bit and write library(rgenoud) it responds by showing a functional rgenoud version 5.7-8. T

Re: [R] uniq -c

2012-10-16 Thread Duncan Murdoch
On 16/10/2012 12:29 PM, Sam Steingold wrote: > * R. Michael Weylandt [2012-10-16 16:19:27 +0100]: > > Have you looked at using table() directly? If I understand what you > want correctly something like: > > table(do.call(paste, x)) I wished to avoid paste (I will have to re-split later, so it

[R] Windows 7 R (32/64bit) running under cygwin: package not found

2012-10-16 Thread Aldi Kraja
Hi, Using R 2.15.1 on Windows 7. Have installed both versions 32 and 64bit. In both of them among others I have installed a package rgenoud When I open R gui of 32bit and write library(rgenoud) it responds by showing a functional rgenoud version 5.7-8. The same it does on Rgui 64bit. Now I am

Re: [R] Download a file from url

2012-10-16 Thread Henrik Bengtsson
Have you tried downloading it manually using a web browser or similar? If so, compare that downloaded file to that you get from download.file() and see if they're the same. If the same, the problem is elsewhere (which is not unlikely to be the case). /H On Mon, Oct 15, 2012 at 6:15 PM, veepsirtt

Re: [R] uniq -c

2012-10-16 Thread Sam Steingold
> * R. Michael Weylandt [2012-10-16 16:19:27 > +0100]: > > Have you looked at using table() directly? If I understand what you > want correctly something like: > > table(do.call(paste, x)) I wished to avoid paste (I will have to re-split later, so it will be a performance nightmare). > Also, if

Re: [R] Pivot Table "like" structure

2012-10-16 Thread David Winsemius
On Oct 13, 2012, at 5:38 PM, Bhupendrasinh Thakre wrote: HI Team, I am currently working on problem and stumped on "for" loop. Data: structure(list(Coutry = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L), .Label = c("J", "M", "U"), class = "factor"), State = structure(c(1L, 1L, 4L, 2L, 5L, 5

Re: [R] List of Levels for all Factor variables

2012-10-16 Thread Lopez, Dan
Perfect! Thank you! Dan -Original Message- From: Rui Barradas [mailto:ruipbarra...@sapo.pt] Sent: Tuesday, October 16, 2012 9:03 AM To: Lopez, Dan Cc: R. Michael Weylandt; R help (r-help@r-project.org) Subject: Re: [R] List of Levels for all Factor variables Hello, The problem is with

Re: [R] nnls() help

2012-10-16 Thread David Winsemius
On Oct 15, 2012, at 10:13 PM, Nicola Cesca wrote: I'm trying to get significance of coefficients as for lm() but I news help. In order for there to be significance tests for the coefficients, the problem would needs to be embedded in some sort of a probability model. Such may be possibl

Re: [R] List of Levels for all Factor variables

2012-10-16 Thread Rui Barradas
Hello, The problem is with "clean"? dat <- data.frame(X = sample(letters[1:4], 100, TRUE), Y = sample(LETTERS[1:6], 100, TRUE), Z = factor(rep(1:5, 4))) levs <- lapply(dat, levels) clean <- lapply(seq_along(levs), function(i) paste(names(levs)[i], ":", paste(levs[[

Re: [R] how to extract from list

2012-10-16 Thread Rui Barradas
Hello, Inline. Em 16-10-2012 16:22, Balqis escreveu: well that function is the one I created, manipulating pargev from evir package. maybe this is where I have to check I presume. Maybe yes, we can't tell. for the 50k,the more the robust perhaps? Yes, the more the merrier but if you want

Re: [R] List of Levels for all Factor variables

2012-10-16 Thread Lopez, Dan
Using unlist() did not produce the result I wanted. I have a dataframe. I tried playing with the parameters of unlist but each time it just tried to return each observation. unlist(x, recursive = TRUE, use.names = TRUE) Dan -Original Message- From: R. Michael Weylandt [mailto:michael.w

Re: [R] List of Levels for all Factor variables

2012-10-16 Thread R. Michael Weylandt
On Tue, Oct 16, 2012 at 4:19 PM, Lopez, Dan wrote: > Hi, > > I want to get a clean succinct list of all levels for all my factor variables. > > I have a dataframe that's something like #1 below. This is just an example > subset of my data and my actual dataset has 70 variables. I know how to > n

Re: [R] uniq -c

2012-10-16 Thread R. Michael Weylandt
Have you looked at using table() directly? If I understand what you want correctly something like: table(do.call(paste, x)) Also, if you take a look at the development version of R, changes are being put in place to allow much larger data sets. Cheers, Micael On Tue, Oct 16, 2012 at 4:03 PM, Sa

[R] List of Levels for all Factor variables

2012-10-16 Thread Lopez, Dan
Hi, I want to get a clean succinct list of all levels for all my factor variables. I have a dataframe that's something like #1 below. This is just an example subset of my data and my actual dataset has 70 variables. I know how to narrow down my list of variables to just my factor variables by u

Re: [R] rJava install - "%1 is not a valid Win32 application."

2012-10-16 Thread Steven Ranney
Thanks for the information, Simon. I had both the 64-bit version of R and the 64-bit Windows 7, but not the 64-bit version of Java. Now that I've downloaded the proper version of Java, the problem has been solved. Thanks - SR Steven H. Ranney On Mon, Oct 15, 2012 at 5:12 PM, Simon Knapp wro

Re: [R] Pivot Table "like" structure

2012-10-16 Thread John Kane
Perhaps this but your results example did not include Char1. ibrary(reshape2) md <- structure(list(Coutry = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L), .Label = c("J", "M", "U"), class = "factor"), State = structure(c(1L, 1L, 4L, 2L, 5L, 5L, 3L, 6L), .Label = c("A", "C", "K", "O", "S", "T"), cla

[R] uniq -c

2012-10-16 Thread Sam Steingold
I need an analogue of "uniq -c" for a data frame. xtabs(), although dog slow, would have footed the bill nicely: --8<---cut here---start->8--- > x <- data.frame(a=1:32,b=1:32,c=1:32,d=1:32,e=1:32) > system.time(subset(as.data.frame(xtabs( ~. , x )), Freq != 0 ))

Re: [R] unique

2012-10-16 Thread Rainer Schuermann
If I understand your problem correctly (as Milan has pointed out, sample data and code would help enormously) this should get you where you want: unique( shopdata$name[ shopdata$employee > 10 ] ) If not, something is wrong from the outset (or with my understanding, but then ... see above)! R

Re: [R] library(rmeta)

2012-10-16 Thread John Kane
Please supply some sample data and code. The easiest way to supply data is to use the dput() function. Example with your file named "testfile": dput(testfile) Then copy the output and paste into your email. For large data sets, you can just supply a representative sample. Usually, dput(h

Re: [R] time extraction and normalization

2012-10-16 Thread John Kane
For some reason this seems to work: d <- "04MAY2011:08:19:00" toDaySecond(d) John Kane Kingston ON Canada > -Original Message- > From: smartpink...@yahoo.com > Sent: Tue, 16 Oct 2012 05:22:29 -0700 (PDT) > To: sleepingw...@gmail.com > Subject: Re: [R] time extraction and normalizatio

Re: [R] how to extract from list

2012-10-16 Thread Rui Barradas
Hello, Your code doesn't work, which libraries are you using? There are several with function rgev. And pargevn() also doesn't exist. Nor does the matrix/df inP. (And, for reproducible example there's no need to replicate 50K times...) Rui Barradas Em 16-10-2012 13:41, Balqis escreveu: Ok he

Re: [R] fit a "threshold" function with nls

2012-10-16 Thread Vito Muggeo
Véronique, in addition to Bert's comments, I would like to bring to your attention that there are several packages that perform threshold/breakpoint/changepoint estimation in R, including cumSeg, segmented, strucchange, and bcp for a Bayesian approach Moreover some packages, such as cghFLasso

Re: [R] unique

2012-10-16 Thread Milan Bouchet-Valat
Le mardi 16 octobre 2012 à 14:45 +0200, paladini a écrit : > Hello everybody, > I've got a problem concerning the function unique. I have got a > data.frame "shopdata" with 1000 shop which were evaluated at different > points in time. > > With function subset I chose those shops with more then 1

[R] unique

2012-10-16 Thread paladini
Hello everybody, I've got a problem concerning the function unique. I have got a data.frame "shopdata" with 1000 shop which were evaluated at different points in time. With function subset I chose those shops with more then 10 employee and store it in data.frame "bigshopdata" with 700 shops.

Re: [R] time extraction and normalization

2012-10-16 Thread arun
Hi Simon, I tried your code, but I am getting some error message: toDaySecond('04MAY2011:08:19:00') #Error in as.POSIXct(d, format = format.string, tz = tz) :   #object 'd' not found A.K. - Original Message - From: Simon Knapp To: Jeff Newmiller Cc: r-help@r-project.org; york8866

Re: [R] Problems with coxph and survfit in a stratified model with interactions

2012-10-16 Thread Andrews, Chris
Hi Roland (and Terry), Is this the model you want to fit? --a separate 'baseline' hazard for each stratum defined by cov1 --a coefficient for cov2 that is different for each stratum defined by cov1 Then you can have a separate call to coxph for each stratum. sCox0 <- coxph(Surv(time, status) ~ co

Re: [R] Excluding all teh columns from a data frame if the standard deviation of that column is zero(0).

2012-10-16 Thread arun
HI, May be this helps. set.seed(1)  dat1<-data.frame(col1=rep(5,10),col2=rnorm(10,15),col3=rep(25,10),col4=rnorm(10,25))  dat1[sapply(dat1,function(x) sd(x)!=0)] #   col2 col4 #1  14.37355 26.51178 #2  15.18364 25.38984 #3  14.16437 24.37876 #4  16.59528 22.78530 #5  15.32951 26.12493 #

Re: [R] how to extract from list

2012-10-16 Thread Balqis
Ok here's the lines of codes: sIr=replicate(5,ts(arima.sim(list(ar=0),n=150,innov=rgev(150,xi=0.2, mu=inP[1,5],sigma=inP[1,4]),start.innov=rgev(150,xi=0.2, mu=inP[1,5],sigma=inP[1,4] sIrr=data.frame(cbind(sIr)) EsIpr=sapply(sIrr[1:100,1:2],function(m) pargevn(lmom.ub(m))) kIpr=EsIpr

Re: [R] time extraction and normalization

2012-10-16 Thread Simon Knapp
Whoops... tried to get all descriptive with the argument names before I posted but after I tested. Try this toDaySecond <- function(date.string, format.string='%d%b%Y:%T', tz='') { d <- as.POSIXct(date.string, format=format.string, tz=tz) sum(mapply(function(f, l) as.numeric(format(d, form

Re: [R] how to extract from list

2012-10-16 Thread arun
HI, Try this: To extract kappa: list1<-list(X17=data.frame(xi=784.77,alpha=165.406,kappa=-0.2709),X19998=data.frame(xi=860.783,alpha=215.114,kappa=-0.1769)) sapply(list1,`[`,3) #$X17.kappa #[1] -0.2709 #$X19998.kappa [1] -0.1769 #To extract alpha:  sapply(list1,`[`,2) #$X17.alpha #[1]

Re: [R] XTS Subsetting question (noob)

2012-10-16 Thread Joshua Ulrich
On Tue, Oct 16, 2012 at 5:04 AM, john.dempster78 wrote: > Hi, > How can an xts object be subset using a date in a variable? > E.g. in below, what is the right syntax for Q to get the same value as P? > Obviously the syntax shown below doesnt work... > V is an xts object. > > R > P <- V['2007-01-0

Re: [R] how to extract from list

2012-10-16 Thread Muhammad Rahiz
Maybe something along the following lines? m <- rep(list(rnorm(10)),3) # dummy data data <- c() for (a in 1:length(m)) { data[a] <- m[[a]][1] } Muhammad On Tue, Oct 16, 2012 at 1:17 PM, Balqis wrote: > Hi all, > > I have a list of 2 data, and the list look like below. I wonder what is > t

[R] data.frame and commandArgs problem

2012-10-16 Thread scottyjock
Hi, I am writing a .R script to plot some data from a file, all info given from command line. For example: Rscript Rtest.R sas_summary.csv sas_score_pre sas_score_post ...will try to plot columns of data "sas_score_pre" and "sas_score_post" from the file "sas_summary.csv". I can extract these

Re: [R] code ok in unix & R2.6 , fails in windows & R 2.12

2012-10-16 Thread Jellevanloon
Hi, I'm experiencing the same problems.. Installed the package DRM yestarday.. first couple of runs it worked.. I closed down R and now I want to do the same code again and I get the error: Error in drm(TotDmShoot ~ DAP, data = DATA, fct = gompGrowth.2()) : Cluster not specified. Use e.g. y ~

[R] XTS Subsetting question (noob)

2012-10-16 Thread john.dempster78
Hi, How can an xts object be subset using a date in a variable? E.g. in below, what is the right syntax for Q to get the same value as P? Obviously the syntax shown below doesnt work... V is an xts object. d = "2007-01-01" P <- V['2007-01-01/'] Q <- V['d/'] Thanks, J -- View this message in c

Re: [R] data dividing

2012-10-16 Thread bambus
ok thanks, but I just got it right. Although I don't know what was the problem. just thanks for your effort!!! -- View this message in context: http://r.789695.n4.nabble.com/data-dividing-tp4646314p4646325.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] how to extract from list

2012-10-16 Thread Rui Barradas
Hello, Try the following. lapply(lst, `[[`, 'kappa') Also, please post a data example using ?dput, in case of lists it's difficult for us to reproduce what you've posted. Hope this helps, Rui Barradas Em 16-10-2012 12:17, Balqis escreveu: Hi all, I have a list of 2 data, and the list

[R] how to extract from list

2012-10-16 Thread Balqis
Hi all, I have a list of 2 data, and the list look like below. I wonder what is the simplest way to extract 'kappa' value (or 'xi' or 'alpha' for the matter) from each of the data. How can I simply code it without having to change the list to a dataframe first? Many thanks! $X19997

Re: [R] gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) > 0.4) { :, missing value where TRUE/FALSE needed

2012-10-16 Thread Simon Wood
Hi Andrew, Could you send me a bit more information (off list, as this is likely to get into obscure details), please? In particular can you let me know the mgcv and R version numbers, the server operating system and, if possible, what BLAS it has installed? best, Simon On 16/10/12 07:32, An

Re: [R] gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) > 0.4) { :, missing value where TRUE/FALSE needed

2012-10-16 Thread Simon Wood
On 16/10/12 07:32, Andrew Crane-Droesch wrote: Hi All, I'm running into a problem with GAM (in the MGCV package). When I try to estimate the model, I get the following error message: 1> fit <- gam(ndvi~s(rain)+s(temp)+s(rainl1)+s(rainl2)+s(rainxY)+s(rainl1xY)+s(rainl2xY)+s(tempxY),

Re: [R] anova test for variables with different lengths

2012-10-16 Thread S Ellison
>> I want to test whether the MEAN of two different variables, >> (and different number of observations) are the same. I am >> trying to use the anova test but it doesn't seem to like that >> the number of observations are different: >> >> a=c(1:5) >> b=c(1:3) >> aov_test=aov(a~b) >> Err

Re: [R] R Errors

2012-10-16 Thread R. Michael Weylandt
Likely you've used layout() or similar to add lots of columns & rows to your plot, where "lots" is determined by the size of the device. Simply make the device larger (either just drag it to be larger if its interactive or change the default arguments if its a non-default device you initialize manu

Re: [R] Excluding all teh columns from a data frame if the standard deviation of that column is zero(0).

2012-10-16 Thread Rui Barradas
Hello, You're calling your dataset 'data' and 'df' in the same instruction, hence the error. (Even if you were to call it different names in different instructions...) Also, both 'data' and 'df' are really bad names for objects, they're already are R functions. Name your dataset something el

Re: [R] data dividing

2012-10-16 Thread Rui Barradas
Hello, Your function works, > sapply(1:12, Jahreszeit) [1] "Winter""Winter""Fruehling" "Fruehling" "Fruehling" "Sommer" [7] "Sommer""Sommer""Herbst""Herbst""Herbst" "Winter" but not with your data? We don't know what your data looks like. Post an example using ?dput

Re: [R] Excluding all teh columns from a data frame if the standard deviation of that column is zero(0).

2012-10-16 Thread R. Michael Weylandt
On Tue, Oct 16, 2012 at 9:08 AM, siddu479 wrote: > Hi All, > > I have a data frame where nearly 10K columns of data, where most of them > have standard deviation( of all rows) as zero. > I want to exclude all the columns from the data frame and proceed to further > processing. > > I tried like b

[R] data dividing

2012-10-16 Thread bambus
hey I'd like to divide my data into four seasons. for this I made a function: Jahreszeit <- function(x) { if (x<=02 || x==12) {return("Winter") }else{ if (x>=03 && x<=05) {return("Fruehling") }else{ if (x>=06 && x<=08) {return("Sommer") }else{ if (x>=09 && x<=11) {return("Herbst") } Now, I

Re: [R] Download a file from url

2012-10-16 Thread veepsirtt
Hello Prof Brian Ripley I installed wget for windows from http://users.ugent.be/~bpuype/wget/ and got the results very thanks veepsirtt --

[R] R Errors

2012-10-16 Thread kokila
How to resolve this below Error.I have tried my best but again i have got error. Error in plot.new() : figure margins too large. Iam waiting for Reply -- View this message in context: http://r.789695.n4.nabble.com/R-Errors-tp4646311.html Sent from the R help mailing list archive at Nab

  1   2   >