[R] sampling

2011-02-17 Thread yf
I want to sample from the ID. For each ID, i want to have 2 set of data. I try the sample() function but it didn't work. 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)) x id v1 V2 1 1 1 12 2 1 2 13 3 1 3 14 4 2 4 15 5 2 5 16 6 2 6 17 7 2 7 18 8 3

Re: [R] help needed for strptime 000000 !

2011-02-17 Thread JESSICA
Hi thanks ! that works perfectly ! now I am wodering how to create a new table , I run the codes: x-read.table(C:/R/DATA.txt,colClasses=c(Date,character,integer), header=T) DateTime-as.POSIXct(paste(x[,1],x[,2]),format=%Y-%m-%d%H%M%S) and get : 2004-11-01 23:33:11 GMT 2004-11-01 23:42:27

[R] darcs patch: Apply on data frame

2011-02-17 Thread Mr rong chen
Hi, I am using a very simple R function to get each row from the attached file and run Wilcox.test between columns 1-3 and 4-12. However, I keep getting an error message. The data files is attached. Any suggestion? Thank you. Rong Error message: +   return c$p.value Error: unexpected

Re: [R] incomplete final line

2011-02-17 Thread mipplor
thx for your suggestions , i have made it csv file,and it looks: data‐read.table('E:/my documents/r/1.csv',header=TRUE) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 2 elements is there wrong with the data? -- View this message in

[R] amount of data R can handle in a single file

2011-02-17 Thread Nasila, Mark
Dear Sir/Madam, I would like to know what is the maximum number of observations a single file must have when using R. I am asking this because am trying to do research on banking transactions and i have around 49million records. Can R handle this? Advise with regard to this.

Re: [R] VAR with HAC

2011-02-17 Thread Pfaff, Bernhard Dr.
Hello Marta, have you read ?coeftest and ? VAR carefully enough? The function does expect a lm/glm object for x as argument. Hence, the following does work: library(vars) data(Canada) myvar - VAR(Canada, p = 2, type = const) lapply(myvar$varresult, coeftest) Best, Bernhard

[R] add text to abline

2011-02-17 Thread David A.
Hi, how could I add a small text note to a vertical or horizontal line? x - rnorm(50) y - rnorm(50) plot(x,y) abline(h=0) I would like to add the text cutoff just above it. Thanks, D. [[alternative HTML version deleted]]

Re: [R] amount of data R can handle in a single file

2011-02-17 Thread Claudia Beleites
On 02/17/2011 10:16 AM, Nasila, Mark wrote: Dear Sir/Madam, I would like to know what is the maximum number of observations a single file must have when using R. I am asking this because am trying Dear Mark, to do research on banking transactions and i have around 49million records. Can

Re: [R] amount of data R can handle in a single file

2011-02-17 Thread Prof Brian Ripley
On Thu, 17 Feb 2011, Nasila, Mark wrote: Dear Sir/Madam, I would like to know what is the maximum number of observations a single file must have when using R. I am asking this because am trying to do research on banking transactions and i have around 49million records. Can R handle this?

Re: [R] create a data frame with the given column names

2011-02-17 Thread Peter Ehlers
On 2011-02-16 13:29, Sam Steingold wrote: how do I create a data frame with the given column names _NOT KNOWN IN ADVANCE_? i.e., I have a vector of strings for names and I want to get an _EMPTY_ data frame with these column names. is it at all possible? It's not really clear to me what you

Re: [R] add text to abline

2011-02-17 Thread Peter Ehlers
On 2011-02-17 01:54, David A. wrote: Hi, how could I add a small text note to a vertical or horizontal line? x- rnorm(50) y- rnorm(50) plot(x,y) abline(h=0) I would like to add the text cutoff just above it. text(-1.5, 0.1, cutoff, col = red) see ?text. Peter Ehlers Thanks, D.

Re: [R] sampling

2011-02-17 Thread Mohamed Lajnef
Hi , what about split function ? ?split divided x into 2 data.frame a-split(x,1:2) a[[1]] first data frame a[[2]] second data frame regrads M Le 17/02/11 05:35, yf a écrit : I want to sample from the ID. For each ID, i want to have 2 set of data. I try the sample() function but it

Re: [R] create a data frame with the given column names

2011-02-17 Thread Sascha Vieweg
On 11-02-16 16:29, Sam Steingold wrote: how do I create a data frame with the given column names _NOT KNOWN IN ADVANCE_? i.e., I have a vector of strings for names and I want to get an _EMPTY_ data frame with these column names. is it at all possible? Read the posting guide, provide example

[R] removing lower and upper quantiles from an arry

2011-02-17 Thread Maas James Dr (MED)
I'm trying to work out the simplest way to remove the upper and lower quantiles, in this case upper and lower 25% from an array. I can do it in two steps but when I try it in one, it fails. Is there something simple missing from my syntax or are there other simple elegant way to accomplish

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

2011-02-17 Thread ONKELINX, Thierry
You need two logical test and then combine them with (AND) or | (OR) i[quantile(i,.25) = i i = quantile(i,.75)] Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie

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

2011-02-17 Thread Dimitris Rizopoulos
have a look at the help page for ?'', try also this: i - 1:20 qs - quantile(i, c(.25, 0.75)) i[i qs[1] i qs[2]] I hope it helps. Best, Dimitris On 2/17/2011 11:08 AM, Maas James Dr (MED) wrote: I'm trying to work out the simplest way to remove the upper and lower quantiles, in this

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

2011-02-17 Thread andrija djurovic
Try this: i[quantile(i,.25) i i quantile(i,.75)] Andrija On Thu, Feb 17, 2011 at 11:08 AM, Maas James Dr (MED) j.m...@uea.ac.ukwrote: I'm trying to work out the simplest way to remove the upper and lower quantiles, in this case upper and lower 25% from an array. I can do it in two steps

Re: [R] confused by lapply

2011-02-17 Thread Peter Ehlers
On 2011-02-16 09:42, Sam Steingold wrote: Description: 'lapply' returns a list of the same length as 'X', each element of which is the result of applying 'FUN' to the corresponding element of 'X'. I expect that when I do lapply(vec,f) f would be called _once_ for each

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

2011-02-17 Thread Mohamed Lajnef
Thierry, you forgot ! i[! quantile(i,.25) = i i = quantile(i,.75)] Best M Le 17/02/11 11:18, ONKELINX, Thierry a écrit : You need two logical test and then combine them with (AND) or | (OR) i[quantile(i,.25)= i i= quantile(i,.75)] Best regards, Thierry

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

2011-02-17 Thread Mohamed Lajnef
Thierry, you forgot ! i[! quantile(i,.25) = i i = quantile(i,.75)] Best M Le 17/02/11 11:18, ONKELINX, Thierry a écrit : You need two logical test and then combine them with (AND) or | (OR) i[quantile(i,.25)= i i= quantile(i,.75)] Best regards, Thierry

[R] multi process support in R

2011-02-17 Thread Alaios
Dear all, two days ago I was trying to run a bunch of adaptIntegrate() functions (double integrals) into my 4 core pc. As I was not satisfied about my pc's performance I tried also to run my code to another computer that has 8 or 16 cores. Unfortunately I didnt get any really decent

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

2011-02-17 Thread Peter Ehlers
Here's one more way: i[ findInterval(i, quantile(i, c(.25, .75))) == 1 ] Peter Ehlers On 2011-02-17 02:08, Maas James Dr (MED) wrote: I'm trying to work out the simplest way to remove the upper and lower quantiles, in this case upper and lower 25% from an array. I can do it in two steps

[R] building R from source

2011-02-17 Thread Jeremy MAZET
Dear all, I post again my question with a new title ... please, help me! I build a customized version of R-2.12.1 from source (under windows XP). I work as explain in the R Installation and Adminstration manual and all seems to be good... But When I try to uninstall this version I have the

Re: [R] darcs patch: Apply on data frame

2011-02-17 Thread Mohamed Lajnef
Hi chen, avoid naming the function with specific expressions (:,;.) and try this code as follow Scripranksum- function(a){ g1- c(1, 2, 3) g2- c(4, 5, 6, 7, 8, 9, 10, 11, 12) c- wilcox.test(a[g1], a[g2]) return (c$p.value) } Best Mohamed Le 17/02/11 08:15, Mr rong chen a écrit :

[R] Fw: RE: Variable length datafile import problem

2011-02-17 Thread John Kane
--- On Thu, 2/17/11, John Kane jrkrid...@yahoo.ca wrote: From: John Kane jrkrid...@yahoo.ca Subject: RE: [R] Variable length datafile import problem To: Ingo Reinhold in...@kth.se Received: Thursday, February 17, 2011, 5:54 AM Generally most of the gurus are in this list.  Hopefully

Re: [R] Function scope issues

2011-02-17 Thread Duncan Murdoch
On 11-02-16 10:23 PM, Sébastien Bihorel wrote: Dear R-users, I have some questions about the scope of functions, which I would like to illustrate with the following example: ### First example require(Hmisc) combine.levels- function(x,y) browser() whatever- function(x,y) combine.levels(x,y)

Re: [R] building R from source

2011-02-17 Thread Duncan Murdoch
On 11-02-17 5:44 AM, Jeremy MAZET wrote: Dear all, I post again my question with a new title ... please, help me! I build a customized version of R-2.12.1 from source (under windows XP). I work as explain in the R Installation and Adminstration manual and all seems to be good... But When I try

Re: [R] Count factor if

2011-02-17 Thread mathijsdevaan
Here is a method that works despite generating a warning: cbind(X, z = ave(X$y, X$x, FUN = seq) - 1) David Winsemius, MD West Hartford, CT I was happy a bit too early. There's still an error: x-as.factor(c('a','a','a','a','a','b','b','b','c','d','d','d')) y-c(1,3,6,8,8,3,4,7,5,6,7,10)

Re: [R] Linear regressions: producing multiple outputs

2011-02-17 Thread Toby Marthews
Hi RTSlider, I suspect you rather need to use the lme command (or perhaps glmmPQL or lmer) because you have a random predictor? lme(fixed=LeafLength~AirTemp*SnowFreeDate,random=~1|Species) See http://socserv.mcmaster.ca/jfox/Books/Companion-1E/appendix-mixed-models.pdf for a tutorial on

[R] Fitting power-law: how to choose xmin ?

2011-02-17 Thread saray
Hello. I am trying to find probability density distribution that best fits my data. Therefore, I am trying to fit several models (like gamma, pareto, log-normal, ...) and then choose the best one using Akaike Information Criterion (AIC). In order to find the parameters for the power-law

Re: [R] multi process support in R

2011-02-17 Thread Ben Haller
On Feb 17, 2011, at 11:40 AM, Alaios wrote: ...Is it possible to split work in many cores in R and if yes how is this library called? I'd recommend the mclapply function in the multicore package. The only drawback is that you can't run your code in a GUI any more. Ben Haller McGill

Re: [R] Reg : read missing values from database using RJDBC

2011-02-17 Thread Raji
Hi R-helpers, Did any of you get a chance to look into this issue?i am kind of stuck in my work due to this..Is there any R command/option that can be used to overcome this? Regards, Raji -- View this message in context:

Re: [R] Rjdbc dbGetquery execution error

2011-02-17 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 12:36 PM, Hasan Diwan di...@economicriskmanagement.com wrote: Rjdbc consistently gives me an execution error with postgresql 9.0s JDBC4 driver. It's probably something trivial so am including my code below: library(RJDBC) param - 249 param2 - 188129 postgres -

Re: [R] Use of panel.segments

2011-02-17 Thread Deepayan Sarkar
On Tue, Feb 15, 2011 at 9:44 PM, Lancaster, Vicki vicki.lancas...@fda.hhs.gov wrote: First I have read all the previous post on error bars segments as well as the  Lattice book by Sarkar. I am using xyplot, there are 2 panels, each panel displays the measurements from 5 matrices over

Re: [R] Count factor if

2011-02-17 Thread Dimitris Rizopoulos
try this: x - factor(c('a','a','a','a','a','b','b','b','c','d','d','d')) y - c(1,3,6,8,8,3,4,7,5,6,7,10) X - data.frame(x, y) cbind(X, z = ave(X$y, X$x, FUN = function (x) match(x, unique(x)) - 1)) I hope it helps. Best, Dimitris On 2/17/2011 11:15 AM, mathijsdevaan wrote: Here is a

[R] Oaxaca Decomposition

2011-02-17 Thread Rasmus
Hi, I have an assignment in which I am asked to use the Oaxaca decomposition. I have not been able to find any support for this in R using rseek. Is anybody aware of an implementations of this in R? I know there is one for Stata, but I do not have easily access to Stata. Thanks, Rasmus [1]

Re: [R] Count factor if

2011-02-17 Thread mathijsdevaan
Thanks! That solved the problem. Dimitris Rizopoulos-4 wrote: try this: x - factor(c('a','a','a','a','a','b','b','b','c','d','d','d')) y - c(1,3,6,8,8,3,4,7,5,6,7,10) X - data.frame(x, y) cbind(X, z = ave(X$y, X$x, FUN = function (x) match(x, unique(x)) - 1)) I hope it

[R] darcs patch: Apply on data frame

2011-02-17 Thread Sébastien Bihorel
Hi, You need to add parentheses around your return argument. (Please, note that your example is not successfully because of data problem). ranksum - function(a){ g1 - c(1, 2, 3) g2 - c(4, 5, 6, 7, 8, 9, 10, 11, 12) c - wilcox.test(a[g1], a[g2]) return(c$p.value) } [[alternative

[R] Best way to organize this data for plotting

2011-02-17 Thread Andre Nathan
Hello I have a number of data files which are outputs for each step of a simulation. The data is organized like this: dmindmax coef 5 6 0.490981 3 8 0.098056 5 6 0.425926 6 6 0.517860 2 4 0.527778 I would

Re: [R] Linear regressions: producing multiple outputs

2011-02-17 Thread Gabor Grothendieck
On Wed, Feb 16, 2011 at 1:13 PM, RTSlider rob.t.sli...@gmail.com wrote: Hello all, I’m running simple linear regressions on multiple species of plants, comparing abiotic factor X against plant trait Y (e.g. Species1: leaf length vs air temperature). Ideally, what I’m looking for is an

Re: [R] sampling

2011-02-17 Thread David Winsemius
On Feb 16, 2011, at 11:35 PM, yf wrote: I want to sample from the ID. For each ID, i want to have 2 set of data. I try the sample() function but it didn't work. You don't say _how_ you used the sample function. You should show what code you used when stating the _something_ doesn't

Re: [R] multi process support in R

2011-02-17 Thread Prof Brian Ripley
He said 'pc' in the part you excised, but failed to follow the posting guide and tell us his OS. I am guessing this means Windows, on which multicore does not run. There are several other solutions on CRAN: I'd suggest 'snow' which can run over sockets on a single Windows machine, and also

[R] Categorical Variables and Machine Learning

2011-02-17 Thread Lorenzo Isella
Dear All, Please consider a dataframe like the one below (I am showing only a few rows). role degree strength weight count disparity intermittency P 10 82 18017 2 2.317073 5.550314e-05 P 7 529 434560 5.178466 6.904488e-03

[R] Dependency on R-Forge Package

2011-02-17 Thread Damian Betebenner
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 the user install my package it will automatically

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.

[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

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

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

[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] 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

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

[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] 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 with error

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) snip On Tue, 9 Jun 2009, Matthieu Stigler wrote:

[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

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

[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

[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

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

[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

[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

[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

[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

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:

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

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

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

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

[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, T with

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=TRUE)

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 josh...@yahoo.com wrote: Hi all, I'm having a problem once again, trying to do something very simple. Consider the following data frame: x -

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,

[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] 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

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] 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.veccutoff.]) with simPD.vec[i] = sum(R.vec cutoff.) Since you're using a different set

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] 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){

Re: [R] incomplete final line

2011-02-17 Thread Joshua Wiley
On Thu, Feb 17, 2011 at 12:35 AM, mipplor wang-p...@hotmail.com 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

[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)

[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:

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 ahupxo...@sneakemail.com 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

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 chang...@umn.edu wrote: But i need for each id

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

[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

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] 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]]

[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

[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

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

[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] Urgent Request

2011-02-17 Thread Ben Bolker
muhammad mohsin mohsinshahid at 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

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 a

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] 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 buysellrentof...@gmail.com wrote: Hi All I have data like this              tom   randy mike dan doug height       150   152     155  134 141 I am trying to

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.

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

[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

[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

[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 =

  1   2   >