[R] Maintaining Column names while writing csv file.

2012-07-18 Thread Vincy Pyne
Dear R helpers, I have one trivial problem while writing an output file in csv format. I have two dataframes say df1 and df2 which I am reading from two different csv files. df1 has column names as date, r1, r2, r3 while the dataframe df2 has column names as date, 1w, 2w. (the dates in both

Re: [R] taylor expansions with real vectors

2012-07-18 Thread Petr Savicky
On Wed, Jul 18, 2012 at 06:02:27PM -0700, bilelsan wrote: > Leave the Taylor expansion aside, how is it possible to compute with [R]: > f(e) = e1 + e2 #for r = 1 > + 1/2!*e1^2 + 1/2!*e2^2 + 1/2!*e1*e2 #for r = 2, excluding e2*e1 > + 1/3!*e1^3 + 1/3!*e1^2*e2 + 1/3!*e2^2*e1 + 1/3!*e2^3 #for r = 3,

Re: [R] Imposing more than one condition to if

2012-07-18 Thread Santiago Guallar
Great! Thank you ever so much Rui. Santi > > From: Rui Barradas >To: Santiago Guallar >Cc: r-help@r-project.org >Sent: Wednesday, July 18, 2012 8:29 PM >Subject: Re: [R] Imposing more than one condition to if > >Hello, > >You're right. I had thought of this,

[R] Contour

2012-07-18 Thread Akhil dua
Hello every one can any one tell me how to draw contour with this data set c zshock 1 0.45450237 0 2 0.02663337 0 3 -2.08444556 0 4 -0.12715275 0 5 0.67066360 0 6 -0.73540081 0 I want to draw contour for shock i.e my z matrix is shock

[R] arima forecasting problem

2012-07-18 Thread johnny
Hi all, I am running into a problem using forecast with ARIMA models, hope you can help shed some light onto this. I am fitting several ARIMA models using the auto.arima() function onto several time series, which are basically the residuals from a linear model fit. There are 40 such data points i

Re: [R] alternate tick labels and tick marks with lattice xyplot

2012-07-18 Thread ilai
Maybe I'm missing something too but from your example seems like you are looking for xyplot(rnorm(12) ~ 1:12 , type="l", scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))), par.settings=list(axis.components=list(bottom=list(tck=c(0,1) See "scales" in ?xyplot and str(trel

Re: [R] taylor expansions with real vectors

2012-07-18 Thread bilelsan
Leave the Taylor expansion aside, how is it possible to compute with [R]: f(e) = e1 + e2 #for r = 1 + 1/2!*e1^2 + 1/2!*e2^2 + 1/2!*e1*e2 #for r = 2, excluding e2*e1 + 1/3!*e1^3 + 1/3!*e1^2*e2 + 1/3!*e2^2*e1 + 1/3!*e2^3 #for r = 3, excluding e2*e1^2 and e1*e2^2 + ... #for r = k In other words, I

[R] 3-d kernel smooth by the "kde" function

2012-07-18 Thread Gary Dong
Dear R community, I'm having hard time to understand the kde function in "ks" package. Let me use a 3-dimensional kernel smooth example to explain my question using the elevation data in geoR. ### here is what I did ### library(ks) require(geoR) data(elevation) elev.df <- data.frame(x = elevatio

[R] Simple tree

2012-07-18 Thread Noah Silverman
Hi, I'm looking for an "easy" way to setup a decision tree. This is *not* any kind of regression, but a very simple DAG with probability on each edge and a value at each node. I just need a way to input the graph and calculate the expected value at each end node. The whole thing could be done

Re: [R] The best solver for non-smooth functions?

2012-07-18 Thread Roger Koenker
There are obviously a large variety of non-smooth problems; for CVAR problems, if by this you mean conditional value at risk portfolio problems, you can use modern interior point linear programming methods. Further details are here: http://www.econ.uiuc.edu/~roger/research/risk/risk.html

Re: [R] Merging Data Frames in R

2012-07-18 Thread Yasir Kaheil
type ?merge in R - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/Merging-Data-Frames-in-R-tp4636781p4636962.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://st

Re: [R] PCA

2012-07-18 Thread Yasir Kaheil
in biplot you could set the limits xlim, ylim of the axes to zoom in on the plot. - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/PCA-tp4636840p4636961.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Entering Data Files

2012-07-18 Thread Yasir Kaheil
type ?read.table in R - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/Entering-Data-Files-tp4636943p4636959.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://st

Re: [R] Subsetting problem data

2012-07-18 Thread arun
Hello, Not sure whether I understand it well. If you want your output to include only Patient A &B, this should work: dat1<-read.table(text=" Patient Cycle Variable1 Variable2 A 1 4 5 A 2 3 3 A 3 4 NA B 1 6 6 B 2 NA 6 C 1 6 5 C 3 2 2 ",sep="",header=TRUE)  subset(dat1,!dat1$Patient=="C")   Pa

Re: [R] Entering Data Files

2012-07-18 Thread David L Carlson
You can do this using only xtabs. Using Rui's data.frame, d: x <- xtabs(Count~Live+Age, d) barplot(x, beside=T, legend.text=TRUE, args.legend=list(x="topleft")) -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station

Re: [R] The best solver for non-smooth functions?

2012-07-18 Thread Hans W Borchers
Cren bancaakros.it> writes: > The most robust solver for non-smooth functions I know of in R is Nelder-Mead in the 'dfoptim' package (that also allows for box constraints). First throw out the equality constraint by using c(w1, w1, 1-w1-w2) as input. This will enlarge the domain a bit, but com

Re: [R] double for cycle

2012-07-18 Thread David L Carlson
First. Your example does not make sense. for (n in 2:10) {s[n]=1+s[n]+rnorm(1,mean=0,sd=1)} adds 1 + 1 + rnorm(1) so it will result in values ranging from 0 - 4 with a few exceeding that range. It will never result in 9 values greater than 4. For example I get > s <- rep(1,10) > set.seed(42) >

[R] cenbox(): Changing Default x-axis Group Labels

2012-07-18 Thread Rich Shepard
I've looked at the lattice book and the 'R Graphics Cookbook' without seeing how to change the labels along the x axis for groups in a box plot, specifically cenbox(). The attached example has a main and axes labels with default group labels. Please point me to a reference on how I can change

Re: [R] Upgrading on Ubuntu from 2.11.1 to 2.15.1

2012-07-18 Thread Sarah Goslee
Did you follow the directions? There's a special README for Ubuntu to help you get the current version. http://cran.r-project.org/bin/linux/ubuntu/README But you also don't tell us what version of Ubuntu you're running. Sarah On Wed, Jul 18, 2012 at 5:27 PM, Chet Seligman wrote: > This doesn't

[R] Upgrading on Ubuntu from 2.11.1 to 2.15.1

2012-07-18 Thread Chet Seligman
This doesn't work, what should I do? sudo apt-get install r-base [sudo] password for cseligman: Reading package lists... Done Building dependency tree Reading state information... Done r-base is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Also: > .

Re: [R] Entering Data Files

2012-07-18 Thread Greg Snow
For reading data into R you should start with http://cran.r-project.org/doc/manuals/R-data.html (or the local copy that was installed with R on your machine). For the example above the read.table function should be fine. If you want to change the shape of the resulting data frame then look at the

Re: [R] Entering Data Files

2012-07-18 Thread Rui Barradas
Hello, Sorry, I forgot the barplot. dmelt <- melt(d, id.vars=c("Live", "Age"), measure.vars="Count") wide <- dcast(Live ~ Age, data = dmelt) col <- rainbow(4) barplot(as.matrix(wide[, 2:5]), beside=T, col=col) legend("topleft", wide[, 1], fill=col) Hope this helps, Rui Barradas Em 18-07-20

Re: [R] Entering Data Files

2012-07-18 Thread Rui Barradas
Hello, Install package 'reshape2' and try the following. #install.packages('reshape2') library(reshape2) d <- read.table(text=" LiveAgeCount ParentsAge19324 AnotherAge1937 OwnPlaceAge19116 GroupAge1958 OtherAge195 ParentsAge20378 Another

Re: [R] taylor expansions with real vectors

2012-07-18 Thread Gabor Grothendieck
On Wed, Jul 18, 2012 at 9:47 AM, bilelsan wrote: > Dear list, > > I have a big deal concerning the development of a Taylor expansion. > > require(Matrix) > e1 <- as.vector(1:5) > e2 <- as.vector(6:10) > > in order to obtain all the combinations between these two vectors following > a Taylor expans

Re: [R] Subsetting problem data

2012-07-18 Thread Peter Alspach
Tena koe Lib In case you have receive a reply to this (I didn't notice one), here is one option: > lib A X1 X4 X5 1 A 2 3 3 2 A 3 4 NA 3 B 1 6 6 4 B 2 NA 6 5 C 1 6 5 6 C 3 2 2 > str(lib) 'data.frame': 6 obs. of 4 variables: $ A : chr "A" "A" "B" "B" ... $ X1: num 2 3 1 2

Re: [R] fitting several lme sistematically

2012-07-18 Thread Jean V Adams
You have only saved the last run of the for() loop (when i is 4 and j is 7) to the object called model. If you want to save all of the lme fits, you need to set give some dimensionality to the object model. For example, you could define model as a list, then store the lme fits as separate ele

Re: [R] conditional increase by increment

2012-07-18 Thread William Dunlap
> land<-c(0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0) > expect <- c(1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3) > cumsum(c(TRUE, diff(land)==1)) [1] 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 > all.equal(.Last.value, expect) [1] TRUE Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-

Re: [R] Trapping option settings

2012-07-18 Thread David A Vavra
Thanks. Also helpful. DAV -Original Message- From: William Dunlap [mailto:wdun...@tibco.com] Sent: Wednesday, July 18, 2012 4:20 PM To: David A Vavra; 'jim holtman' Cc: r-help@r-project.org Subject: RE: [R] Trapping option settings Try using trace(), as in trace(options, quote(print

[R] Entering Data Files

2012-07-18 Thread darnold
Hi, Entering data from a given file is the hardest part of learning R for me. For example, I have this datafile from Moore's text: LiveAge Count Parents Age19 324 Another Age19 37 OwnPlaceAge19 116 Group Age19 58 Other Age19 5 Parents Age20 378 Another Age20 47 O

Re: [R] fitting several lme sistematically

2012-07-18 Thread arun
Hi Jean,  Is there something missing in the function? ids <- a$id for(i in 2:4){ for(j in 5:7){     y <- a[, j]     x <- a[, i]     model<-lme(y ~ x , random= ~1|ids, na.action="na.exclude")     }}  summary(model) Linear mixed-effects model fit by REML  Data: NULL    AIC   

Re: [R] plotting points to a map

2012-07-18 Thread Barry Rowlingson
On Wed, Jul 18, 2012 at 7:41 PM, Gary Dong wrote: > For your second question: > 1) by relative long and lat, I mean distances to the city center from > south-north and east-west directions. > 2) I know the coordinate of the reference point. The problem here is that going 10 miles north along a

Re: [R] Imposing more than one condition to if

2012-07-18 Thread Santiago Guallar
Nice! It works. Thank you, Rui   There's something that takes me back to the original question, though. The code takes the first value that meets the critical condition (light ==0); however, this value can appear more than once a day because these animals nest in dark caves, and once they are in

Re: [R] R code for to check outliers

2012-07-18 Thread arun
HI, Check this link: http://stackoverflow.com/questions/1444306/how-to-use-outlier-tests-in-r-code Hope it would be helpful. A.K. - Original Message - From: Sajeeka Nanayakkara To: "r-help@r-project.org" Cc: Sent: Wednesday, July 18, 2012 9:27 AM Subject: [R] R code for to check out

Re: [R] taylor expansions with real vectors

2012-07-18 Thread bilelsan
Dear list, I have a big deal concerning the development of a Taylor expansion. require(Matrix) e1 <- as.vector(1:5) e2 <- as.vector(6:10) in order to obtain all the combinations between these two vectors following a Taylor expansion (or more simply through a Maclaurin series) for real numbe

Re: [R] Variable labels

2012-07-18 Thread Francois Maurice
Thanks a lot, it works fine with me !! François Maurice De : "Nutter, Benjamin" À : Francois Maurice ; r-help@r-project.org Envoyé le : mercredi 18 juillet 2012 8h21 Objet : RE: [R] Variable labels I have my own function for doing this that is similar to the one presented below.  Others may

Re: [R] Mean of matched data

2012-07-18 Thread robgriffin247
got it... another merge did the trick narrow6<-merge(narrow2,narrow5,by=c("gene","gender")) Thanks for the help Rui -- View this message in context: http://r.789695.n4.nabble.com/Mean-of-matched-data-tp4636856p4636877.html Sent from the R help mailing list archive at Nabble.com. __

[R] System Invocation Error - Cspade

2012-07-18 Thread sdoberman
I am trying to run the cspade function in the arulesSequences package in R. After I successfully read in my transactions using read_baskets, I try to execute the cspade function against the transactions object I read in. However, when I execute the command, I obtain an error: system invocation fa

Re: [R] duplicate data between two data frames according to row names

2012-07-18 Thread arun
Hi, You could use "merge", "join" etc. merge(DF3,DF2)  # station lat lon data #1   ST002  41   2    3 #2   ST003  42   3    7 library(plyr)  join(DF3,DF2,type="inner") Joining by: station #  station lat lon data #1   ST002  41   2    3 #2   ST003  42   3    7 #or join(DF3,DF2,type="right") Ho

Re: [R] NTH PERCENTILE COULMNWIESE

2012-07-18 Thread arun
Hi Try this: mydat <-read.table(text=" ABC    XYZ 12  6 6    50 90    100 55  85 100    25 ",sep="",header=TRUE) apply(mydat,2,quantile,probs=0.2)  ABC  XYZ 10.8 21.2 A.K. - Original Message - From: Rantony To: r-help@r-project.org Cc: Sent: Wednesda

Re: [R] Mean of matched data

2012-07-18 Thread robgriffin247
Thanks, in a way this has worked... with a slight modification to this: narrow3<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,mean) narrow4<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,sd) which gives a table of the 24000 gene&gender means (narro

Re: [R] The best solver for non-smooth functions?

2012-07-18 Thread Cren
# Whoops! I have just seen there's a little mistake # in the 'sharpe' function, because I had to use # 'w' array instead of 'ead' in the cm.CVaR function! # This does not change the main features of my, # but you should be aware of it --- # The function to be minimized sharpe <- function(w) {

[R] The best solver for non-smooth functions?

2012-07-18 Thread Cren
# Hi all, # consider the following code (please, run it: # it's fully working and requires just few minutes # to finish): require(CreditMetrics) require(clusterGeneration) install.packages("Rdonlp2", repos= c("http://R-Forge.R-project.org";, getOption("repos"))) install.packages("Rsolnp2", repos=

Re: [R] alternate tick labels and tick marks with lattice xyplot

2012-07-18 Thread Leah Marian
Yes, I would be interested in both the ggplot2 and lattice ways of doing this. Unfortunately, I am not interested in creating a panel for each chromosome. Actually, I would like to create a Manhattan plot using xyplot. Thus I would need to alternate tick marks and tick labels. Thanks! On Mon,

[R] convert deldir$delsgs to a X3D IndexedTriangleSet

2012-07-18 Thread Erdal Karaca
Anyone knows how to convert a deldir$delsgs to a X3D IndexedTriangleSet? Are there already any functions/packages? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do r

[R] Subsetting problem data

2012-07-18 Thread Lib Gray
Hello, I need to subset my data to only look at the parts that have "holes" in it. I already have a formula to get rid of inconsistencies, but now I need to look only at the problem data to reconfigure it. In my data set where there are multiple "cycles" per "patient," and I want to highlight the p

Re: [R] Help with correlation matrices, thresholding

2012-07-18 Thread Drinniol
Thank you! I had to make some modifications since my data is between a data set and a subset not one data set to itself, but I was able to use essentially your method to get it working. I did have some trouble with the matrix command on the last line - it kept returning lots of NAs. So I just

[R] conditional increase by increment

2012-07-18 Thread penguins
I am trying to assign increasing trip numbers to a binary variable ("land"; 1=home and 0=away) where a string of 1's shouldn't increment the trip_no more than once. For example; based on land<-c(0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0) the "trip_no" sequence produced should be 1,1,1,1,2,2,2,2,2,2,3,3,

[R] double for cycle

2012-07-18 Thread cesare orsini
Hi nice people, i am trying to made a double "for" cycle, i wish that for cycle on k activates t times the for cycle on s the first cycle is this: s<-rep(1,10) s [1] 1 1 1 1 1 1 1 1 1 1 > for (n in 2:10) { + s[n]=1+s[n]+rnorm(1,mean=0,sd=1) + } > s [1] 1 4.75 4.86 4.05 4.09 4.56 4.63 4.65 4

[R] information

2012-07-18 Thread Karan Anand
hi, i am new to using R, so if u can help me in merging my csv file having different sheets .if u can help me with the commands for it. regards karan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.e

Re: [R] alternate tick labels and tick marks with lattice xyplot

2012-07-18 Thread John Kane
Oh, I clearly misunderstood what you were doing there. I don't know anything about Manhattan plots but a quick google for "manhattan plot r package" turns up a number of items so the type of plot you want may already exist. Sorry to not be of more help. John Kane Kingston ON Canada > -

Re: [R] Mean of matched data

2012-07-18 Thread Peter Ehlers
On 2012-07-18 04:27, Rui Barradas wrote: Helo, All problems should be easy. d <- read.table(text=" gene variable value gender line rep 1 CG1 X208.F1.30456 4.758010 Female 208 1 2 CG1 X365.F2.30478 4.915395 Female 365 2 3 CG1 X799.F2.30509 4.641636 Female 799 2 4 CG1 X306.M2.326

Re: [R] Trapping option settings

2012-07-18 Thread William Dunlap
Try using trace(), as in trace(options, quote(print(as.list(sys.calls() Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of David A Vavra > Sent: Wednesday, July 18, 20

Re: [R] Trapping option settings

2012-07-18 Thread David A Vavra
Jim, Thanks. It wasn't sure if merely overriding the options function by placing one in the global environment would guarantee it would be the one actually called. In any case, I didn't know how to identify the caller. This is quite helpful and looks promising. I'll give it a try. DAV -

Re: [R] R code for to check outliers

2012-07-18 Thread Rui Barradas
Hello, Inline Em 18-07-2012 18:44, Nordlund, Dan (DSHS/RDA) escreveu: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Sajeeka Nanayakkara Sent: Wednesday, July 18, 2012 6:28 AM To: r-help@r-project.org Subject: [R] R code for to

Re: [R] plotting points to a map

2012-07-18 Thread Gary Dong
Thanks, Sara. For your first question: Geographic Coordinate System: GCS_North_American_1983_HARN Projected Coordinate System: NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601_Feet_Intl I have imported the shp file in R by read.shaplefiles(). For your second question: 1) by relative long and la

Re: [R] plotting points to a map

2012-07-18 Thread Sarah Goslee
Hi, On Wed, Jul 18, 2012 at 2:11 PM, Gary Dong wrote: > Dear R users, > > I have a city map in shape file (polygon). I also have some points that I > hope to plot them to the city map. What projection is the shape file in? Have you successfully imported it into R yet? This page has a nice overv

Re: [R] Imposing more than one condition to if

2012-07-18 Thread Rui Barradas
Hello, You're right. I had thought of this, and I believe there's a day when it happens to have a zero in the middle of the day. R doesn't allow conditions like the one you've written but it does allow multiple conditions, combined using the logical connectives, 'not' - '!', 'or' - '|' and 'a

[R] How does "rlm" in R decide its "w" weights for each IRLS iteration?

2012-07-18 Thread Michael
Hi all, I am also confused about the manual: a. The input arguments: wt.method are the weights case weights (giving the relative importance of case, so a weight of 2 means there are two of these) or the inverse of the variances, so a weight of two means this error is half as variable

Re: [R] Power analysis for Cox regression with a time-varying covariate

2012-07-18 Thread Paul Miller
Hi Terry, Greg, and Marc,   Thanks for your advice about this. I think I have a pretty good starting point now for the analysis.   Appreciate your help.   Paul --- On Wed, 7/18/12, Terry Therneau wrote: From: Terry Therneau Subject: Re: [R] Power analysis for Cox regression with a time-varyin

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
Thank you Rui. Very helpful. Yolande. On Wed, Jul 18, 2012 at 1:37 PM, Rui Barradas wrote: > Hello, > > Try the following. > > > for(i in 1:dim(diveData_2008)[1]){ > # Which dive is this observation from > thisIndex <- as.character(index(diveData_**2008[i,])) > thisIndex <- as.PO

[R] plotting points to a map

2012-07-18 Thread Gary Dong
Dear R users, I have a city map in shape file (polygon). I also have some points that I hope to plot them to the city map. The only information I have about those points are their relative longitude and latitude to the city center by miles. Is there a way that R can help me to do this? Thanks. Ga

Re: [R] R code for to check outliers

2012-07-18 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Sajeeka Nanayakkara > Sent: Wednesday, July 18, 2012 6:28 AM > To: r-help@r-project.org > Subject: [R] R code for to check outliers > > > > > >  What is the R code to check w

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Rui Barradas
Hello, Try the following. for(i in 1:dim(diveData_2008)[1]){ # Which dive is this observation from thisIndex <- as.character(index(diveData_2008[i,])) thisIndex <- as.POSIXct(thisIndex) dive_id <- diveCond_all$dive_id[diveCond_all$timestamp == thisIndex] #

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
it is a function from library(xts) On Wed, Jul 18, 2012 at 1:15 PM, Jean V Adams wrote: > What is the function index() that you use in this line of code? > thisIndex <- as.character(index(diveData_2008[i,])) > > Is it from some package? Or a function you wrote yourself? > I'm trying to run the

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Jean V Adams
What is the function index() that you use in this line of code? thisIndex <- as.character(index(diveData_2008[i,])) Is it from some package? Or a function you wrote yourself? I'm trying to run the code you submitted, but I don't have a function called index(). Jean Yolande Tra wrote on 07/18

Re: [R] tweaking forest plot (metafor package)

2012-07-18 Thread Michael Dewey
At 00:10 18/07/2012, eeste...@ualg.pt wrote: Dear All, I'm having trouble tweaking a forest plot made using the R meta-analysis package metafor. I did the analysis based upon the correlation coeff from studies and plotted the corresponding forest plot easily q2<-rma(yi,vi,mods=cbind(grupo),dat

Re: [R] weighted mean by week

2012-07-18 Thread Dimitri Liakhovitski
David, thanks a lot! I tried x[-1] myself but forgot to delete 'group' from the keyby statement - this explains why it did not work for me. This is amazing - just 2 lines instead of my many-many. Great learning! Dimitri On Tue, Jul 17, 2012 at 10:49 PM, David Freedman wrote: > Honestly, I wasn't

Re: [R] fitting several lme sistematically

2012-07-18 Thread Jean V Adams
I'm not sure why, but lme() doesn't seem to like the variables to be referenced as part of a list using [ or $. Here's an easy workaround ... ids <- a$id for(i in 2:4){ for(j in 5:7){ y <- a[, j] x <- a[, i] lme(y ~ x , random= ~1|ids, na.action="na.exclude") }} J

Re: [R] R code for to check outliers

2012-07-18 Thread Martin Maechler
> Bert Gunter > on Wed, 18 Jul 2012 07:14:31 -0700 writes: > checkforoutliers <- function(series) NULL > Cheers, Bert > *Explanation: There is no such thing as a statistical > outlier -- or, rather,"outlier" is a fraudulent > statistical concept, defined arbitrari

Re: [R] R code for to check outliers

2012-07-18 Thread Duncan Murdoch
On 18/07/2012 10:14 AM, Bert Gunter wrote: checkforoutliers <- function(series)NULL Cheers, Bert *Explanation: There is no such thing as a statistical outlier -- or, rather,"outlier" is a fraudulent statistical concept, defined arbitrarily and without scientific legitimacy. The typical unstated

Re: [R] R code for to check outliers

2012-07-18 Thread S Ellison
> >> What is the R code to check whether data series have >>> outliers or not? In case noone else has pointed you there, you could try the 'outliers' package. That contains some of the 'standard' methods of outlier testing for univariate data. What you do with them when you find them is a

Re: [R] R code for to check outliers

2012-07-18 Thread R. Michael Weylandt
To further what Bert says: You would almost certainly prefer to use robust statistics than "outlier detection". I believe Greg Snow's TeachingDemos package has a data set "outliers" suggesting some of the perils of doing things the outlier-removal way. Best, Michael On Wed, Jul 18, 2012 at 9:14

Re: [R] keep parameter in step function

2012-07-18 Thread Uwe Ligges
On 18.07.2012 18:03, Mati Bielawski wrote: I would like to know how to use the keep parameter in the step function. Or the way to always keep one of my Xs, and the other Xs to be keep or not by step forward method. See ?step and in particular the "lower" part of its scope argument: step(

[R] keep parameter in step function

2012-07-18 Thread Mati Bielawski
I would like to know how to use the keep parameter in the step function. Or the way to always keep one of my Xs, and the other Xs to be keep or not by step forward method. Thank you all Mati Bielawski [[alternative HTML version deleted]] __ R-he

Re: [R] Installing packages from RProfile.site file

2012-07-18 Thread G See
abhisarihan, Please don't crosspost! http://stackoverflow.com/questions/11530800/installing-packages-from-rprofile-site-file Thanks, Garrett On Tue, Jul 17, 2012 at 2:34 PM, abhisarihan wrote: > I am trying to install custom packages upon starting R. A lot of the code > that is written by us ri

Re: [R] Installing packages from RProfile.site file

2012-07-18 Thread Uwe Ligges
On 17.07.2012 21:34, abhisarihan wrote: I am trying to install custom packages upon starting R. A lot of the code that is written by us right now is available for editing to the users. To try and protect the code, I am packaging the production level code and having the users install it on their

Re: [R] functions of vectors : loop or vectorization

2012-07-18 Thread Uwe Ligges
On 14.07.2012 00:41, Julien Salanie wrote: I have a read a lot about the benefits of vectorization in R. I have a program that takes "almost forever" to run. A good way to see if I have learned something ... My problem can be summarized like this : I have a nonlinear function of several variables

Re: [R] check whether connection can be opened

2012-07-18 Thread Michael Weylandt
I think you'll need to roll your own using tryCatch() around open(). Michael On Jul 18, 2012, at 5:09 AM, Berry Boessenkool wrote: > > > Hi all, > > I'm working on a function that reads online data that is only available to > certain IPs. It then writes a subset of the data into a file. >

Re: [R] R code for to check outliers

2012-07-18 Thread Bert Gunter
checkforoutliers <- function(series)NULL Cheers, Bert *Explanation: There is no such thing as a statistical outlier -- or, rather,"outlier" is a fraudulent statistical concept, defined arbitrarily and without scientific legitimacy. The typical unstated purpose of such identification is to remove

Re: [R] Skip file

2012-07-18 Thread Duncan Murdoch
On 18/07/2012 8:27 AM, bunnylove...@optonline.net wrote: What i have is a for loop to name files. I want it to skip over the file if it doesn't exist. Is there a way to do that? s=seq(from = chron("03/15/2012"), to = chron("06/15/2012")) day=format(as.Date(s), "%Y%m%d") for (k in 1:length(day))

[R] Plotting trajectories of ordinal variables over time by cheating

2012-07-18 Thread Eiko Fried
Hello. I have an ordered dependent variable (scale 0 - 3), 5 measurement points. I am afraid I have strong ceiling effects in my data, and would like to plot the data (trajectories). However, you know that plotting ordered variables isn't really feasible. My question: would you think it appropri

[R] fitting several lme sistematically

2012-07-18 Thread Berta Ibáñez
Dear R-list, I have a data set (in the following example called "a") which have: one "subject indicator" variable (called "id") three dependent variables (varD, varE, var F) three independent variables (varA, varB, varC) I want to fit 9 lme models, one per posible combination (DA, DB, DC, E

[R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
Hello, I have the following loop for two data sets: diveData_2008 and diveData_2009. It uses two other data: diveCond_all and fishTable. The problem is at the point to identify the dive_id for the given index (index is timestamp). It keeps on saying for the1st loop Error in fishReport$dive_id[i] <

Re: [R] read mignight as 24:00 and not as 0:00

2012-07-18 Thread Sandy Adriaenssens
Ok, thank you Dan! I was already afraid that I would get this answer. I will solve it by defining date/time both as a date/time object and as a character object ( in another column) Regards, Sandy -- View this message in context: http://r.789695.n4.nabble.com/read-mignight-as-24-00-and-not-as-

[R] R code for to check outliers

2012-07-18 Thread Sajeeka Nanayakkara
 What is the R code to check whether data series have outliers or not? Thanks, Sajeeka Nanayakkara [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the pos

Re: [R] Power analysis for Cox regression with a time-varying covariate

2012-07-18 Thread Terry Therneau
Marc gave the referencer for Schoenfeld's article. It's actually quite simple. Sample size for a Cox model has two parts: 1. Easy part: how many deaths to I need d = (za + zb)^2 / [var(x) * coef^2] za = cutoff for your alpah, usually 1.96 (.05 two-sided) zb = cutoff for pow

[R] Building a web risk calculator based on Cox, PH--definitive method for calculating probability?

2012-07-18 Thread Terry Therneau
Here is an example of how to do it. > library(survival) > vfit <- coxph(Surv(time, status) ~ celltype + trt, data=veteran) > userinput <- data.frame(celltype="smallcell", trt = 1) > usercurve <- survfit(vfit, newdata=userinput) #the entire predicted survival curve > user2 <- summary(usercurve,

[R] contour lines with number labels in lattice?

2012-07-18 Thread Martin Ivanov
Dear R users, I am new to lattice but am trying to get to grips with it. I need to add contour lines for the topography to a plot I created with spplot. The topography is available as a SpatialPixelsDataFrame object Z_sfc. If I plot it as spatial lines, after converting to a SpatialLines objec

[R] Skip file

2012-07-18 Thread bunnylover23
What i have is a for loop to name files. I want it to skip over the file if it doesn't exist. Is there a way to do that? s=seq(from = chron("03/15/2012"), to = chron("06/15/2012")) day=format(as.Date(s), "%Y%m%d") for (k in 1:length(day)){ B1=read.csv(paste("S:/file_", day[k], ".csv", sep="")) Da

Re: [R] Variable labels

2012-07-18 Thread Nutter, Benjamin
I have my own function for doing this that is similar to the one presented below. Others may have other ideas that work better. As a general rule, I would caution against writing out just the label without the variable name. The only reason I see to separate the labels and names is if you are

Re: [R] 'symbols' not plotting correct circle radii

2012-07-18 Thread Jim Lemon
On 07/18/2012 10:11 PM, Jim Lemon wrote: On 07/18/2012 09:42 PM, Sarah Goslee wrote: On Wed, Jul 18, 2012 at 6:42 AM, Jim Lemon wrote: On 07/18/2012 08:02 PM, Stuart Leask wrote: Hi there. I have been plotting some circles using 'symbols', with radii representing my data, but the radii looke

Re: [R] order or sort doesn´t work properly

2012-07-18 Thread Jean V Adams
# MCT ordered by the second column of MCT, from smallest to largest values MCT[order(MCT[, 2]), ] Jean Trying To learn again wrote on 07/17/2012 04:42:24 PM: > Hi all, > > I want to order a series that is included on the second column in MCT.csv. > > I do but R doesn´t order, could be beca

Re: [R] 'symbols' not plotting correct circle radii

2012-07-18 Thread Jim Lemon
On 07/18/2012 09:42 PM, Sarah Goslee wrote: On Wed, Jul 18, 2012 at 6:42 AM, Jim Lemon wrote: On 07/18/2012 08:02 PM, Stuart Leask wrote: Hi there. I have been plotting some circles using 'symbols', with radii representing my data, but the radii looked incorrect. It seems to happen with a s

Re: [R] 'symbols' not plotting correct circle radii

2012-07-18 Thread Sarah Goslee
On Wed, Jul 18, 2012 at 6:42 AM, Jim Lemon wrote: > On 07/18/2012 08:02 PM, Stuart Leask wrote: >> >> Hi there. >> >> I have been plotting some circles using 'symbols', with radii representing >> my data, but the radii looked incorrect. >> >> It seems to happen with a single circle too: >> >> Symb

Re: [R] Mean of matched data

2012-07-18 Thread Rui Barradas
Helo, All problems should be easy. d <- read.table(text=" gene variable value gender line rep 1 CG1 X208.F1.30456 4.758010 Female 208 1 2 CG1 X365.F2.30478 4.915395 Female 365 2 3 CG1 X799.F2.30509 4.641636 Female 799 2 4 CG1 X306.M2.32650 4.550676 Male 306 2 5 CG1 X712.M2.3

Re: [R] How to have original (name) order after melt and cast command

2012-07-18 Thread Rui Barradas
Hello, Try the following. # This is your code df_sorted = df[order(as.Date(df$date, "%m/%d/%Y"), decreasing = TRUE),] # This is my code nams <- as.character(unique(dat1$name)) nums <- sapply(nams, function(nm) which(names(df_sorted) %in% nm)) df_sorted[, sort(nums)] <- df_sorted[, nams] names(d

Re: [R] How to have original (name) order after melt and cast command

2012-07-18 Thread Vincy Pyne
Dear Mr Rui Barradas, Thanks a lot for your wonderful suggestion. It worked and will help me immensely in future too. Really heartfelt thanks once again. Vincy --- On Wed, 7/18/12, Rui Barradas wrote: From: Rui Barradas Subject: Re: [R] How to have original (name) order after melt and cast c

[R] check whether connection can be opened

2012-07-18 Thread Berry Boessenkool
Hi all, I'm working on a function that reads online data that is only available to certain IPs. It then writes a subset of the data into a file. So whenever I'm logged in elsewhere or am not connected to the internet, I get an error, and the function is terminated. I want it to rather print a

[R] Mean of matched data

2012-07-18 Thread robgriffin247
Hi I think/hope there will be a simple solution to this but google-ing has provided no answers (probably not using the right words) I have a long data frame of >2 000 000 rows, and 6 columns. Across this there are 24 000 combinations of gene in a column (n=12000) and gender in a column (n=2... obv

Re: [R] contour

2012-07-18 Thread Rui Barradas
Hello, Now I don't understand. Inline Em 18-07-2012 11:56, Akhil dua escreveu: why are you writing ncol=2 ? I have levels=100 for x1 and the x1 is my z matrix In your contour instruction x3 is the z matrix, not x1. And your dataset shows a 2x3 grid, hence ncol=2, for (x1 times x2) 0:1x1:3.

  1   2   >