[R] Matrix of Matrices?

2011-02-10 Thread Alaios
Dear all I have a few matrices that I would like to store alltogether under a bigger object. My matrixes with the same name were calculated inside a loop like for (few times){ estimatedsr<- this is my matrix savematrixasimagefile(); } which means that I was losing all that instances.

[R] Writing R packages in an easier way?

2011-02-10 Thread Dr. Michael Wolf
Dear R colleagues, is there an easier way to write R packages for the own use - without RTools and TeX? With R versions < 2.10.0 it was very easy to write a package. Under the path with the package name you wrote a description file and built some directories like "help", "html" and "R" with t

[R] fitdistr question

2011-02-10 Thread Antje Niederlein
Hello, I tried to fit a poisson distribution but looking at the function fitdistr() it does not optimize lambda but simply estimates the mean of the data and returns it as lambda. I'm a bit confused because I was expecting an optimization of this parameter to gain a good fit... If I would use mle(

[R] When is *interactive* data visualization useful to use?

2011-02-10 Thread Tal Galili
Hello all, Before getting to my question, I would like to apologize for asking this question here. My question is not directly an R question, however, I still find the topic relevant to R community of users - especially due to only * partial* (current) support for interactive data visualization

Re: [R] comparing proportions

2011-02-10 Thread Robert A LaBudde
You need to change models 2 and 3 to use ~ group + subject. You left subject out as a fixed factor. At 05:17 PM 2/10/2011, array chip wrote: Robert, thank you! I tried all 3 models you suggested. Since each subject only has one line of data in my dataset, would including Subject as a factor

[R] How can we make a vector call a function element-wise efficiently?

2011-02-10 Thread zhaoxing731
Hello I have a time-comsuming program which need to simplify, I have tested the annotated program as follow: > #define function which will be call > calsta <- function(c, n=10) + { + i <- seq(from=0, length=c) + logx <- lchoose(NT-n, CT-i) + lchoose(n, i) + logmax <- max(lo

Re: [R] Multi-page plots (Trellis)

2011-02-10 Thread David Winsemius
On Feb 10, 2011, at 2:39 PM, sherri heck wrote: Dear All - I would like to make multi-page plots, but my plots are writing over one another - thus leaving just the last plot. Here is what I am doing: pollutionRose(temp, "nox", type="hour") update(trellis.last.object(), layout =c(3,3,3) )

Re: [R] Plotting confidence bands around regression line

2011-02-10 Thread dtholmes
Here is my primitive and computationally intensive solution to this problem. Thank you to Michal (see above) for making me aware of the nice polygon function. I am sure that there are better solutions but this one works for me at work and for publication. ###

Re: [R] tzone and DST

2011-02-10 Thread Jeff Newmiller
I would say it is quite tedious to process timestamps in such a mixed basis unless it includes the daylight/standard time indicators in the data itself. Up until you work with time in the repeated hour in the autumn you can skate by, but those times require the extra indicator, and if it isn't i

Re: [R] tzone and DST

2011-02-10 Thread Bill Harris
Jeff Newmiller writes: > Use Sys.setenv(TZ="Etc/GMT+8") before you read the files. Thanks, Jeff and all for the suggestions (assuming this works, as it seems it should, I may go with this one). I'll try them tomorrow. After posting my query, I discovered a related problem which I have to resea

[R] backward prediction in multivariate multiple regression

2011-02-10 Thread Ondřej Mikula
Dear r-helpers, I used lsfit to estimate regression coefficients from the matrices of predictors and predicted values (i.e multivariate multiple regression model). I wish, however, to compute rank-one matrices of predictor values from the predicted ones. How to do it in R? Could you suggest me app

Re: [R] Where can I download/install grDevices

2011-02-10 Thread Dennis Murphy
Hi: Here's one way: plot(1~1,ylab=expression("Areas ("~mu*m^2~")")) The tildes incorporate space between the math and text elements; they're optional, but useful. Another way that also works is plot(1~1,ylab=expression(paste("Areas (", mu*m^2, ")", sep = ' '))) HTH, Dennis On Thu, Feb 10, 20

Re: [R] highest and second highest value in row for each combination

2011-02-10 Thread Dennis Murphy
Hi: And yet another: :) library(plyr) top2 <- function(x) { y <- sort(x[-c(1, 2)], decreasing = TRUE)[1:2] area <- rep(x[1], 2) type <- rep(x[2], 2) data.frame(area, type, value = y, variable = names(y)) } v <- ldply(apply(df, 1, top2), rbind) The last line does

Re: [R] Getting p-value from summary output

2011-02-10 Thread Bill.Venables
Hi Alice, You can use pvals <- summary(myprobit)$coefficients[, "Pr(>|z|)"] Notice that if the p-value is very small, the printed version is abbreviated, but the object itself has full precision (not that it matters). Bill Venables. -Original Message- From: r-help-boun...@r-project.o

Re: [R] comparing proportions

2011-02-10 Thread Mike Marchywka
I had a longer draft before but I'll just ask if you ever looked at your data? cr=rainbow(3); plot(df$success+df$failure,df$prop.success,col=cr[as.numeric(df$group)],cex=as.numeric(df$group)) you'd have to suspect that p is a function of the number of trials per subject and that differences bet

Re: [R] if a variable is defined

2011-02-10 Thread Bill.Venables
!is.null(my.obj...@my.data.frame$my.var) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kushan Thakkar Sent: Friday, 11 February 2011 10:30 AM To: r-help@r-project.org Subject: [R] if a variable is defined I have an object type m

Re: [R] Where can I download/install grDevices

2011-02-10 Thread Lizblip
Duncan Murdoch-2 wrote: > > > There is no plotmath function. "plotmath" is the name of the help > topic; it describes how various other functions plot text that includes > math. > > > grDevices is a base package, so if you've got R, you've got it. > > Duncan Murdoch > > ok thanks. I

[R] if a variable is defined

2011-02-10 Thread Kushan Thakkar
I have an object type my.object. One of its slots contains a data frame (i.e. my.obj...@my.data.frame) .. I want to check if one of the variables exists in this data frame (i.e. my.obj...@my.data.frame$my.var) I am trying to use the exists function but can't figure out how the arguments work. Plea

Re: [R] Getting p-value from summary output

2011-02-10 Thread Dennis Murphy
Hi: Try summary(myprobit)$coefficients[, 4] HTH, Dennis On Thu, Feb 10, 2011 at 3:46 PM, Allie818 wrote: > > I can get this summary of a model that I am running: > > summary(myprobit) > > Call: > glm(formula = Response_Slot ~ trial_no, family = binomial(link = "probit"), >data = neg_data,

Re: [R] extracting characters from string

2011-02-10 Thread jim holtman
A safer way to make sure you don't match the underscore: > gsub("[^_]*_[^_]*_([^_]*).*", "\\1", "abcd_efgh_X_12ab3_dfsfd") [1] "X" On Thu, Feb 10, 2011 at 2:06 PM, Henrique Dallazuanna wrote: > So, a way could be: > > gsub("(.*)_(.*)_(.*)_.*", "\\3",  "abcd_efgh_X_12ab3_dfsfd") > >

[R] Getting p-value from summary output

2011-02-10 Thread Allie818
I can get this summary of a model that I am running: summary(myprobit) Call: glm(formula = Response_Slot ~ trial_no, family = binomial(link = "probit"), data = neg_data, na.action = na.pass) Deviance Residuals: Min 1Q Median 3Q Max -0.9528 -0.8934 -0.8418 1.44

Re: [R] Add different types of legend: line and points

2011-02-10 Thread Shiguo Jiang
Thank you Duncan. It works. It seems that NA is of great use. Shiguo On Thu, Feb 10, 2011 at 5:25 PM, Duncan Murdoch wrote: > On 11-02-10 3:56 PM, Shiguo Jiang wrote: > >> Hello, >> >> I plot box plot, and add a point to the box indicating mean. I also add >> some >> range to the box width. I wa

Re: [R] tzone and DST

2011-02-10 Thread Jeff Newmiller
Use Sys.setenv(TZ="Etc/GMT+8") before you read the files. --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /So

Re: [R] Prediction accuracy from Bagging with continuous data

2011-02-10 Thread Peter Langfelder
On Thu, Feb 10, 2011 at 8:45 AM, Simon Gillings wrote: > I am using bagging to perform Bagged Regression Trees on count data (bird > abundance in Britain and Ireland, in relation to climate and land cover > variables). Predictions from the final model are visually believable but I > would reall

Re: [R] Rioja package, creating transfer function, WA, "Error in FUN"

2011-02-10 Thread Peter Ehlers
On 2011-02-10 09:40, mdc wrote: Hi, I am a new R user and am trying to construct a palaeoenvironmental transfer function (weighted averaging method) using the package rioja. I've managed to insert the two matrices (the species abundance and the environmental data) and have assigned them to the y

Re: [R] highest and second highest value in row for each combination

2011-02-10 Thread jim holtman
here is another way of doing it: > set.seed(19) > > area<-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10)) > type<-c(rep(1:10,5)) > a<-rnorm(50) > b<-rnorm(50) > c<-rnorm(50) > d<-rnorm(50) > df<-cbind(area,type,a,b,c,d) > df1 <- data.frame(df) > require(reshape2) > df.melt <- melt(df1, id=c('

Re: [R] tzone and DST

2011-02-10 Thread Gabor Grothendieck
On Thu, Feb 10, 2011 at 7:06 PM, Bill Harris wrote: > I'm reading in ~3 years worth of data that includes hourly timestamps. > Presumably to avoid DST confusion, all the data is in PST time zone -- no > discontinuities in the spring or fall. > > The data comes in a csv file, which I'm reading with

Re: [R] Calling symbols from dataframe for xyplot

2011-02-10 Thread Dennis Murphy
Hi: It's not a perfect solution, but an 'easy' way out is to recognize that some symbols are open and some are filled. If you want fill, use a filled symbol and then change the color. p <- rep(16:18, 4) x<-c(1:12) y<-c(rpois(12,4)) grp<-c(rep(c(3,4), each=6)) z<-c(rep(c(1,2), each=6)) dd <- data.

Re: [R] problem with R (akima, fUtilities) in Ubuntu 10.04

2011-02-10 Thread Ben Bolker
Željka biologija.unios.hr> writes: > > Dear all! > > I'm using R 2.12.1 in Ubuntu 10.04. > Problem is that when using functions like interp (package akima) and > akimaInterp (package fUtilities), I get different results every time for > the same data set. I've checked the interpolated results,

[R] tzone and DST

2011-02-10 Thread Bill Harris
I'm reading in ~3 years worth of data that includes hourly timestamps. Presumably to avoid DST confusion, all the data is in PST time zone -- no discontinuities in the spring or fall. The data comes in a csv file, which I'm reading with myvariable <- read.csv("my_data_file.csv",header=FALSE, col

Re: [R] Where can I download/install grDevices

2011-02-10 Thread Duncan Murdoch
On 10/02/2011 4:08 PM, Lizblip wrote: I get the same errors: plotmath(area~cell,main="Myofibril areas by cell",ylab=expression("Areas (mu*m^2)"),xlab="") Error: could not find function "plotmath" There is no plotmath function. "plotmath" is the name of the help topic; it describes how var

Re: [R] Repeaded sampling

2011-02-10 Thread Dennis Murphy
My apologies to Eik - I didn't see his solution and essentially replicated it. Sorry for the noise.. Dennis On Thu, Feb 10, 2011 at 3:46 PM, Dennis Murphy wrote: > Hi: > > On Thu, Feb 10, 2011 at 10:50 AM, Hui Du wrote: > >> >> Hi all, >> >>I have a dataset. Each time I want to

Re: [R] Repeaded sampling

2011-02-10 Thread Dennis Murphy
Hi: On Thu, Feb 10, 2011 at 10:50 AM, Hui Du wrote: > > Hi all, > >I have a dataset. Each time I want to sample N(i) elements > from it and I want to repeated sampling M times. N(i) is varied from time to > time. For example, > >dataset = 1:50; >a

Re: [R] Finding length of unique numbers in a vector

2011-02-10 Thread Rob Tirrell
How about: table(samp) -- Robert Tirrell | r...@stanford.edu | (607) 437-6532 Program in Biomedical Informatics | Butte Lab | Stanford University On Thu, Feb 10, 2011 at 13:54, Nipesh Bajaj wrote: > > set.seed(100) > > samp <- sample(c(1,-1,0), 20, replace=T); samp > [[alternative H

Re: [R] Prediction accuracy from Bagging with continuous data

2011-02-10 Thread mxkuhn
If you do use correlation, you should think about doing it on the log or sort scale. The train() function in the caret package can estimate performance using resampling. There are examples in ?train that show how to define custom performance measures (I think it shows how to do this with MAD es

Re: [R] Calculating rowMeans from different columns in each row?

2011-02-10 Thread rex.dwyer
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marine Andersson Sent: Thursday, February 10, 2011 3:53 PM To: r-help@r-project.org Subject: [R] Calculating rowMeans from different columns in each row? Hello! I have a dataset lik

[R] Changing the points in a circular plot

2011-02-10 Thread Bobby Lee
x<-circular(dayofmax[,2]*2*pi/365) res25 <- density(x, bw=25, control.circular=list(units="degrees")) circularp(res25$x) plot(res25, col=4, points.plot=TRUE, xlim=c(-1.5,1.5)) res50 <- density(x, bw=50, adjust=2) lines(res50, col=2) lines(res50, col=3, shrink=0.9) this is my code, basically, it

Re: [R] Where can I download/install grDevices

2011-02-10 Thread Lizblip
I get the same errors: > plotmath(area~cell,main="Myofibril areas by cell",ylab=expression("Areas > (mu*m^2)"),xlab="") Error: could not find function "plotmath" > install.packages("grDevices") Warning in install.packages("grDevices") : argument 'lib' is missing: using '/home/elizabeth/R/i686-

[R] Bwplot with dendrogram to indicate significant differences

2011-02-10 Thread Michael Hoffman
I would like to make a box plot with a dendogram on top that can be used to indicate significant differences (with an asterisk or three at a node depending on the p-value). I can supply the adjacency information a priori. Is there an easy way to do this? Other ways of presenting the same inform

Re: [R] How to determine the quantile boundary from an ECDF?

2011-02-10 Thread Eik Vettorazzi
Hi Ivan, are you looking for quantiles of "type 1"? See ?quantile x<-rnorm(50) ecdfx<-ecdf(x) ecdfx(quantile(x,.95,type=1)) #so this is the lowest x having ecdf(x)>=.95 ecdfx(quantile(x,.95,type=1)-1e-10) #left from that point ecdf<.95 so actually it is right-continuous (because its an inverse o

Re: [R] Finding length of unique numbers in a vector

2011-02-10 Thread Clint Bowman
?rle -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600

Re: [R] about prediction with a factor

2011-02-10 Thread Dennis Murphy
Hi: There are a couple of things here. Firstly, if you intend to predict from a model in R, make sure your input to the model is a data frame. You can fit a model piecemeal with a set of vectors, but there's a distinct possibility you'll end up frustrated when trying to make predictions with new d

Re: [R] Add different types of legend: line and points

2011-02-10 Thread Duncan Murdoch
On 11-02-10 3:56 PM, Shiguo Jiang wrote: Hello, I plot box plot, and add a point to the box indicating mean. I also add some range to the box width. I want to add legend for both the range (line) and mean (point). However, I cannot add line legend and point legend together. The code looks like t

Re: [R] Finding length of unique numbers in a vector

2011-02-10 Thread Eik Vettorazzi
Hi, does table(samp) do what you want? Am 10.02.2011 22:54, schrieb Nipesh Bajaj: > Hello there, would you please look into my codes? Here I have following: > >> set.seed(100) >> samp <- sample(c(1,-1,0), 20, replace=T); samp > [1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0

Re: [R] comparing proportions

2011-02-10 Thread array chip
Robert, thank you! I tried all 3 models you suggested. Since each subject only has one line of data in my dataset, would including Subject as a factor in glm() or lm() lead to 0 df for resaiduals? Attached is my dataset and here is my version of the 3 models: test<-read.table("test.txt",sep=

Re: [R] How to reset libPaths for root

2011-02-10 Thread Prof Brian Ripley
See ?.libPaths : as so often, all that is needed is attentive reading of the documentation: The library search path is initialized at startup from the environment variable ‘R_LIBS’ (which should be a colon-separated list of directories at which R library trees are rooted) followed

Re: [R] Calculating rowMeans from different columns in each row?

2011-02-10 Thread Phil Spector
Marine - Assuming your data frame is named "df", I think apply(df,1,function(x)mean(x[x[7]:x[8]])) will give you what you're looking for. - Phil Spector Statistical Computing Facility

[R] Finding length of unique numbers in a vector

2011-02-10 Thread Nipesh Bajaj
Hello there, would you please look into my codes? Here I have following: > set.seed(100) > samp <- sample(c(1,-1,0), 20, replace=T); samp [1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0 Here I want to calculate the length of each unique number for above vector. How can I do that?

[R] How to determine the quantile boundary from an ECDF?

2011-02-10 Thread Ivan Popivanov
Given a dataset x, the ecdf is ecdf(x). Then I can use ecdf(x)(y) to find the percentile of y. Given the ecdf is there a way to determine what is the value of y that is the boundary of let's say 95 percentile? In other words, is there a function I can call on the ecdf like: fomeFunc( ecdf( x ), 0.

[R] Calling symbols from dataframe for xyplot

2011-02-10 Thread John Poulsen
Hello, I am trying to make a xyplot plot with points that are different symbols. I want to call the symbol type (pch) from a column in my dataframe. Here is a simplified example. In my real example I also have groups, which I have not included here. This example doesn't change the symbols or

Re: [R] : package to draw

2011-02-10 Thread Greg Snow
You could use the floating.pie function in the plotrix package, but even the author of that function/package has stated in the past that pie charts are not the best tool. Also look at the symbols function for some alternatives, I would use the thermometers (and if that does not give enough opti

[R] Calculating rowMeans from different columns in each row?

2011-02-10 Thread Marine Andersson
Hello! I have a dataset like this: X1 X2 X3 X4 X5X6X7X8 1 2 2 1 2 3 2 6 2 3 2 5 7 9 1 3 19 12 6 1 1 3 6 The columns X1-X6 contains ordinary numeric values. X7 contains the numb

Re: [R] Repeaded sampling

2011-02-10 Thread Eik Vettorazzi
Hi, try ds<-1:50 M<-10 n<-sample(5:15,M,replace=T) #generate different n[i] lapply(1:M,FUN=function(i) sample(ds,n[i])) hth. Am 10.02.2011 19:50, schrieb Hui Du: > > Hi all, > > I have a dataset. Each time I want to sample N(i) elements > from it and I want to repeated sampli

Re: [R] comparing proportions

2011-02-10 Thread Robert A LaBudde
1. If you use a random effects model, you should make Subject the random factor. I.e., a random intercepts model with 1|Subject. Group is a fixed effect: You have only 2 groups. Even if you had more than 2 groups, treating Group as random would return a standard deviation, not a P-value as you

[R] Add different types of legend: line and points

2011-02-10 Thread Shiguo Jiang
Hello, I plot box plot, and add a point to the box indicating mean. I also add some range to the box width. I want to add legend for both the range (line) and mean (point). However, I cannot add line legend and point legend together. The code looks like the following. (1) First, I tried the follo

[R] : package to draw

2011-02-10 Thread Mr rong chen
Do anyone know an R or bioconductor package to draw HGDP pie chart as in the link below? http://hgdp.uchicago.edu/cgi-bin/alfreqs.cgi?pos=118253964&chr=chr8&rs=rs12255372&imp=false Many SNPs were missing from the link, so I would like to draw similar graphs in R. I have all the allele frequency

Re: [R] accessing members from a data frame

2011-02-10 Thread Phil Spector
Try my.data.frame[my.data.frame$Buy==1 | my.data.frame$Sell ==1, ] or subset(my.data.frame,buy == 1 | sell == 1) Then take a look at the help page for || i.e., help("||") to see what you did wrong. - Phil Spector

[R] Rioja package, creating transfer function, WA, "Error in FUN"

2011-02-10 Thread mdc
Hi, I am a new R user and am trying to construct a palaeoenvironmental transfer function (weighted averaging method) using the package rioja. I've managed to insert the two matrices (the species abundance and the environmental data) and have assigned them to the y and x values respectively. When I

[R] Multi-page plots (Trellis)

2011-02-10 Thread sherri heck
Dear All - I would like to make multi-page plots, but my plots are writing over one another - thus leaving just the last plot. Here is what I am doing: pollutionRose(temp, "nox", type="hour") update(trellis.last.object(), layout =c(3,3,3) ) I would like 24 plots with 9 plots/page (the last pag

[R] accessing members from a data frame

2011-02-10 Thread Kushan Thakkar
I have a data frame with the following columns: Date Price Buy Sell The Buy and Sell variables are binary. They are either zero or 1. Additionally, they are mutually exclusive. Either Buy is 1, Sell is 1 or they are both 0. But they are never both 1 for a given observation. I want to see observa

[R] Repeaded sampling

2011-02-10 Thread Hui Du
Hi all, I have a dataset. Each time I want to sample N(i) elements from it and I want to repeated sampling M times. N(i) is varied from time to time. For example, dataset = 1:50; a = list(); M = 1000; I want to d

[R] Chi square test of proprotions in 2 groups of different sizes

2011-02-10 Thread Dimitri Liakhovitski
Hello! Very sorry for a probably very simple question - I looked but did not find an answer in the archives. I have a table "counts" (below) that shows counts by Option within each of my 2 groups. However, my groups have different sizes (N1=255 and N2=68). Table "prop" shows the resulting proporti

Re: [R] Revolution Analytics reading SAS datasets

2011-02-10 Thread Jeremy Miles
On 10 February 2011 12:01, Matt Shotwell wrote: > On Thu, 2011-02-10 at 10:44 -0800, David Smith wrote: >> The SAS import/export feature of Revolution R Enterprise 4.2 isn't >> open-source, so we can't release it in open-source Revolution R >> Community, or to CRAN as we do with the ParallelR pack

[R] How to reset libPaths for root

2011-02-10 Thread Juergen Rose
High, on all of my computers the first entry in libPaths for root was /usr/lib64/R/library or /usr/lib/R/library. Now it change at one (lynx) anyway to root@lynx:/root(2)# R R version 2.12.1 (2010-12-16) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform:

Re: [R] Revolution Analytics reading SAS datasets

2011-02-10 Thread Matt Shotwell
On Thu, 2011-02-10 at 10:44 -0800, David Smith wrote: > The SAS import/export feature of Revolution R Enterprise 4.2 isn't > open-source, so we can't release it in open-source Revolution R > Community, or to CRAN as we do with the ParallelR packages (foreach, > doMC, etc.). Judging by the language

Re: [R] Problem with xlsx package

2011-02-10 Thread Tobias Verbeke
On 02/10/2011 05:30 PM, Gabor Grothendieck wrote: On Thu, Feb 10, 2011 at 10:49 AM, Nikhil Joshi wrote: Gabor, thanks for the suggestion. I did as you have suggested- Started a clean session of R and set the java option. Then I sourced the library and tried to read the xlsx file but got the sa

Re: [R] Modifying a package name / Build from sources (rpart)

2011-02-10 Thread Marc Schwartz
On Feb 10, 2011, at 12:13 PM, Ben Bolker wrote: > Simon Knos quantentunnel.de> writes: > >> Upfront: I am not sure if this is the right place to ask this question even >> after reading through the FAQ, so apologies if I should have directed the >> question elsewhere. > > I appreciate your con

Re: [R] Hmisc errbar color

2011-02-10 Thread David Winsemius
On Feb 9, 2011, at 8:27 PM, Robert Baer wrote: Is there an easy way to make the error bars the same color as the points and lines they are plotted with. My example # fake data x=sample(1:10, 100, replace =T) y = rnorm(100) + runif(100) df=data.frame(x,y) # summarize data m = aggregate(df,lis

Re: [R] Hmisc errbar color

2011-02-10 Thread Peter Ehlers
On 2011-02-09 17:27, Robert Baer wrote: Is there an easy way to make the error bars the same color as the points and lines they are plotted with. My example # fake data x=sample(1:10, 100, replace =T) y = rnorm(100) + runif(100) df=data.frame(x,y) # summarize data m = aggregate(df,list(x),mean)

Re: [R] Use glm coefficients for other datasets

2011-02-10 Thread maxsilva
Thank you guys, I've solved my problem with your precious help -- View this message in context: http://r.789695.n4.nabble.com/Use-glm-coefficients-for-other-datasets-tp3276626p3299747.html Sent from the R help mailing list archive at Nabble.com. __ R

[R] Optimal choice of the threshold u in Peak Over Threshold (POT) Approach

2011-02-10 Thread FMH
Dear All, Could someone please suggest me the way to calculate the optimal threshold in POT method via any available  packages in R? Thanks, Fir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the po

[R] Comparison of glm.nb and negbin from the package aod

2011-02-10 Thread sabwo
I have fitted the faults.data to glm.nb and to the function negbin from the package aod. The output of both is the following: summary(glm.nb(n~ll, data=faults)) Call: glm.nb(formula = n ~ ll, data = faults, init.theta = 8.667407437, link = log) Deviance Residuals: Min 1Q Media

Re: [R] Generate multivariate normal data with a random correlation matrix

2011-02-10 Thread rex.dwyer
If you want a random correlation matrix, why not just generate random data and accept the correlation matrix that you get? The standard normal distribution in k dimensions is (hyper)spherically symmetric. If you generate k standard normal N(0,1) variates, you have a point in k-space with direc

[R] non-finite function value

2011-02-10 Thread Claudio Carneiro
Hi, all I'm trying to solve an optimization problem with two variables, in wich I use the following functions(they all are working perfectly): FxMixedALT=function(x){calc=(-0.88*exp((-1.53655/1000)*(x^5.3)))-(0.12*exp(-0.06415*(x^2.5)))+0.88+0.12return(calc)} RxMixedALT=function(x){calc=1-FxM

Re: [R] Need help merging two dataframes

2011-02-10 Thread Nathaniel
Hi Dennis, Thanks for the solution, I really appreciate it! Best, Nathaniel -- View this message in context: http://r.789695.n4.nabble.com/Need-help-merging-two-dataframes-tp3297313p3299539.html Sent from the R help mailing list archive at Nabble.com.

[R] Prediction accuracy from Bagging with continuous data

2011-02-10 Thread Simon Gillings
I am using bagging to perform Bagged Regression Trees on count data (bird abundance in Britain and Ireland, in relation to climate and land cover variables). Predictions from the final model are visually believable but I would really like a diagnostic equivalent to classification success that ca

Re: [R] Problem with xlsx package

2011-02-10 Thread Nikhil Joshi
Gabor, thanks for the suggestion. I did as you have suggested- Started a clean session of R and set the java option. Then I sourced the library and tried to read the xlsx file but got the same error. I am assuming that Java machine is loaded when the package xlsx is sourced and not when the base

[R] about prediction with a factor

2011-02-10 Thread Zhao Jin
Hi, I don't know how to make prediction with a factor in the linear model. Say yd=c(1,2,3,4,5) > sl=c(2,3,4,5,6) > sex=c("male","male","female","female","male") > sex=factor(sex) > m=lm(sl~yd+sex+sex:yd) How to make a prediction with new data like yd=c(4,5,6,7,8) for male and female s

Re: [R] extracting characters from string

2011-02-10 Thread Henrique Dallazuanna
So, a way could be: gsub("(.*)_(.*)_(.*)_.*", "\\3", "abcd_efgh_X_12ab3_dfsfd") On Thu, Feb 10, 2011 at 3:47 PM, Soumendra wrote: > Hi Henrique, > > I believe your solution is wrong as it is fitted to find 12ab3, > whereas Yan seems to be asking for the characters after the second > unders

Re: [R] Revolution Analytics reading SAS datasets

2011-02-10 Thread David Smith
The SAS import/export feature of Revolution R Enterprise 4.2 isn't open-source, so we can't release it in open-source Revolution R Community, or to CRAN as we do with the ParallelR packages (foreach, doMC, etc.). It is, though, available for download free of charge to members of the academic commu

[R] hazard ratio between my groups

2011-02-10 Thread Angel Russo
HI, I am interested in calculating hazard ratio of the stratified groups defined by me. library(survcomp) binscores <- cut(scores.train,c(-1000,-1,1,1000),c("low","intermediate","high")) dd <- data.frame("surv.time"=OS, "surv.event"= status, "strat"=binscores) km.coxph.plot(formula.s=Surv(surv.t

Re: [R] Modifying a package name / Build from sources (rpart)

2011-02-10 Thread Ben Bolker
Simon Knos quantentunnel.de> writes: > Upfront: I am not sure if this is the right place to ask this question even > after reading through the FAQ, so apologies if I should have directed the > question elsewhere. I appreciate your confusion. I think this might be slightly more appropriate for

Re: [R] comparing proportions

2011-02-10 Thread Robert A LaBudde
prop.test() is applicable to a binomial experiment in each of two classes. Your experiment is binomial only at the subject level. You then have multiple subjects in each of your groups. You have a random factor "Subjects" that must be accounted for. The best way to analyze is a generalized li

[R] Question about the covariate Z in rhierMnlRwMixture (bayesm)

2011-02-10 Thread Dimitri Liakhovitski
Hello! I am using rhierMnlRwMixture from bayesm package. I would like to use it with a categorical covariate (Z). I have 2 clariciation questions: 1. If the covariate is categorical, do I have to represent it as dummy variable(s)? (e.g., 2 dummy variables for a 3-level categorical variable)? 2. D

Re: [R] highest and second highest value in row for each combination

2011-02-10 Thread Phil Spector
Alain - Here's a reproducible data set: set.seed(19) area<-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10)) type<-c(rep(1:10,5)) a<-rnorm(50) b<-rnorm(50) c<-rnorm(50) d<-rnorm(50) df<-cbind(area,type,a,b,c,d) First I'll make a helper function to operate on one row of the data frame:

Re: [R] Simulation of Multivariate Fractional Gaussian Noise and Fractional Brownian Motion

2011-02-10 Thread Kjetil Halvorsen
What you can do to find out is to type into your R session RSiteSearch("multivariate fractional gaussian") That seems to give some usefull results. Kjetil On Tue, Feb 8, 2011 at 1:51 PM, Wonsang You wrote: > > Dear R Helpers, > > I have searched for any R package or code for simulating multivar

Re: [R] extracting characters from string

2011-02-10 Thread Soumendra
Hi Henrique, I believe your solution is wrong as it is fitted to find 12ab3, whereas Yan seems to be asking for the characters after the second underscore and before the third underscore. For example, gsub(".*_.*_(.*)_.*", "\\1", "abcd_efgh_X_12ab3_dfsfd") would still yield 12ab3 even though,

Re: [R] Generate multivariate normal data with a random correlation matrix

2011-02-10 Thread Rick DeShon
Thanks for the response, Rex. This is an interesting approach. The Choleski decomposition approach that John suggested seems to be an obvious and direct approach to this problem. Your approach is less obvious to me but may be equal or superior to the Choleski decomposition. Are all possible cor

[R] comparing groups of proportions

2011-02-10 Thread array chip
Hi, I initially posted this to the general R mailing list, but Bert Gunter thought this may be a mixed model issue, so suggested me to post here. I have a dataset that has 2 groups of subjects. For each subject in each group, the response measured is the number of success (no.success) obatined w

[R] Hmisc errbar color

2011-02-10 Thread Robert Baer
Is there an easy way to make the error bars the same color as the points and lines they are plotted with. My example # fake data x=sample(1:10, 100, replace =T) y = rnorm(100) + runif(100) df=data.frame(x,y) # summarize data m = aggregate(df,list(x),mean) se = aggregate(df,list(x),sd)/sqrt(10) li

Re: [R] Loop to find dates whithin dates

2011-02-10 Thread Phil Spector
I can't see a good solution using a loop, but perhaps this will get you what you want: Dframe1$date = as.Date(Dframe1$sunrise) Dframe2$date = as.Date(Dframe2$Logtime) both = merge(Dframe1,Dframe2) both$when = ifelse(both$Logtime >= both$sunrise & +both$Logtime <= both$sunse

[R] Kernel and Machine Learning

2011-02-10 Thread Lorenzo Isella
Dear All, I am not that much into machine learning, but I know that R is wonderful at that. My problem is the following: consider a set of N individuals and an N by N symmetric matrix M. This matrix stands for an interaction between individuals, i.e. the element M[i,j]=M[j,i] is the (cumulative

[R] Modifying a package name / Build from sources (rpart)

2011-02-10 Thread Simon Knos
Dear List Members Upfront: I am not sure if this is the right place to ask this question even after reading through the FAQ, so apologies if I should have directed the question elsewhere. My problem as follows: I need a modified version of some existing R package. I am well able to make the mod

Re: [R] randomly generated binary matrix (with conditions)

2011-02-10 Thread Ben Bolker
Baptiste Coulmont yahoo.com> writes: > > I want to create a randomly generated 25*15 binary matrix knowing what the > colSums and rowSums of this matrix should be. > > colSums(a) > [1] 3 7 2 5 0 4 6 5 5 4 3 4 4 5... > rowSums(a) > [1] 8 6 6 6 6 6 5 5 5 5 4 4 4... > This is a fairly ch

Re: [R] Problem with xlsx package

2011-02-10 Thread Gabor Grothendieck
On Thu, Feb 10, 2011 at 10:49 AM, Nikhil Joshi wrote: > Gabor, > thanks for the suggestion. > I did as you have suggested- Started a clean session of R and set the java > option.  Then I sourced the library and tried to read the xlsx file but got > the same error.  I am assuming that Java machine

Re: [R] modifynig some elements of a vector

2011-02-10 Thread William Dunlap
Try using tabulate() instead of table(). E.g., compare your original f0 <- function (x, u) { tu <- table(u) indices <- as.numeric(names(tu)) x[indices] <- x[indices] + tu x } to f1 <- function (x, u) { x + tabulate(u, nbins = length(x)) } I tried it for a 20-

Re: [R] Conditional sampling

2011-02-10 Thread Duncan Murdoch
On 10/02/2011 11:02 AM, Hosack, Michael wrote: R experts, I need to sample two rows without replacement from the following data frame such that neither row contains the same 'DOW'. For example, I cannot select both a Monday morning and a Monday afternoon. I am using STRATA_NUM as an index to r

[R] randomly generated binary matrix (with conditions)

2011-02-10 Thread Baptiste Coulmont
I want to create a randomly generated 25*15 binary matrix knowing what the colSums and rowSums of this matrix should be. colSums(a) [1] 3 7 2 5 0 4 6 5 5 4 3 4 4 5... rowSums(a) [1] 8 6 6 6 6 6 5 5 5 5 4 4 4... . . Baptiste Coulmont coulm...@yahoo.com

[R] Conditional sampling

2011-02-10 Thread Hosack, Michael
R experts, I need to sample two rows without replacement from the following data frame such that neither row contains the same 'DOW'. For example, I cannot select both a Monday morning and a Monday afternoon. I am using STRATA_NUM as an index to randomly select rows from, since this variable

[R] Help using "tm" text mining package - preprocessing

2011-02-10 Thread dunner
Thanks all for your help. I fear text mining is an abstract little corner of "R". I have imported 3228 text (.txt) files, each a news story, into R using [tm]: textd <- Corpus(DirSource("other/docs"), readerControl = list(reader =readPlain)) I can pre-process each individual document using tolo

  1   2   >