[R] Find peaks in dataset(x,y) and area for each peak

2011-02-17 Thread Ramya
http://r.789695.n4.nabble.com/file/n3312061/x_and_y_values.txt x_and_y_values.txt I have the absorbance values form HPLC Chromatogram. I need to find the peaks in datapoints and area under each peak. I am not sure how how to find the peaks, I tried couple of libraries and peak function but the

Re: [R] CDF of Sample Quantile

2011-02-17 Thread Bentley Coffey
Duncan, I'm not sure how I missed your message. Sorry. What you describe is what I do when (n-1)p is an integer so that R computes the sample quantile using a single order statistic. My later posting has that exact binomial expression in there as a special case. When (n-1)p is not an integer then

[R] How to change dataframe to tables

2011-02-17 Thread Lao Meng
The data is in the attachment. What I wanna get is: , , Sex = Male Eye HairBrown Blue Hazel Green Black32 1110 3 Brown53 502515 Red 10 10 7 7 Blond 3 30 5 8 , , Sex = Female Eye HairBrown Blue Hazel Green Blac

Re: [R] xyplot formula

2011-02-17 Thread Geoff Russell
On Fri, Feb 18, 2011 at 5:42 PM, Phil Spector wrote: > Geoff - > I think this will get you closer to a solution: > Yes, much closer, many thanks. Geoff. > > newdf = reshape(df,varying=names(df)[-c(1,2)],direction='long', >times=2000:2003,idvar=c('country','food'),v.names='X',

Re: [R] xyplot formula

2011-02-17 Thread Phil Spector
Geoff - I think this will get you closer to a solution: newdf = reshape(df,varying=names(df)[-c(1,2)],direction='long', times=2000:2003,idvar=c('country','food'),v.names='X', timevar='year') xyplot(X~year|country*food,data=newdf)

Re: [R] problem with rbind when data frame contains an date-time variable "POSIXt" "POSIXlt"

2011-02-17 Thread Andrew Anglemyer
Thanks again for your help. I was sniffing around this solution forever, but that did it cleanly and without any problems. On Thu, Feb 17, 2011 at 10:21 PM, wrote: > The solution is probably to make the data-time columns POSIXct: > > > x <- read.table(textConnection(" > + ID event.date.ti

[R] xyplot formula

2011-02-17 Thread Geoff Russell
df=data.frame(country=c("A","A","A","B","B","B"), food=rep(c("Apples","Pears","Bananas"),2), X2000=c(4,5,6,7,6,8), X2001=c(4,5,6,7,6,8), X2002=c(4,5,6,7,6,8), X2003=c(4,5,6,7,6,8)); I have data in the above form trying to get a plot of each fruit over time year conditioned on c

Re: [R] problem with rbind when data frame contains an date-time variable "POSIXt" "POSIXlt"

2011-02-17 Thread Bill.Venables
The solution is probably to make the data-time columns POSIXct: > x <- read.table(textConnection(" + ID event.date.time + 1 '2009-07-23 00:20:00' + 2 '2009-08-18 16:25:00' + 3 '2009-08-13 08:30:00' + "), header = TRUE) > y <- read.table(textConnection(" + ID event.date.time + 4

[R] problem with rbind when data frame contains an date-time variable "POSIXt" "POSIXlt"

2011-02-17 Thread Andrew Anglemyer
I'm trying to rbind two data frames, both with the same columns names. One of the columns is a variable with date-time and this variable is causing the rbind to fail--giving the error "Error in names(value[[jj]])[ri] <- nm : 'names' attribute [7568] must be the same length as the vector [9]" Is

Re: [R] recoding a data in different way: please help

2011-02-17 Thread Dennis Murphy
Hi: This is as far as I could get: df <- read.table(textConnection(" Individual Parent1 Parent2 mark1 mark2 10 0 12 11 20 0 11 22 30 0 13 22 40 0 13 11 51 2

Re: [R] recoding a data in different way: please help

2011-02-17 Thread Joshua Wiley
Dear Umesh, I could not figure out exactly what your recoding scheme was, so I do not have a specific solution for you. That said, the following functions may help you get started. ?ifelse # vectorized and different from using if () statements ?if # ?Logic ## logical operators for your tests ##

Re: [R] Integrate with an indicator function

2011-02-17 Thread li li
Hi Dennis, Thank you for your kind reply. Yes, essentially, we take integration twice. However, I still have a few questions: First, if we consider doing a double integration at the end, since the first integration in within the indicator function, it seems to be difficult. Second, m1star is

[R] recoding a data in different way: please help

2011-02-17 Thread Umesh Rosyara
Dear R users The following question looks simple but I have spend alot of time to solve it. I would highly appeciate your help. I have following dataset from family dataset : Here we have individuals and their two parents and their marker scores (marker1, marker2,and so on). 0 means t

Re: [R] Transforming relational data

2011-02-17 Thread Matthew Dowle
Mathijs, To my eyes you seem to have repeated back what is already done. More R and less English would help. In other words if it is not 2.5 you need, what is it? Please provide some input and state what the output should be (and what you tried already). Matthew -- View this message in contex

Re: [R] Using Weights in R

2011-02-17 Thread Phil Spector
Well, if you really want to produce what SAS does: ageval = read.table(textConnection('AgeCat FINWT + 1 98 + 2 62 + 1 75 + 3 39 + 4 28 + 2 47 + 2 66 + 4 83 + 1 19 + 3 50 + '),header=TRUE) one = aggregate(ageval$FINWT,ageval['AgeCat'],sum) two = prop.table(as.table(one$x)) * 100 three = cumsum(

Re: [R] logsumexp function in R

2011-02-17 Thread Spencer Graves
On 2/17/2011 3:49 PM, William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky Sent: Wednesday, February 16, 2011 10:46 PM To: r-help@r-project.org Subject: Re: [R] logsumexp function in R On Wed, Feb 16,

[R] Using Weights in R

2011-02-17 Thread Krishnan Viswanathan
I am new to R. I have a data set like this (given below is a fictional dataset): AgeCat FINWT 1 98 2 62 1 75 3 39 4 28 2 47 2 66 4 83 1 19 3 50 I need to calculate the weighted distribution of the variable AgeCat. In SAS i can do: proc freq data=ageval; tables agecat; weight finwt; run; Wha

[R] RCurl HTTP Post ?

2011-02-17 Thread Hasan Diwan
According to [1] and [2], using RCurl to post a form with basic authentication is done using the postForm method. I'm trying to post generated interpolation data from R onto an HTTP form. The call I'm using is page <- postForm('http://our.server.com/dbInt/new', opts = curlOptions=(userpwd="test:tes

Re: [R] sort by column and row names

2011-02-17 Thread Jim Moon
Yes, that is it. Thank you very much, Phil. -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Thursday, February 17, 2011 3:36 PM To: Jim Moon Cc: r-help@r-project.org Subject: Re: [R] sort by column and row names Jim - I believe dat[order(rownames(d

Re: [R] logsumexp function in R

2011-02-17 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky > Sent: Wednesday, February 16, 2011 10:46 PM > To: r-help@r-project.org > Subject: Re: [R] logsumexp function in R > > On Wed, Feb 16, 2011 at 04:14:38PM -0500, Bri

Re: [R] sort by column and row names

2011-02-17 Thread Phil Spector
Jim - I believe dat[order(rownames(dat)),order(colnames(dat))] is what you are looking for. - Phil Spector Statistical Computing Facility Department of Statistics

[R] sort by column and row names

2011-02-17 Thread Jim Moon
Hello, All, How can one sort on column and row names. For example: How can this X1 X3 X2 X1 1 0 0 X3 0 1 0 X2 0 0 1 become this? X1 X2 X3 X1 1 0 0 X2 0 1 0 X3 0 0 1 Thank you for your time! Jim [[alternative H

Re: [R] convert the sas file into csv in R

2011-02-17 Thread Joshua Wiley
Hi yf, On Thu, Feb 17, 2011 at 2:35 PM, yf wrote: > > i am trying to convert sas file into csv. I used write.csv(a, > file="cool.csv") but nothing come out. i don't know why. Thanks. > > > library(Hmisc) > a<- sasxport.get("C:\\Users\.") Let's back up a little bit. What type of file are you

Re: [R] convert the sas file into csv in R

2011-02-17 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of yf > Sent: Thursday, February 17, 2011 2:35 PM > To: r-help@r-project.org > Subject: [R] convert the sas file into csv in R > > > i am trying to convert sas file into csv. I use

[R] convert the sas file into csv in R

2011-02-17 Thread yf
i am trying to convert sas file into csv. I used write.csv(a, file="cool.csv") but nothing come out. i don't know why. Thanks. library(Hmisc) a<- sasxport.get("C:\\Users\.") write.csv(a, file="cool.csv") -- View this message in context: http://r.789695.n4.nabble.com/convert-the-sas-file-in

[R] Problem with writing a file in UTF-8

2011-02-17 Thread tpklein
Hello, I am working with a data frame containg character strings with many special symbols from various European languages. When writing such character strings to a file using the UTF-8 encoding, some of them are converted in a strange way. See the following example, run in R 2.12.1 on Windows

[R] cv.glmnet errors

2011-02-17 Thread Brian Tsai
Hi, I am trying to do multinomial regression using the glmnet package, but the following gives me an error (for no reason apparent to me): library(glmnet) cv.glmnet(x=matrix(c(1,2,3,4,5,6,1,2,3,4,5,6), nrow=6),y=as.factor(c(1,2,1,2,3,3)),family='multinomial',alpha=0.5, nfolds=2) The error i get

Re: [R] Integrate with an indicator function

2011-02-17 Thread Dennis Murphy
Hi Hannah: You have a few things going on, but the bottom line is that numer and denom are both double integrals. On Thu, Feb 17, 2011 at 1:06 PM, li li wrote: > Hi all, > I have some some problem with regard to finding the integral of a > function containing an indicator function. > please s

Re: [R] Populate a list / recursively set list values to NA

2011-02-17 Thread Gene Leynes
Works perfectly, thank you! On Thu, Feb 17, 2011 at 4:11 PM, Erik Iverson wrote: > Gene, > > ?rapply is a recursive version of ?lapply, and should work. > > rapply(masterlist, function(x) x*NA, how = "replace") > > > --Erik > > Gene Leynes wrote: > >> Hello all, >> >> Maybe I'm being thick, but

Re: [R] tikzDevice compiling problem

2011-02-17 Thread Yihui Xie
I don't think tikz() can capture the plots in rgl. To export rgl graphics, you need to use rgl.snapshot() or rgl.postscript(). Regards, Yihui -- Yihui Xie Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Feb 16, 201

Re: [R] using the bootstrap method for latent class analysis

2011-02-17 Thread David Duffy
My main question is: can the bootstrap procedure sometimes be less precise than the non-bootstrap procedure when carrying out latent class analysis? I am asking this question because I carried out some analyses and when I *did not* use the bootstrap procedure I found adequate fit for one of

Re: [R] Populate a list / recursively set list values to NA

2011-02-17 Thread Erik Iverson
Gene, ?rapply is a recursive version of ?lapply, and should work. rapply(masterlist, function(x) x*NA, how = "replace") --Erik Gene Leynes wrote: Hello all, Maybe I'm being thick, but I was trying to figure out a simple way to create a list with the same dimension of another list, but popul

Re: [R] which functions are being debugged?

2011-02-17 Thread Shi, Tao
Hi Henrique, Thanks for the reply! I posted the question in a hurry yesterday. After a bit research today, I found that back in 2009, Andrew actually asked the same question and there was a good discussion about it: http://r.789695.n4.nabble.com/how-do-you-know-which-functions-are-being-debu

[R] RGtk2 on Debian Testing

2011-02-17 Thread Lorenzo Isella
Dear All, I am running Debian testing on my system for the amd64 architecture, When trying to install the RGtk package I get this error > install.packages('RGtk2') Installing package(s) into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'http://rm.mirror.garr.it/mirrors/C

[R] Populate a list / recursively set list values to NA

2011-02-17 Thread Gene Leynes
Hello all, Maybe I'm being thick, but I was trying to figure out a simple way to create a list with the same dimension of another list, but populated with NA values. masterlist = list( aa=list( a=matrix(rnorm(100),10,10), b=matrix(rnorm(130)

Re: [R] barplot with errorbars

2011-02-17 Thread Marc Schwartz
Aldi, Thanks for the reference to the R News article. That seems like a lifetime ago... :-) As an exercise in learning to use R's base graphics and some of the concepts of manipulating and annotating base R plots, it is a decent intro. That being said, unless pressured (eg. weapon pointing at

Re: [R] need tick marks by 10s or 20s up to 200 on x axis

2011-02-17 Thread Joshua Wiley
Hi Julie, Here is a little example. First I make a histogram (it looks odd because there isn't much data), then add the x axis in manually specifying at what points to place tick marks. ## histogram suppressing x axis hist(c(0, 200), xaxt = "n") ## add axis with custom ticks axis(1, at = seq(0,

Re: [R] sampling

2011-02-17 Thread Dennis Murphy
Hi: A couple more approaches to consider: # Utility function to extract two rows from a data frame # Meant to be applied to each data subset sampler <- function(d) if(nrow(d) > 2) d[sample(1:nrow(d), 2, replace = FALSE), ] else d library(plyr) > ddply(x, 'id', sampler) id v1 V2 1 1 2 13 2 1

[R] need tick marks by 10s or 20s up to 200 on x axis

2011-02-17 Thread Julie McWhorter
I haven't been able to get any code to make more tick marks than the default by 50. Thanks! Code: hist(OMY$FL, main = "2010 Oncorhynchus mykiss Fork Length Frequencies at Buck Creek Reach 1", include.lowest = TRUE, col = "blue", border = "white", breaks = 140,xlab = "Fork Length in mm", ylab

[R] need tick marks by 10s or 20s up to 200 on x axis

2011-02-17 Thread juliemcwh
Sorry, I have read other posts on tick marks but nothing is working. Here is my R code. I was able to turn off the x axis at one point (I removed that code), but never got the tick marks on by 20s. It always goes to the default of 50, 100, 150, 200. Thanks. R code: hist(OMY$FL, main = "2010 O

[R] Credible intervals for Bayesian Model Averaging using the BAS package

2011-02-17 Thread matthewnkim
Dear all, I am using the BAS package to make predictions using the predict.bma function. Does anyone know how to calculate credible intervals for predictions from objects of class bma? It seems like all of the required information is available from the bma class objects and/or output from the pr

Re: [R] summing 15 minute precip data to daily

2011-02-17 Thread Gabor Grothendieck
On Thu, Feb 17, 2011 at 3:39 PM, Stephen Sefick wrote: > Janet: > > The zoo package and aggregate.zoo should do the trick.  I have done this > many times with these tools. Here is some code. Suppose precip is the data. We convert it to a zoo object with date/times assuming the first one is at th

Re: [R] barplot with errorbars

2011-02-17 Thread William Revelle
As the FAQ (http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-put-error-bars-or-confidence-bands-on-my-plot_003) says, there are about 5 different packages that will draw error bars. At 2:38 PM -0600 2/17/11, Aldi Kraja wrote: Hi Toby and Maria, I did a check on Toby's suggestion and i

[R] Integration with an Indicator Function in R

2011-02-17 Thread li li
Hi all, I have some some problem with regard to finding the integral of a function containing an indicator function. please see the code below: func1 <- function(x, mu){ (mu^2)*dnorm(x, mean = mu, sd = 1)*dgamma(x, shape=2)} m1star <- function(x){ integrate(func1, lower = 0, upper = Inf,x)

[R] Integrate with an indicator function

2011-02-17 Thread li li
Hi all, I have some some problem with regard to finding the integral of a function containing an indicator function. please see the code below: func1 <- function(x, mu){ (mu^2)*dnorm(x, mean = mu, sd = 1)*dgamma(x, shape=2)} m1star <- function(x){ integrate(func1, lower = 0, upper = Inf,x

[R] Data frame sampling

2011-02-17 Thread Hosack, Michael
R users, I have been trying to write a program in R that will extract rows from a data frame and combine the rows into a new smaller data frame while meeting several criteria. I would greatly appreciate any advice that could help me get started down the right path. What I want to do is to ext

[R] [R-pkgs] New version of rms package on CRAN

2011-02-17 Thread Frank Harrell
A new version of rms is now available on CRAN for Linux/UNIX. I expect Mac and Windows versions to be available in a day or so. This version works with and requires the newest version of Therneau's survival package. More information is at http://biostat.mc.vanderbilt.edu/Rrms Changes in ve

Re: [R] A very basic line-plot question

2011-02-17 Thread Phil Spector
The reason that it's easy to produce dotcharts or barplots in R with data like yours, and difficult to produce a line plot, is because dotcharts and barplots are appropriate for your data, whereas a line plot is not. Since the values on the x-axis represent names, and those names are not measur

Re: [R] barplot with errorbars

2011-02-17 Thread Aldi Kraja
Hi Toby and Maria, I did a check on Toby's suggestion and it is not there: R version 2.12.1 (2010-12-16) > ??barploterrbar No help files found with alias or concept or title matching 'barploterrbar' using fuzzy matching. Also I went to the following location which does not exist. http://www.dkf

Re: [R] A very basic line-plot question

2011-02-17 Thread Jinyan Huang
dat<-c(150,152,155,134,141) plot(dat,type="o",ylim=c(100,160),xlab="Names",ylab="Height") On Thu, Feb 17, 2011 at 7:45 PM, world peace wrote: > Hi All > > I have data like this > >              tom   randy mike dan doug > height       150   152     155  134 141 > > I am trying to create a line pl

Re: [R] sampling

2011-02-17 Thread David Winsemius
On Feb 17, 2011, at 1:33 PM, andrija djurovic wrote: This is, maybe, not the best solution but I hope it will help you: x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23)) do.call("rbind",by(x,x$id,function(x) x[c(sample(nrow(x),2)),])) Andrija Another way (and note that

Re: [R] summing 15 minute precip data to daily

2011-02-17 Thread Stephen Sefick
Janet: The zoo package and aggregate.zoo should do the trick. I have done this many times with these tools. HTH, Stephen On Thu, 2011-02-17 at 11:56 -0800, Janet Choate wrote: > Hi all, > i'm sure there is an easy way to do this, but i'm stumped, so any help would > be appreciated. > > i have

Re: [R] Urgent Request

2011-02-17 Thread Ben Bolker
muhammad mohsin yahoo.com> writes: > Hope you will be fine. I am student of Ph.D and doing ' > some work on distribution. > I developed a new distribution and having some problems in estimating their > parameters by MLE. I used R-program and  used "maxLik" function (maxLik: A > Package for Max

[R] missing values in party::ctree

2011-02-17 Thread Andrew Ziem
After ctree builds a tree, how would I determine the direction missing values follow by examining the BinaryTree-class object? For instance in the example below Bare.nuclei has 16 missing values and is used for the first split, but the missing values are not listed in either set of factors. (

Re: [R] summing 15 minute precip data to daily

2011-02-17 Thread Joshua Wiley
Hi Janet, One relatively simple way would be to transofrm the data into a 96 x Ndays matrix and use colSums(). Of course, lets say on one day, the measurement tool had technical difficulties and missed two observations, then you only have 94 observations for that day, you will need a fancier solu

[R] summing 15 minute precip data to daily

2011-02-17 Thread Janet Choate
Hi all, i'm sure there is an easy way to do this, but i'm stumped, so any help would be appreciated. i have a single column of data for precipitation every 15 minutes over a year. i want to sum the precip to daily data. so the first 96 records = the first day, the second 96 records = the second d

[R] A very basic line-plot question

2011-02-17 Thread world peace
Hi All I have data like this tom randy mike dan doug height 150 152 155 134 141 I am trying to create a line plot, with names on X-axis and height measure on Y. how can i get it through R. I could get several versions which are close (dotchart, bargraph), but not qui

[R] Indentify polygons that are on the border of a shapefile

2011-02-17 Thread Leonardo Monasterio
Dear R users, I would like to know how to indentify the polygons that are located on the border of a map (i.e.shapefile). Do you have any suggestion on how to do it? Thank you very much, Leo Monasterio. [[alternative HTML version deleted]] __

Re: [R] Multivariate BLUP

2011-02-17 Thread Muhammad Yaseen
*Dear All,* *I'm trying to do Multivariate BLUP in R. I'd highly appreciate if someone can share R code and data for Multivariate BLUP. Thanks* * * *Regards! * -- * Muhammad Yaseen * [[alternative HTML version deleted]] __ R-help@r-project.org

[R] Predictive Analytics with R, PMML and ADAPA

2011-02-17 Thread MZ
This is a presenation from the R Users Group (Bay Area) Covers building predictive analytic models in R, exporting in PMML and using ADAPA for model deployment and execution. Introduction to the Predictive Model Markup Language (PMML) standard and how it helps to overcome memory and speed limitat

Re: [R] Pre-allocation of matrices is LESS efficient?

2011-02-17 Thread Duncan Murdoch
On 17/02/2011 11:02 AM, Alex F. Bokov wrote: Motivation: during each iteration, my code needs to collect tabular data (and use it only during that iteration), but the rows of data may vary. I thought I would speed it up by preinitializing the matrix that collects the data with zeros to what I

Re: [R] sampling

2011-02-17 Thread andrija djurovic
This is, maybe, not the best solution but I hope it will help you: x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23)) do.call("rbind",by(x,x$id,function(x) x[c(sample(nrow(x),2)),])) Andrija On Thu, Feb 17, 2011 at 6:39 PM, yf wrote: > > But i need for each id have two data

Re: [R] Pre-allocation of matrices is LESS efficient?

2011-02-17 Thread Douglas Bates
On Thu, Feb 17, 2011 at 10:02 AM, Alex F. Bokov wrote: > Motivation: during each iteration, my code needs to collect tabular data (and > use it only during that iteration), but the rows of data may vary. I thought > I would speed it up by preinitializing the matrix that collects the data with >

[R] censoring symbols on survfit plot

2011-02-17 Thread threshold
Hi, when ploting Kaplan-Meier estimate curves as below, the censoring symbols (crosses) to not change thickness along the lines plot(survfit(surv ~ I(x>=cut.off) ),lty=c(1,2), lwd=2) is there any strightforward way to make it happen? thanks robert -- View this message in context: http://r.789

[R] Urgent Request

2011-02-17 Thread muhammad mohsin
Dear Colleagues, Hope you will be fine. I am student of Ph.D and doing some work on distribution. I developed a new distribution and having some problems in estimating their parameters by MLE. I used R-program and  used "maxLik" function (maxLik: A Package for Maximum Likelihood Estimation in R

Re: [R] incomplete final line

2011-02-17 Thread Joshua Wiley
On Thu, Feb 17, 2011 at 12:35 AM, mipplor wrote: > > thx for your suggestions , i have made it csv file,and it looks: > > >> data<‐read.table('E:/my documents/r/1.csv',header=TRUE) It looks like you could benefit from (re)reading my previous email. You either need to specify the sep = argument in

Re: [R] exact logistic regression

2011-02-17 Thread Łukasz Ręcławowicz
I believe that this code will work (...for very small) samples, but let some correct me if there is something wrong. require(logistf);require(combinat) permY<-permn(data$y) ntimes<-length(permY) results<-matrix(nrows=ntimes,ncols=number_of_coefficients) for(i in 1:ntimes){ results[i,]<-logistf(unl

Re: [R] sampling

2011-02-17 Thread yf
But i need for each id have two data. Like... > x id v1 V2 1 1 1 12 2 1 2 13 4 2 4 15 5 2 5 16 8 3 8 19 9 3 9 20 11 4 11 22 12 4 12 23 So should write sample( if sample id >2 ,2). I don't know how to write (if sample id >2). Thanks. -- View this message in context:

Re: [R] How to speed up a for() loop

2011-02-17 Thread Phil Spector
Simona - I don't think preallocating your random variables would make the code run any faster. A very simple change that would speed things up a little would be to replace simPD.vec[i]=length(R.vec[R.vec Dear all, Does anyone have any idea on how to speed up the for() loop below. Current

Re: [R] Find and replace all the elements in a data frame

2011-02-17 Thread Gong-Yi Liao
You may write as this: for (i in 1:nrow(x)){ for (j in 1:ncol(x)){ if (!is.na(x[i, j])) { if(x[i, j] == 'A') {x2[i, j] <- 'A/A'} else{ if(x[i, j] == 'T') {x2[i, j] <- 'T/T'} else{ if(x[i, j] == 'G') {x2[i, j] <- 'G/G'} else{

Re: [R] removing lower and upper quantiles from an arry

2011-02-17 Thread Greg Snow
In addition to the other answers that you received you can also do: library(TeachingDemos) i[ quantile(i,.25) %<% i %<% quantile(i,.75) ] This may or may not be more readable than the others. Also note that precomputing both quantiles in one step may be faster than calling quantile twice. You

[R] color.scale error

2011-02-17 Thread Alaios
Dear all when I call color.scale like this: require('plotrix') colcolor<-color.scale(c(range_sr,sr),extremes=c("red","blue")) Error in if (min(reds) < 0 || max(reds) > 1) reds <- rescale(reds, c(0, : missing value where TRUE/FALSE needed range_sr [1] -10.00 44.02977813958366

Re: [R] Find and replace all the elements in a data frame

2011-02-17 Thread baptiste auguie
Hi, You could use car::recode to change the levels of the factors, library(car) transform(x, locus1 = recode(locus1, "'A' = 'A/A' ; else = 'T/T'"), locus2 = recode(locus2, "'T'='T/T' ; 'C' = 'C/C'"), locus3 = recode(locus3, "'C'='C/C' ; 'G' = 'G/G'")) HTH

Re: [R] Find and replace all the elements in a data frame

2011-02-17 Thread Henrique Dallazuanna
Try this: xNew <- as.data.frame(mapply(paste, x, x, sep = "/")) xNew[is.na(x)] <- NA xNew On Thu, Feb 17, 2011 at 2:54 PM, Josh B wrote: > Hi all, > > I'm having a problem once again, trying to do something very simple. > Consider > the following data frame: > > x <- read.table(textConnection("

Re: [R] Find and replace all the elements in a data frame

2011-02-17 Thread Sarah Goslee
Josh, you've made it far too complicated. Here's one simpler way (note that I changed your read.table statement to make the values NOT factors, since I wouldn't think you want that). > x <- read.table(textConnection("locus1 locus2 locus3 + A T C + A T NA + T C C + A T G"), header = TRUE, as.is=TRU

[R] Find and replace all the elements in a data frame

2011-02-17 Thread Josh B
Hi all, I'm having a problem once again, trying to do something very simple. Consider the following data frame: x <- read.table(textConnection("locus1 locus2 locus3 A T C A T NA T C C A T G"), header = TRUE) closeAllConnections() I am trying to make a new data frame, replacing "A" with "A/A", "

Re: [R] covar

2011-02-17 Thread rex.dwyer
I hate to sound like David "Have You Read The Posting Guide?" Winsemius, but there's no way for anyone to know what you are trying to accomplish here without a lot more information. You don't show us the output you expect and the output you got. I would expected "relatedness" to be on a scale

Re: [R] Transforming relational data

2011-02-17 Thread mathijsdevaan
Thanks for helping me out so generously. After reading the vignettes and the other info I still have a question (sorry I am a R novice): I am not so much trying to construct time series (although it comes very close). Rather for each pair (Bi,Bj) in project (An) I am trying to sum up the values o

Re: [R] barplot with errorbars

2011-02-17 Thread Toby Marthews
If you google "barplot with error bars" you immediately find http://svitsrv25.epfl.ch/R-doc/library/prada/html/barploterrbar.html . Toby. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Lathouri, Maria [m.lathour...@imperial

Re: [R] Dependency on R-Forge Package

2011-02-17 Thread Prof Brian Ripley
On Thu, 17 Feb 2011, Uwe Ligges wrote: On 17.02.2011 15:29, Damian Betebenner wrote: In building a package, is it possible to make the package depend upon another package that is only available on R-Forge (not CRAN). For example, by doing something in the DESCRIPTION file I'd like to add a d

Re: [R] VAR with HAC

2011-02-17 Thread Marta Lachowska
Thank you for your hint! I see that there was a thread discussing implementation of what I wanted to do (Newey-West standard errors in a VAR context), but that there is a conflict due to how the type = "const" is defined in the VAR command: https://stat.ethz.ch/pipermail/r-sig-finance/2009q2/00427

[R] Multi-response MCMCglmm (gaussian and zapoisson)

2011-02-17 Thread Susanne Lachmuth
Dear MCMCglmm users, I am currently struggling with the specification of a proper prior and model formula for a multi-response MCMCglmm with two of the three response variables being Gaussian and the third being za-poisson. The model includes several fixed effects and three nested random effect

[R] How to speed up a for() loop

2011-02-17 Thread simona.costanzo
Dear all, Does anyone have any idea on how to speed up the for() loop below. Currently it takes approximately 2 minutes and 30 seconds. Because of the size of Nsim and N, simulating a multivariate normal (instead of simulating Nsim times a vector of N normal distributions) would require too much

[R] VGAM in R

2011-02-17 Thread Weichao Bao
I am using VGAM package to model a multinormial outcome with spline function. But from the following result, I only can get p-value for variable with spline function, such as s(As). However, there is no p-value available for variable with linear function, such as SEX, Parity. Does anybody know why?

[R] ggplot2, 'se' variable in geom_errorbar's limits?

2011-02-17 Thread Eric Fail
Dear R-list I'm working with with geom_errorbar; specifically I'm trying to reproduce the example Hadley Wickham have on http://had.co.nz/ggplot2/geom_errorbar.html (all in the button of the page) where he makes an nice plot with errorbars and then draw lines between the points. What confuses me

Re: [R] calling pairs of variables into a function

2011-02-17 Thread rex.dwyer
Try putting d,e,f in a list: Xxx = list(d,e,f) For (I in 1:length(xxx)) For (j in 1:length(xxx)) If (i!=j) bigfunction(xxx[[i]],xxx[[j]]) (bad indentation, caps thanks to outlook) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of s

[R] [BioC] Make.cdf.package error

2011-02-17 Thread elodiem
Hi everybody, I tried to analyze a custom Affymetrix 3'-biased Array. So I wanted to make a cdf package. (My CDF file size is 1.12Go). I tried several methods but the same error occured Method 1 > #Set the working directory > setwd("D:/Analyse R/Cel files") > #library to create cdf env >

[R] deriving waveform values

2011-02-17 Thread whizevans
Im am curerntly trying to use R software to extract uncompressed waveform values with I have acquired from IDLreadGLAS tool. I am very lost with this & know I have to assess the GLA01 product data, however, any advice on the matter atall would be brilliant, particularly on define thresholds and co

Re: [R] Categorical Variables and Machine Learning

2011-02-17 Thread Andrew Ziem
Try the function ctree() in the package party or earth() in earth. You can use factor variable as is, or you can transform the factor to binary variables (i.e., is_P is 0 or 1, is_D is 0 or 1). In the second case, you can use any algorithm, and earth() automatically transforms factors to bina

[R] Pre-allocation of matrices is LESS efficient?

2011-02-17 Thread Alex F. Bokov
Motivation: during each iteration, my code needs to collect tabular data (and use it only during that iteration), but the rows of data may vary. I thought I would speed it up by preinitializing the matrix that collects the data with zeros to what I know to be the maximum number of rows. I was su

Re: [R] VAR with HAC

2011-02-17 Thread Pfaff, Bernhard Dr.
Hello Marta, arrg, sorry, I have not carefully enough read your message. Well, if you follow the cited thread further down, you will find: (and hereby directly quoting from: https://stat.ethz.ch/pipermail/r-sig-finance/2009q2/004274.html) <> On Tue, 9 Jun 2009, Matthieu Stigler wrote: > Hi

Re: [R] barplot with errorbars

2011-02-17 Thread Mohamed Lajnef
Hi Maria, Look at barplot function ? barplot for help Regards M Le 17/02/11 17:00, Lathouri, Maria a écrit : > Dear all > > I have six variables of the average metal concentrations > > Var1 4.77 > Var2 23.5 > Var3 5.2 > Var4 12.3 > Var5 42.1 > Var6 121.2 > > I want to plot them as a barplot wi

[R] barplot with errorbars

2011-02-17 Thread Lathouri, Maria
Dear all I have six variables of the average metal concentrations Var1 4.77 Var2 23.5 Var3 5.2 Var4 12.3 Var5 42.1 Var6 121.2 I want to plot them as a barplot with error bars. Could you help me? Cheers Maria [[alternative HTML version deleted]]

Re: [R] does range of values in array include a third value?

2011-02-17 Thread David Winsemius
On Feb 17, 2011, at 10:36 AM, Maas James Dr (MED) wrote: I'm using the range command to get the minimum and maximum values of an array as in x <- range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For ex

Re: [R] does range of values in array include a third value?

2011-02-17 Thread Peter Ehlers
On 2011-02-17 07:36, Maas James Dr (MED) wrote: I'm using the range command to get the minimum and maximum values of an array as in x<- range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For example I'd like

[R] does range of values in array include a third value?

2011-02-17 Thread Maas James Dr (MED)
I'm using the range command to get the minimum and maximum values of an array as in x <- range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For example I'd like to query 1) does the range of -2 to 9 include 3,

Re: [R] Dependency on R-Forge Package

2011-02-17 Thread Uwe Ligges
On 17.02.2011 15:29, Damian Betebenner wrote: In building a package, is it possible to make the package depend upon another package that is only available on R-Forge (not CRAN). For example, by doing something in the DESCRIPTION file I'd like to add a dependency to my package such that when t

Re: [R] Saturated model in binomial glm

2011-02-17 Thread Giovanni Petris
Dear Bill, Thank you very much for your careful discussion of the issue. It is not surprising that the deviance is the same whether you fit the model using a factor response with weights or individual 0/1 responses. I think this happens because the fitted probabilities in the saturated models are

[R] does range of values in array include a third value?

2011-02-17 Thread Maas James Dr (MED)
I'm using the range command to get the minimum and maximum values of an array as in x <- range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For example I'd like to query 1) does the range of -2 to 9 include 3

Re: [R] Cannot allocate memory block

2011-02-17 Thread Uwe Ligges
On 16.02.2011 22:38, poisontonic wrote: Uwe Ligges-3 wrote: If the available space got too fragmented, there is not single 3.8 block of memory available any more Is there anything I can do to prevent this? If you did it after a fresh reboot: I don't see a way to prevent it. Neverth

  1   2   >