Re: [R] need help on melt/cast
Hi > > I can never remember what melt, cast and all that means, hence I simpy > use reshape() which does not even require any additional package: > > reshape(dat, direction="long", idvar = "ID", >varying=list(2:4), v.names="Value", times=names(dat)[2:4]) > > Uwe Ligges www ID T0 T1 T2 1 A 1 2 3 2 B 4 5 6 3 C 7 8 9 melt(www) Using ID as id variables ID variable value 1 A T0 1 2 B T0 4 3 C T0 7 4 A T1 2 5 B T1 5 6 C T1 8 7 A T2 3 8 B T2 6 9 C T2 9 AFAIK melt does exactly what OP wanted only sorting of columns is different. So mmm[order(mmm$ID),] ID variable value 1 A T0 1 4 A T1 2 7 A T2 3 2 B T0 4 5 B T1 5 8 B T2 6 3 C T0 7 6 C T1 8 9 C T2 9 Therefore simple ordering makes it. Regards Petr > > > On 22.09.2011 15:54, Eugene Kanshin wrote: > > Hello, > > I need to convert dataframe from: > > > > ID T0 T1 T2 > > A1 2 3 > > B4 5 6 > > C7 8 9 > > > > to: > > > > ID Variable Value > > A T0 1 > > A T1 2 > > A T2 3 > > B T0 4 > > B T1 5 > > B T2 6 > > C T0 7 > > C T1 8 > > C T2 9 > > > > i tried to use melt cast but it gives me all the time not exactly what I > > need. > > Thank you. > > > >[[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Testing packages
Dear R users, It would be really helpful if I got to know the names of the packages which use the following for testing: >pkg-Ex. Rout.save files (examples of testing) If possible some testing links: to see how testing is done. Thanks in advance. Regards Vikram [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to adjust the y-axis range in barplot properly
On 09/23/2011 01:49 AM, Benedikt Drosse wrote: Hello R-Users, it might be a rather simple problem I have, but I couldn't find any solution online. Thus, here is my problem: I would like to adjust the y-axis range in a barplot, since all my values are >70. Therefore I would like to only visualize the y-axis from 60-100 (example 1). The problem is, the range of the y-axis is adjusted, but the barsize stays the same and vanishes from the plot area. How can I "cut" the y-axis and the bars in a proper way. Unfortunatlely I dit not get "gap.barplot" function to work on the matrix in example 1. Hi Benedikt, The gap.*plot functions are intended to create a gap between two or more sets of values with ranges that don't overlap, such that there would be large empty spaces on the plot. When you just want to start the ordinate above zero, you can do this: barp(data,ylim=c(60,100),col=2:3,height.at=c(70,80,90,100)) axis.break(2,65) or if you really want the gap in there: barp(data,ylim=c(60,100),col=2:3,height.at=c(60,70,80,90,100), height.lab=c(0,70,80,90,100)) axis.break(2,65,style="gap") Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in as.vector(data) optim() / fkf()
Problem solved. It had something to do with calling expm(-array(c(K_1, 0, 0, K_2), c(2,2))*h). 2011/9/22 Kristian Lind > Dear R users, > > When running the program below I receive the following error message: > fit <- optim(parm, objective, yt = tyield, hessian = TRUE) > Error in as.vector(data) : > no method for coercing this S4 class to a vector > > I can't figure out what the problem is exactly. I imagine that it has > something to do with "tyield" being a matrix. Any help on explaining what's > going on and how to solve this is much appreciated. > > Thank you, > > Kristian > > library(FKF) #loading Fast Kalman Filter package > library(Matrix) # matrix exponential package > > K_1 = 0.1156 > K_2 = 0.17 > sigma_1 = 0.1896 > sigma_2 = 0.2156 > lambda_1 = 0 > lambda_2 = -0.5316 > theta_1 = 0.1513 > theta_2 = 0.2055 > > #test data > tyield <- matrix(data = rnorm(200), nrow =2, ncol =100) > > # defining dimensions > m <- 2 # m is the number of state variables > n <- 100 # is the length of the observed sample > d <- 2 # is the number of observed variables. > theta <- c(theta_1, theta_2) > h <- t <- 1/52 # time between observations > > ## creating state space representation of 2-factor CIR model follwing > Driessen and Geyer et al. > CIR2ss <- function(K_1, K_2, sigma_1, sigma_2, lambda_1, lambda_2, theta_1, > theta_2){ > ## defining auxilary parameters > phi_11 <- sqrt((K_1+lambda_1)^2+2*sigma_1^2) > phi_21 <- sqrt((K_1+lambda_2)^2+2*sigma_2^2) > phi_12 <- K_1+lambda_1+phi_11 > phi_22 <- K_2+lambda_2+phi_12 > phi_13 <- -2*K_1*theta_1/sigma_1^2 > phi_23 <- -2*K_2*theta_2/sigma_2^2 > phi_14 <- 2*phi_11+phi_21*(exp(phi_11*t)-1) > phi_24 <- 2*phi_12+phi_22*(exp(phi_12*t)-1) > phi <- array(c(phi_11, phi_21, phi_12, phi_22, phi_13, phi_23, phi_14, > phi_24), c(4,2)) > a <- array(0, c(d,n)) > for(t in n:1){ > a[,n-(t+1)] <- > -phi_13/(n-(t+1))*log(2*phi_11*exp(phi_12*(n-(t+1))/2)/phi_14)-phi_23/(n-(t+1))*log(2*phi_21*exp(phi_22*(n-(t+1))/2)/phi_24) > } > b <- array(c(1,0,0,1,0), c(d,m,n)) > j <- -array(c(K_1, 0, 0, K_2), c(2,2))*h > explh <- expm(j) > Tt <- array(explh, c(m,m,n)) #array giving the factor of the transition > equation > Zt <- b #array giving the factor of the measurement equation > ct <- a #matrix giving the intercept of the measurement equation > dt <- (diag(m)-expm(-array(c(K_1, 0, 0, K_2), c(2,2))*h))*theta #matrix > giving the intercept of the transition equation > GGt <- array(c(1,0,0,1), c(d,d,n)) #array giving the variance of the > disturbances of the measurement equation > HHt <- array(c(1,0,0,1), c(m,m,n)) #array giving the variance of the > innovations of the transition equation > a0 <- c(0, 0) #vector giving the initial value/estimation of the state > variable > P0 <- matrix(1e6, nrow = 2, ncol = 2) # matrix giving the variance of > a0 > return(list(a0 = a0, P0 = P0, ct = ct, dt = dt, Zt = Zt, Tt = Tt, GGt = > GGt, > HHt = HHt)) > } > > ## Objective function passed to optim > objective <- function(parm, yt) { > sp <- CIR2ss(parm["K_1"], parm["K_2"], parm["sigma_1"], parm["sigma_2"], > parm["lambda_1"], parm["lambda_2"], >parm["theta_1"], parm["theta_2"]) > ans <- fkf(a0 = sp$a0, P0 = sp$P0, dt = sp$dt, ct = sp$ct, Tt = sp$Tt, >Zt = sp$Zt, HHt = sp$HHt, GGt = sp$GGt, yt = yt) > return(-ans$loglik) > } > > parm <- c(K_1 = 0.1156, K_2 = 0.17, sigma_1 = 0.1896, sigma_2 = 0.2156, > lambda_1 = 0, lambda_2 = -0.5316, theta_1 = 0.1513, theta_2 = > 0.2055) # initial parameters > > ##optimizing objective function > fit <- optim(parm, objective, yt = tyield, hessian = TRUE) > print(fit) > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] chippeakanno package: "getAllPeakSequence" problem
Thanks Martin, it worked. I will post on BioC next time. Cheers. -- View this message in context: http://r.789695.n4.nabble.com/chippeakanno-package-getAllPeakSequence-problem-tp3830284p3836422.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How make a x,y dataset from a formula based entry
To separate the parts of a formula, use as.character (check the examples in ?character) Helios 22 Sep 2011 16:14:05 -0400 From: Jean-Christophe BOU?TT? > Hello, > You can check ?model.frame. > I do not know however to extract only the right-hand of left-hand part > of a formula. > > JC > > 2011/9/22 trekvana : >> Hello all, >> >> So I am using the (formula entry) method for randomForests: >> >> randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that some of >> the items in that package dont take a formula entry - you have to explicitly >> state the y and x vector: >> >> randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...) >> >> Now my question is whether there is a function/way to tell R to take a >> formula and make the two corresponding datasets [x,y] (that way I dont have >> to create the x dataset manually with all 40 variables I have). >> >> There must be a more elegant way to do this than >> x=xxx[,c('x1','x2',...,'x40')] >> >> Thanks! >> George INSTITUTO DE BIOMECÁNICA DE VALENCIA Universidad Politécnica de Valencia • Edificio 9C Camino de Vera s/n • 46022 VALENCIA (ESPAÑA) Tel. +34 96 387 91 60 • Fax +34 96 387 91 69 www.ibv.org Antes de imprimir este e-mail piense bien si es necesario hacerlo. En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección de Datos de Carácter Personal, le informamos de que el presente mensaje contiene información confidencial, siendo para uso exclusivo del destinatario arriba indicado. En caso de no ser usted el destinatario del mismo le informamos que su recepción no le autoriza a su divulgación o reproducción por cualquier medio, debiendo destruirlo de inmediato, rogándole lo notifique al remitente. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing data from several matrices in R into one excel-file with several sheets
hello, thank you for your help! I was not successfull using the XLConnect-package. Anyway, I have to postpone this problem for now as I have to sort out some other other problems at the moment. marion 2011/9/16 Greg Snow > Look at the XLConnect package. > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of Marion Wenty > > Sent: Friday, September 16, 2011 9:19 AM > > To: r-help@r-project.org > > Subject: [R] writing data from several matrices in R into one excel- > > file with several sheets > > > > hello, > > > > does anyone know how I can write several matrices from R into one exel- > > file > > using different sheets for the different matrices? > > > > thank you very much in advance for your help. > > > > Marion > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting- > > guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Significance test
I have a bunch of benchmark measurements that look something like this: sample.10.000.0625000.0583300.058330 0.058330 sample.20.0583300.0583300.0583300.058330 0.058330 sample.30.0625000.0625000.0708300.062500 0.00 i.e each measurement take on one of a set of values. The set values isn't fixed, but they seem to go up increments; in this case, it appears to be about 4.17e-07 (e.g. it would be impossible for a measurement to be 0.066440). What is way to test for significant differences between two samples? Sorry if this is a noob question, but I'm kinda new to this. The two tests I'm aware of are the Student's t and Wilcoxon Rank Sum; neither seems to apply here. I've tried Googling this, but haven't found anything useful (maybe I'm not using the right terms...). Any help would be greatly appreciated. Regards, setro -- View this message in context: http://r.789695.n4.nabble.com/Significance-test-tp3836155p3836155.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Clusplot axes
I am a relative novice with R and am having some difficulty using 'clusplot' (package Cluster). I have performed PCA analysis (using vegan) on a large set of morphometric measurements and revealed up to 4 principal components. To examine the grouping of the data I have used PAM followed by clusplot to visualise the clusters. My problem is that I would like to see the clusters plotted on the PC2 and PC3 axes but cannot find a way to configure clusplot to do this. The default axes appear to be PC1 and PC2. Can someone please suggest a way to do this? Many thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Subsetting a zooreg object using window / subset
A nice alternative, Many thanks Achim Wesley >>> Achim Zeileis 22/09/2011 14:46 >>> On Thu, 22 Sep 2011, Gabor Grothendieck wrote: > On Thu, Sep 22, 2011 at 6:48 AM, Wesley Roberts wrote: >> Dear R users, >> >> >> I am currently working in subsetting a zooreg() object using either window >> or subset. I have a solution but it may be a bit cumbersome when I start >> working with actual data. Your inputs would be greatly appreciated. >> >> Example: I have a zooreg() object that starts in 1997 and ends in 2001. This >> object contains daily data for the 4 years >> >> aa<-zooreg(1:1825,start=as.Date("1997-01-01")) >> >> My aim is to subset the data according to seasons (Southern Hemisphere) for >> continuous years: December - January - February (DJF-Summer: 1997-2001), >> March - April - May (MAM-Autumn: 1997-2001), June - July - August >> (JJA-Winter: 1997-2001), September - October - November (SON-Spring: >> 1997-2001) thereby analysing the seasons data only for all years. The >> example below is only for DJF but I would like to replicate the analysis for >> each season. >> >> My solution so far uses subset to select the monthly data for each year and >> then rbind() the results. >> >> bb <- subset(aa, >> index(aa)>=as.Date("1998-12-01")&index(aa)<=as.Date("1999-02-28")) >> cc <- subset(aa, >> index(aa)>=as.Date("1999-12-01")&index(aa)<=as.Date("2000-02-28")) >> dd <- subset(aa, >> index(aa)>=as.Date("2000-12-01")&index(aa)<=as.Date("2001-02-28")) >> >> ee<- rbind(bb,cc,dd) >> >> The method above appears to do the job just fine except that I have around >> 30 locations (catchments) each with varying data availability and some with >> over 20 years worth of data. Ideally I would like to combine the second set >> of commands into a single command where I specify the start and end year and >> the months that I am interested in. >> > > This gives the season (1 = djf, 2 = mam, 3 = jja, 5 = son): > > seas <- as.numeric(format(as.yearqtr(as.yearmon(time(aa)) + 1/12), "%q")) An alternative route might be to go via the "mon" component of POSIXlt, e.g., as.POSIXlt(time(aa))$mon %in% c(11, 0, 1) instead of seas == 1 etc. > and this picks out djf: > > aa[seas == 1] > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Significance test
You've got to state the problem little bit more clear. What do you mean by "set"? Is it a list of certain possible values, available as outcomes of each single measurement (variate)? Or is it something else? How many variates do you have inside each sample? What is it exactly that you want to find? Do you want just to compare sample #1 and #2? There seems to be not enough variates for reliable result. Still, you may want to look at central tendencies (mean, median), i.e. location shift of samples, homogeneity of their variances, or the overall shape of empirical distributions. If your data are NOT normally distributed, you may use Wilcoxon rank sum test for medians,Kolmogorov-Smirnov for comparing empirical distribution functions and median-centering Fligner-Killeen test for homogeneity of variances. Or may be you are in fact looking for something else? May be you suspect that variates inside each sample vary together, according to some outside force? In that case you may want to calculate correlation coefficient - Perason product-moment for normal and Spearman for NOT normal data. All in all it seems like you need to consult some statistical textbook = ) Socal and Rolf is a good choice setrofim wrote: > > I have a bunch of benchmark measurements that look something like this: > sample.1 0.000.0625000.0583300.058330 > 0.058330 > ... > i.e each measurement take on one of a set of values. The set values isn't > fixed, but they seem to go up increments; in this case, it appears to be > about 4.17e-07 (e.g. it would be impossible for a measurement to be > 0.066440). > What is way to test for significant differences between two samples? > -- View this message in context: http://r.789695.n4.nabble.com/Significance-test-tp3836155p3836365.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 103, Issue 22
Szeptember 12-től 26-ig irodán kívül vagyok, és az emailjeimet nem érem el. Sürgős esetben kérem forduljon Kárpáti Edithez (karpati.e...@gyemszi.hu). Üdvözlettel, Mihalicza Péter I will be out of the office from 12 till 26 September with no access to my emails. In urgent cases please contact Ms. Edit Kárpáti (karpati.e...@gyemszi.hu). With regards, Peter Mihalicza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Newbie question: Converting Table
Hi, I'm new to R, and I have searched helpfiles and this forum on my 2 questions. Hope you guys can help me out! :-) Many thanks in advance! Cheers, Lars Q1: I imported a csv file with columnames subject and class. There are about 1000 different classes... It looks like this: subject1, class1 subject1, class2 subject2, class1 subject2, class3 ... subject999, class1 subject999, class2 Now I want to transform this in R into a table (with columnnames subject,class1,class2,...) like: subject1, yes, yes, no, ... subject2, yes, no, yes, ... ... Q2: I want to count the matching class patterns in the previous table (output: in a table with columns count, class1, ...). In this example for only the subjects1,2 and 999 it looks like this: 2,yes,yes,no,.. 1,yes,no,yes ... -- View this message in context: http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836468.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Newbie question: Converting Table
> > [R] Newbie question: Converting Table > > Hi, > > I'm new to R, and I have searched helpfiles and this forum on my 2 > questions. Hope you guys can help me out! :-) You did not search enough. You probably want table or xtabs Q1 untested res <- xtabs(~subject+class, data=your.file) ifelse(res==1, "yes", "no") Q2 I do not understand what exactly do you want. Please be more specific. BTW, if you are in it you'd rather give a look to posting guide. Regards Petr > > Many thanks in advance! > > Cheers, > > > Lars > > Q1: I imported a csv file with columnames subject and class. There are about > 1000 different classes... > It looks like this: > subject1, class1 > subject1, class2 > subject2, class1 > subject2, class3 > ... > subject999, class1 > subject999, class2 > > Now I want to transform this in R into a table (with columnnames > subject,class1,class2,...) like: > subject1, yes, yes, no, ... > subject2, yes, no, yes, ... > ... > > Q2: I want to count the matching class patterns in the previous table > (output: in a table with columns count, class1, ...). In this example for > only the subjects1,2 and 999 it looks like this: > 2,yes,yes,no,.. > 1,yes,no,yes > ... > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Newbie- > question-Converting-Table-tp3836468p3836468.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Testing packages
On 23.09.2011 10:16, Vikram Bahure wrote: Dear R users, It would be really helpful if I got to know the names of the packages which use the following for testing: pkg-Ex. Rout.save files (examples of testing) Simply take a look, there are really many. The source packages are all available from CRAN. I'd just unpack and use "find" ... If possible some testing links: to see how testing is done. See the manual "Writing R Extensions". Best, Uwe Ligges Thanks in advance. Regards Vikram [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] identifying cells in data frames with the same value
As Jim suggested, the duplicated() function should help. If I understand what you're after, you could try something like this. I assumed that the name of your data frame was "df". selrows <- df$WorkerID %in% df$WorkerID[duplicated(df$WorkerID)] # SubjectNumbers with duplicate WorkerIDs df$SubjectNumber[selrows] # Full records with duplicate WorkerIDs df[selrows, ] Jean jim holtman wrote on 09/21/2011 10:13:49 PM: > > ?duplicated > > Hard to give a specific solution unless you follow the posting guide > and provide a subset of the data to test on. > > On Wed, Sep 21, 2011 at 7:31 PM, stevesp101 wrote: > > Hi, > > > > I'm trying to find out if there is a command that tells me which cells in my > > data frame have the same value. I am looking at the results from an online > > survey, organized into a data frame with the following columns: > > SubjectNumber, WorkerID, Age. I know the one person must have taken the > > survey more than once, because there is one less level in the WorkerID > > column than there are rows in the data frame. Is there something that will > > tell me which SubjectNumber cells correspond to more than one WorkerID cell? > > Thanks, > > > > Stevesp > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to do Multiple Comparisons for a Mixed Effects Model
Allan Carson unbc.ca> writes: [snip] > When I try to conduct a > multiple comparison, I get an error (See below): > fm3<- lme(abovegroundbiomass.m.2~medium*amelioration*fertilizer*treatment, > random=~1|block/medium/amelioration/fertilizer) > tukeytest<-glht(fm3, linfct=mcp(treatment="Tukey")) > Error in contrMat(table(mf[[nm]]), type = types[pm]) : > less than two groups You should probably re-post this question to the r-sig-mixed-models mailing list, which specializes (as you would guess) in mixed models. I'm a little suspicious of your random effects specification. Are there really random effects at all four levels? i.e., are there four separate hierarchical levels at which the predictors vary? It's hard to diagnose this problem without a reproducible example. Is your model fit otherwise sensible? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How make a x,y dataset from a formula based entry
Also, if your formula is really of the form y ~x1+...+xn you can have a look at the last example for ?formula for a simple way to generate the formula. HTH, JC 2011/9/23 Helios de Rosario : > To separate the parts of a formula, use as.character > (check the examples in ?character) > > Helios > > 22 Sep 2011 16:14:05 -0400 > From: Jean-Christophe BOU?TT? >> Hello, >> You can check ?model.frame. >> I do not know however to extract only the right-hand of left-hand > part >> of a formula. >> >> JC >> >> 2011/9/22 trekvana : >>> Hello all, >>> >>> So I am using the (formula entry) method for randomForests: >>> >>> randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that > some of >>> the items in that package dont take a formula entry - you have to > explicitly >>> state the y and x vector: >>> >>> randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...) >>> >>> Now my question is whether there is a function/way to tell R to take > a >>> formula and make the two corresponding datasets [x,y] (that way I > dont have >>> to create the x dataset manually with all 40 variables I have). >>> >>> There must be a more elegant way to do this than >>> x=xxx[,c('x1','x2',...,'x40')] >>> >>> Thanks! >>> George > > > INSTITUTO DE BIOMECÁNICA DE VALENCIA > Universidad Politécnica de Valencia • Edificio 9C > Camino de Vera s/n • 46022 VALENCIA (ESPAÑA) > Tel. +34 96 387 91 60 • Fax +34 96 387 91 69 > www.ibv.org > > Antes de imprimir este e-mail piense bien si es necesario hacerlo. > En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección > de Datos de Carácter Personal, le informamos de que el presente mensaje > contiene información confidencial, siendo para uso exclusivo del > destinatario arriba indicado. En caso de no ser usted el destinatario > del mismo le informamos que su recepción no le autoriza a su divulgación > o reproducción por cualquier medio, debiendo destruirlo de inmediato, > rogándole lo notifique al remitente. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (sin asunto)
Look at the help page for Surv to see how to code left censored data. Be aware of the difference between left censored (we know the event happened before fecha) and left truncated (the subject entered observation at fecha) -- they are different concepts. The survival code can deal with both. Terry T. ---begin inclusion I want to know as mortality in different families of epiphytes after selective logging in the forest I want to make a survival analysis with left and right censored data. My study begins in 2004 but I have many individuals who enter the study in 2007 I have tried this: surara<-survfit(Surv(fecha,estado)~categoria) fecha= time estado= dead categoria= control and experimental but it is working just with right censored data __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] p values in coxph()
1) The p values in the printout are a Wald test. The Wald, score, and likelihood ratio tests are asymptotically equivalent, but may differ somewhat in finite samples. (The Wald and score are both Taylor series approximations to the LR). If you want to do an LR test, fit the two models and use the anova command. But beware if your second variable has missing values: the two fits have to be on the same sample. 2) Yes, coxph(Surv(time, status) ~1) is a valid Cox model. Not a particularly interesting one -- it's the LR for the overall fit of the baseline hazard which is equivalent to a Kaplan Meier when there are no covariates. Terry T. ---begin inclusion -- I'm interested in building a Cox PH model for survival modeling, using 2 covariates (x1 and x2). x1 represents a 'baseline' covariate, whereas x2 represents a 'new' covariate, and my goal is to figure out where x2 adds significant predictive information over x1. Ideally, I could get a p-value for doing this. Originally, I thought of doing some kind of likelihood ratio test (LRT), where i measure the (partial) likelihood of the model with just x1, then with x1 and x2, then it becomes a LRT with 1 degree of freedom. But when i use the summary() function for coxph(), i get the following output (shown at the bottom). I have two questions: 1) What exactly are the p-values in the Pr(>|z|) representing? I understand that the coefficients have standard errors, etc., but i'm not sure how the p-value there is calculated. 2) At the bottom, where it shows the results of an LRT with 2df, i don't quite understand what model the ratio is being tested against. If the current model has two variables (x1 and x2), and those are the extra degrees of freedom, then the baseline should then have 0 variables, but that's not really a Cox model? thanks for any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How make a x,y dataset from a formula based entry
On Thu, Sep 22, 2011 at 2:54 PM, trekvana wrote: > Hello all, > > So I am using the (formula entry) method for randomForests: > > randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that some of > the items in that package dont take a formula entry - you have to explicitly > state the y and x vector: > > randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...) > > Now my question is whether there is a function/way to tell R to take a > formula and make the two corresponding datasets [x,y] (that way I dont have > to create the x dataset manually with all 40 variables I have). > > There must be a more elegant way to do this than > x=xxx[,c('x1','x2',...,'x40')] We assume that the formula is of the form: fo <- y ~ x1 + x2 + x3 Now if we set: v <- all.vars(fo) and if DF is our data frame then DF[, v[1]] and DF[v[-1]] are the response and predictors. (You may need to add an intercept to the predictors and convert the predictors from data frame to a matrix depending on what you intend to do next.) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'save' saved object names instead of objects
Hello, I created an array to hold the results of a series of simulations I'm running: d.eta <- array(0,dim=c(3,3,200)) Then I tried to save the results using this: save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") When I later tried to reload them using this: d.eta <- load(file="D:/Simulation Results/sim 9-23-11 deta") I got the following: > class(d.eta) [1] "character" > d.eta [1] "d.eta" Why didn't it load the original object that I tried to save (the array)? Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'save' saved object names instead of objects
A more compact example might be helpful: g <- array(0,dim=c(4,4)) g save(g,file="D:/g") h <- load(file="D:/g") h -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Downey, Patrick Sent: Friday, September 23, 2011 9:32 AM To: r-help@r-project.org Subject: [R] 'save' saved object names instead of objects Hello, I created an array to hold the results of a series of simulations I'm running: d.eta <- array(0,dim=c(3,3,200)) Then I tried to save the results using this: save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") When I later tried to reload them using this: d.eta <- load(file="D:/Simulation Results/sim 9-23-11 deta") I got the following: > class(d.eta) [1] "character" > d.eta [1] "d.eta" Why didn't it load the original object that I tried to save (the array)? Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'save' saved object names instead of objects
Hi, did you try load(file="D:/Simulation Results/sim 9-23-11 deta") without the assignment ? look at ?load 2011/9/23 Downey, Patrick : > Hello, > > I created an array to hold the results of a series of simulations I'm > running: > > d.eta <- array(0,dim=c(3,3,200)) > > > > Then I tried to save the results using this: > > save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") > > When I later tried to reload them using this: > > d.eta <- load(file="D:/Simulation Results/sim 9-23-11 deta") > > I got the following: > >> class(d.eta) > [1] "character" >> d.eta > [1] "d.eta" > > Why didn't it load the original object that I tried to save (the array)? Is > the problem with how I'm saving or how I'm loading? Any explanation would > be greatly appreciated. > > And to head off this question, I did check after the simulation, before > saving, and the d.eta object is an array of numbers. > > Thanks, > Mitch > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using method = "aic" with pspline & survreg
--- begin inclusion -- Hi everybody. I'm trying to fit a weibull survival model with a spline basis for the predictor, using the survival library. I've noticed that it doesn't seem to be possible to use the aic method to choose the degrees of freedom for the spline basis in a parametric regression (although it's fine with the cox model, or if the degrees of freedom are specified directly by the user), and I was wondering if there is some reason for this? ... --- end inclusion --- A simple reason as it turns out: there was an incorrect variable name in the survpenal.fit function. A "variable not found" error is exactly what one would expect. I've now repaired the function for version 2.36.10 (which I hope to post shortly). The big surprise is that it has been wrong for about a decade, and no one had ever tried a situation that exercised that particular line of code -- or at least they never told me about the error. Thank you for the very clear description of the problem, which made it easy for me to track it down. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'save' saved object names instead of objects
This is one of the rare cases in R where you don't want to save the return value. You loaded d.eta, and then promptly overwrote it with the return value, which is just the name of the object. > ls() character(0) > d.eta <- array(0,dim=c(3,3,200)) > dim(d.eta) [1] 3 3 200 > save(d.eta, file="deta") > rm(d.eta) > ls() character(0) > load("deta") > ls() [1] "d.eta" > dim(d.eta) [1] 3 3 200 > # and compare > rm(d.eta) > ls() character(0) > d.eta.name <- load("deta") > ls() [1] "d.eta" "d.eta.name" > dim(d.eta) [1] 3 3 200 > d.eta.name [1] "d.eta" > Sarah On Fri, Sep 23, 2011 at 9:31 AM, Downey, Patrick wrote: > Hello, > > I created an array to hold the results of a series of simulations I'm > running: > > d.eta <- array(0,dim=c(3,3,200)) > > > > Then I tried to save the results using this: > > save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") > > When I later tried to reload them using this: > > d.eta <- load(file="D:/Simulation Results/sim 9-23-11 deta") > > I got the following: > >> class(d.eta) > [1] "character" >> d.eta > [1] "d.eta" > > Why didn't it load the original object that I tried to save (the array)? Is > the problem with how I'm saving or how I'm loading? Any explanation would > be greatly appreciated. > > And to head off this question, I did check after the simulation, before > saving, and the d.eta object is an array of numbers. > > Thanks, > Mitch > -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'save' saved object names instead of objects
Thank you Jean Christophe and Sarah. You are both, of course, absolutely correct. -Original Message- From: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com] Sent: Friday, September 23, 2011 9:44 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] 'save' saved object names instead of objects Hi, did you try load(file="D:/Simulation Results/sim 9-23-11 deta") without the assignment ? look at ?load 2011/9/23 Downey, Patrick : > Hello, > > I created an array to hold the results of a series of simulations I'm > running: > > d.eta <- array(0,dim=c(3,3,200)) > > > > Then I tried to save the results using this: > > save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") > > When I later tried to reload them using this: > > d.eta <- load(file="D:/Simulation Results/sim 9-23-11 deta") > > I got the following: > >> class(d.eta) > [1] "character" >> d.eta > [1] "d.eta" > > Why didn't it load the original object that I tried to save (the > array)? Is the problem with how I'm saving or how I'm loading? Any > explanation would be greatly appreciated. > > And to head off this question, I did check after the simulation, > before saving, and the d.eta object is an array of numbers. > > Thanks, > Mitch > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'save' saved object names instead of objects
On 23/09/2011 9:31 AM, Downey, Patrick wrote: Hello, I created an array to hold the results of a series of simulations I'm running: d.eta<- array(0,dim=c(3,3,200)) Then I tried to save the results using this: save(d.eta,file="D:/Simulation Results/sim 9-23-11 deta") When I later tried to reload them using this: d.eta<- load(file="D:/Simulation Results/sim 9-23-11 deta") I got the following: > class(d.eta) [1] "character" > d.eta [1] "d.eta" Why didn't it load the original object that I tried to save (the array)? It did, and then it overwrote it with the result of load(). (Load recreates variables with their original names. The return value is a vector of names. Use saveRDS and readRDS if you want the value saved/restored without its name. Duncan Murdoch Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to fit a non-normal-dist.-GARCH() time series?
Hi, i think the right to fit a GARCH-model is to use garchFit of the fGARCH package. My problem is that the time-series is definitly not normal distributed. So i can not use the "QMLE" method. How can i do it right? thanks Roland -- View this message in context: http://r.789695.n4.nabble.com/How-to-fit-a-non-normal-dist-GARCH-time-series-tp3836979p3836979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (Requested) caTools::runmean Patch
Dear Mr. Tuszynski, I would like to request what I believe would be a beneficial update / patch to the runmean() function in the caTools package. Consider the following R>> x = 1:100 R>> is.integer(x) [1] TRUE R>> library(caTools) R>> head(runmean(x, 5, alg="exact")) [1] 8.487983e-314 1.060998e-313 1.273197e-313 1.697597e-313 2.121996e-313 2.546395e-313 R>> head(runmean(x, 5, alg="C")) [1] 2.0 2.5 3.0 4.0 5.0 6.0 R>> head(runmean(as.double(x), 5, alg="C")) [1] 2.0 2.5 3.0 4.0 5.0 6.0 R>> head(runmean(as.double(x), 5, alg="exact")) [1] 2.0 2.5 3.0 4.0 5.0 6.0 As you can see (and can be verified in the code), unlike the call for the "C" algorithm, the "exact" algorithm does not make sure that x is stored as double resulting in occasional unexpected behavior. ## From caTools::runmean if (alg == "exact") { .C("runmean_exact", x, y, as.integer(n), as.integer(k), NAOK = TRUE, DUP = FALSE, PACKAGE = "caTools") } else if (alg == C"){ .C("runmean", as.double(x), y, as.integer(n), as.integer(k), NAOK = TRUE, DUP = FALSE, PACKAGE = "caTools") } Thanks once again for the fantastic package, Michael Weylandt cc: R-Help List. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Wrapper of linearHypothesis (car) for post-hoc of repeated measures ANOVA
Dear Helios, I've now had a chance to look at your code for the factorltest.mlm() function. I agree that the function makes it easier to test hypotheses in repeated-measures ANOVAs. When I have some more time, I'll make a few suggestions (off list) for improving the user interface to the function. Best, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Helios de Rosario > Sent: September-22-11 12:41 PM > To: r-help@r-project.org > Subject: [R] Wrapper of linearHypothesis (car) for post-hoc of repeated > measures ANOVA > > For some time I have been looking for a convenient way of performing post-hoc > analysis to Repeated Measures ANOVA, that would be acceptable if sphericity > is violated (i.e. leaving aside post-hoc to lme models). > > The best solution I found was John Fox's proposal to similar requests in R- > help: > http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26518.html > http://tolstoy.newcastle.edu.au/R/e10/help/10/04/1663.html > > However, I think that using linearHypothesis() is not as straightforward as I > would desire for testing specific contrasts between factor levels. The > hypotheses must be defined as linear combinations of the model coefficients > (subject to response transformations according to the intra-subjects design), > which may need some involved calculations if one is thinking on differences > between "this and that" factor levels (either between-subjects or intra- > subjects), and the issue gets worse for post-hoc tests on interaction > effects. > > For that reason, I have spent some time in writing a wrapper to > linearHypothesis() that might be helpful in those situations. I copy the > commented code at the end of this message, because although I have > successfully used it in some cases, I would like more knowledgeable people > to put it to test (and eventually help me create a worthwile contribution for > other people that could find it useful). > > This function (which I have called "factorltest.mlm") needs the multivariate > linear model and the intrasubject-related arguments (idata, > idesign...) that would be passed on to Anova() (from car) for a repeated > measures analysis, or directly the Anova.mlm object returned by Anova() > instead of idata, idesign... (I have tried to explain it clearly in the > commentaries to the code.) > > Moreover, it needs an argument "levelcomb": a list that represents the level > combinations of factors to be tested. There are different ways of > representing those combinations (through names of factor levels, or > coefficient vectors/matrices), and depending on the elements of that list the > test is made for main effects, simple effects, interaction contrasts, etc. > > For instance, let me use an example with the OBrienKaiser data set (as in the > help documentation for Anova() and linearHypothesis()). > > The calculation of the multivariate linear model and Anova is copied from > those help files: > > > phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, > 5)), > + levels=c("pretest", "posttest", "followup")) > > hour <- ordered(rep(1:5, 3)) > > idata <- data.frame(phase, hour) > > mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, > +post.1, post.2, post.3, post.4, post.5, > +fup.1, fup.2, fup.3, fup.4, fup.5) ~ > treatment*gender, > + data=OBrienKaiser) > > av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour) > > Then, let's suppose that I want to test pairwise comparisons for the > significant main effect "treatment" (whose levels are c("control","A","B")). > For the specific contrast between treatment "A" > and the "control" group I can define "levelcomb" in the following > (equivalent) ways: > > > levelcomb <- list(treatment=c("A","control")) levelcomb <- > > list(treatment=c(A=1,control=-1)) levelcomb <- > > list(treatment=c(-1,1,0)) > > Now, let's suppose that I am interested in the (marginally) significant > interaction between treatment and phase. First I test the simple main effect > of phase for different levels of treament (e.g. for the "control" > group). To do this, levelcomb must have one variable for each interacting > factor (treatment and phase): levelcomb$treatment will specify the treatment > that I want to fix for the simple main effects test ("control"), and > levelcomb$phase will have a NA value to represent that I want to test all > orthogonal contrasts within that factor: > > > levelcomb <- list(treatment="control",phase=NA) > > I could also use numeric vectors to define the levels of "treatment" > that I want to fix, as in the previous example, or if I want a more > complicated combination (e.g. if I want to test the phase effect for poole
Re: [R] Re-installing R
See FAQ for windows 2.7! - "2.7 How do I UNinstall R?". John On Thursday, 22 September 2011, Uwe Ligges wrote: > > > On 22.09.2011 14:47, Andrey A wrote: >> >> Dear R users >> How does one completely uninstall R from their machine? Going to control >> panel>programs does not do it for me. After installing the new version it >> will still remember my previous workspace and all packages I've installed. > > This seems to be Windows? > > remove.packages() removes packages. You found the way to uninstall the part that got installed, The uninstaller won't install stuff you installed independently (such as packages, additional config files). The workspace is just a file called ".RData" in your working directory. Since it is user data, the user has to delete it himself. > If you uninstall MS Word, it also won't remove all your .doc / .docx files - at least I hope so. > > Uwe Ligges > > > > > > >> Thank you. >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help < https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- John C Frain Economics Department Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:fra...@tcd.ie mailto:fra...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] comparing factor and value data (rather offtopic)
Dear all I have a bit off topic question. I need to compare some measured values with people's subjective estimation (was not done yet). Before I start the experiment I would like to consult some appropriate literature. Basically I will have several samples and several people can evaluate all samples. They can e.g. rank samples according to some feature orthey can do something else. Can I simply compare the average ranks with measured value? Where to look for some info about planing such experiment and evaluating results? Thanks for any hint. Petr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Correlation of variables with repeated measures.
I guess that I have just to consider the means of each subject, as indicated here. http://www-users.york.ac.uk/~mb55/intro/corrsim.htm Thanks On Thu, Sep 22, 2011 at 9:16 PM, Heverkuhn Heverkuhn wrote: > Hello > I have a dataframe that looks like this: > > Date Min Subj VAR1 VAR2 VAR3 > 1 8/30/2011 5min1 34.41042 126.08490 55.3548387 > 2 8/30/2011 10min1 34.53030 133.81343 61.600 > 3 8/30/2011 15min1 34.66297 118.38193 11.800 > 4 8/30/2011 20min1 34.82770 110.77767 6.600 > 5 8/30/2011 5min2 36.36994 116.24861 41.2258065 > 6 8/30/2011 10min2 36.37420 101.16457 13.600 > 7 8/30/2011 15min2 36.37453 92.26340 0.400 > 8 8/30/2011 20min2 36.37697 87.73650 0.000 > 9 8/30/2011 5min3 35.25667 146.90037 10.0645161 > 10 8/30/2011 10min3 35.36654 139.49364 6.000 > 11 8/30/2011 15min3 35.33833 135.75633 0.400 > 12 8/30/2011 20min3 36.01337 127.83797 0.000 > 13 8/30/2011 5min4 35.26742 84.78603 0.9677419 > 14 8/30/2011 10min4 35.17913 91.27093 1.800 > 15 8/30/2011 15min4 35.09825 92.03692 13.400 > 16 8/30/2011 20min4 35.36823 88.73337 4.800 > > and so on for more days. > > I would like to check the correlation and p of variables VAR1 VAR2 VAR3. > > if I use cor.test(tel$VAR1, tel$VAR2) > the observations are considered independent, and Indeed I got df=14 > I have seen that I can obtain a correlation for each block using this > script: > > http://stackoverflow.com/questions/2336056/how-to-do-correlation-with-blocks-or-repeated-measures > > I was wandering what I should do for obtain a correlation that account for > all the blocks. > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Envfit, inconsistant result?
Hi R-experts, I am using the envfit function over an ordination of floristic data. The problem is that every time that I run it changes the results. Sometimes dramatically, selecting variables that the first time were not significant. I do not get what could be the problem or if is normal given the permutations are different. # the NMDS ordination gap_flor_NMDS_chord <- metaMDS(gaps_flor, distance = "euclid", k = 2, trymax = 20, autotransform =TRUE, noshare = 0.1, wascores = TRUE, expand = TRUE, trace = 1, plot = FALSE, old.wa = FALSE, zerodist = "add") # the environmental variables to use with enfit explain1<- site[c("Tipo", "Gap.size", "Gap diameter (m)", "Size.cat", "altitud", "Slope (%)", "Exp.deg", "form","formcont", "largo_medio_gmak_m", "Dom.Hight", "d_m_gapmak_cm", "Cat_edad", "uprooted_perc", "Snapped gap maker (%)", "stand_dead_perc", "controlled_perc", "nodet_orig_gmkr_perc", "Total_borde", "PACL_diff_warm045", "rock", "musg_hep", "mantillo", "sm", "tronco_tot", "Time.ctr", "mf_gmk_perc", "fm_gmk", "dc_gmk_perc", "be_gmk_perc", "ach_gmk_perc", "nodet_spp_gmkr_perc", "Myrceugenia as border tree (%)", "Fm_borde.", "Dc_borde.", "Be_borde.", "Rv_borde.", "Aristotelia as border tree (%)")] # the Envfit calculation exp_flor1 <- envfit(gap_flor_NMDS_chord, explain1, permu = 999, na.rm=T) Thanks a lot for your help, comments and input! - Rodrigo Vargas G. - Silviculture Institute Freiburg University -- View this message in context: http://r.789695.n4.nabble.com/Envfit-inconsistant-result-tp3836585p3836585.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Newbie question: Converting Table
Thanks, I will read the posting guide. Q1: thanks for helping me out! Q2: What I mean is that given the dataset: subject1,class1_yes, class2_no, class3_yes, class4_no subject2, class1_no, class2_no, class3_no, class4_yes subject3, class1_yes, class2_no, class3_yes, class4_no I want to count for each unique class combination the number of subjects that share this whole combination. In this case the result should be: 2 counts for the combination class1_yes, class2_no, class3_yes, class4_no 1 count for the combination class1_no, class2_no, class3_yes, class4_yes Regards, Lars Op 23 sep. 2011 (w38), om 14:12 heeft Petr Pikal [via R] het volgende geschreven: > > [R] Newbie question: Converting Table > > Hi, > > I'm new to R, and I have searched helpfiles and this forum on my 2 > questions. Hope you guys can help me out! :-) You did not search enough. You probably want table or xtabs Q1 untested res <- xtabs(~subject+class, data=your.file) ifelse(res==1, "yes", "no") Q2 I do not understand what exactly do you want. Please be more specific. BTW, if you are in it you'd rather give a look to posting guide. Regards Petr > > Many thanks in advance! > > Cheers, > > > Lars > > Q1: I imported a csv file with columnames subject and class. There are about > 1000 different classes... > It looks like this: > subject1, class1 > subject1, class2 > subject2, class1 > subject2, class3 > ... > subject999, class1 > subject999, class2 > > Now I want to transform this in R into a table (with columnnames > subject,class1,class2,...) like: > subject1, yes, yes, no, ... > subject2, yes, no, yes, ... > ... > > Q2: I want to count the matching class patterns in the previous table > (output: in a table with columns count, class1, ...). In this example for > only the subjects1,2 and 999 it looks like this: > 2,yes,yes,no,.. > 1,yes,no,yes > ... > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Newbie- > question-Converting-Table-tp3836468p3836468.html > Sent from the R help mailing list archive at Nabble.com. > > __ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836611.html To unsubscribe from Newbie question: Converting Table, click here. -- View this message in context: http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836711.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error message when using 'optim' for numerical maximum likelihood
Hello All, I am trying to estimate the parameters of a stochastic differential equation (SDE) using quasi-maximum likelihood methods but I am having trouble with the 'optim' function that I am using to optimise the log-likelihood function. After simulating the SDE I generated samples of the simulated data of varying size (I want to see what effect adding more observations has on the accuracy of the estimates) and ran the 'optim' function to optimise the log-likelihood function. The optimiser seemed to work fine for sample sizes up to 100,000 i.e. the optim function converged, but when I tried to run optim using a sample size of 200,000 the optim failed to converge - the correspoding error message was "NEW_X". Can someone please advise what this error message means, and what I can do to avoid producing this error? I have supplied an extract of my code below for inspection (note that I am fairly new to programming so my code is probably not the most efficient/elegant...). Thank you in advance, Steven # I use a Milstein scheme to generate a simulation of the SDE I am trying to estimate Mil.sim <- function(X0,drift,diffusion,diffusion.x,horizon,no.steps) { set.seed(123) X <- rep(NA,no.steps+1) # initialise vector to store sample X[1] <- X0 shocks <- rnorm(no.steps) # generate normal shocks for FEM method step.size <- horizon/no.steps # define step size to use in simulation for (i in 2:(no.steps+1))# loop to generate sample { X[i] <- X[i-1] + drift(X[i-1])*step.size + diffusion(X[i-1])*sqrt(step.size)*shocks[i-1] + 0.5*diffusion(X[i-1])*diffusion.x(X[i-1])*step.size*(shocks[i-1]^2 - 1) } X <<- ts(X,start=0,end=horizon,frequency=1/step.size) # coerce simulated process into 'ts' class for ease of plotting } # generate simulation of SDE Mil.sim(1,d,s,s.x,1000,1000) # this sets up the sample and associated variables that I will use to carry out the estimation observations.1 <- seq(1,by=50,length(X))# set up sample of X, varying 'by=..' varies the size (and spacing) of the sample X.obs.1 <- X[observations.1] obs.times.1 <- (observations.1-1)/1 delta.1 <- obs.times.1[2] - obs.times.1[1] sample.1 <- data.frame(tt = obs.times.1,values = X.obs.1) # create data frame to be used in optimisation of log likelihood function n.1 <- length(sample.1$values)-1 # define the log-likelihood function for optimisation IEM.loglik.fn <- function(par,data) { A <- data[2:(n.1+1)]*(1-par[3]*delta.1) - par[1]*delta.1*(data[2:(n.1+1)]^(-1)) + par[2]*delta.1 + par[4]*delta.1*(data[2:(n.1+1)]^2) - data[1:n.1] B <- data[1:n.1]^(-2*par[6]) C <- 1 - par[3]*delta.1 + par[1]*delta.1*(data[2:(n.1+1)]^(-2)) + 2*par[4]*delta.1*data[2:(n.1+1)] loglik <- -(n.1/2)*log(2*pi*delta.1) - n.1*log(par[5]) - par[6]*sum(log(data[1:n.1])) - (1/(2*delta.1*(par[5]^2)))*sum(B*(A^2)) + sum(log(C)) } # define the gradient of the parameters to be estimated (6 parameters to estimate) IEM.gradient <- function(par,data) { A <- data[2:(n.1+1)]*(1-par[3]*delta.1) - par[1]*delta.1*(data[2:(n.1+1)]^(-1)) + par[2]*delta.1 + par[4]*delta.1*(data[2:(n.1+1)]^2) - data[1:n.1] B <- data[1:n.1]^(-2*par[6]) C <- 1 - par[3]*delta.1 + par[1]*delta.1*(data[2:(n.1+1)]^(-2)) + 2*par[4]*delta.1*data[2:(n.1+1)] diff.1 <- (1/(par[5]^2))*sum((data[2:(n.1+1)]^(-1))*A*B) + delta.1*sum((data[2:(n.1+1)]^(-2))*(C^(-1))) diff.2 <- -(1/(par[5]^2))*sum(A*B) diff.3 <- (1/(par[5]^2))*sum(data[2:(n.1+1)]*A*B) - delta.1*sum(C^(-1)) diff.4 <- -(1/(par[5]^2))*sum((data[2:(n.1+1)]^2)*A*B) + 2*delta.1*sum(data[2:(n.1+1)]*(C^(-1))) diff.5 <- -(n.1/par[5]) + (1/(delta.1*(par[5]^3)))*sum((A^2)*B) diff.6 <- -sum(log(data[1:n.1])) + (1/(delta.1*(par[5]^2)))*sum((log(data[1:n.1]))*(A^2)*B) obj <- c(diff.1,diff.2,diff.3,diff.4,diff.5,diff.6) return(obj) } # use optim function to find maximum likelihood parameter estimates opt <- optim(c(3,3,3,3,3,3),method="L-BFGS-B",lower=c(0,0,0,0,1e-8,0),fn=IEM.loglik.fn,gr=IEM.gradient,control=list(fnscale=-1),hessian=TRUE,data=sample.1$values) -- S [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Significance test
Yuta, Thanks for the response. Yuta wrote: > > You've got to state the problem little bit more clear. > > What do you mean by "set"? Is it a list of certain possible values, > available as outcomes of each single measurement (variate)? Or is it > something else? > How many variates do you have inside each sample? > What is it exactly that you want to find? Sorry, I should have been more clear. My team is working on a software system. This system comes with a set of benchmarks that exercise specific functionality. I am attempting to measure the performance impact of the changes made my my team. Each of the samples in my previous post represents a particular "build" of this software system and corresponding to it there are five measurements of a benchmark execution (each benchmark is executed five times for each build). Each measurement is time in seconds, so there isn't a list of all possible values as such. However, it seems that for specific benchmarks, the execution times seem to vary by at least some minimal amount (4.17e-07 for the samples i've posted), so the distribution of the measurements is essentially becoming discrete. Yuta wrote: > Do you want just to compare sample #1 and #2? I want to be able to compare any pair of samples (that is, "builds"). Yuta wrote: > There seems to be not enough variates for reliable result. Yes, unfortunately, the full set of benchmarks takes a while to run, and this ties up resources, etc. So the number of variates available for a particular build is limited. Yuta wrote: > Still, you may want to look at central tendencies (mean, median), i.e. > location shift of samples, homogeneity of their variances, or the overall > shape of empirical distributions. Yes, I'm basically looking at the difference between the means of the five runs between two samples. But I need an indicator of whether the difference is significant. At the moment, I'm doing a t-test, and that sort-of works, but from the results I'm getting, I'm not sure how accurate it is, so I've started to wonder if I'm doing something wrong. Yuta wrote: > If your data are NOT normally distributed The way the benchmarks are calculated, each measurement itself is a mean. I believe the mean of the five means should be normally distributed (at least, if they weren't "discrete-ized", as described above)? I guess, the crux of my question is -- does the t-test apply in this case, or should I be doing something else? Yuta wrote: > All in all it seems like you need to consult some statistical textbook = ) > Socal and Rolf is a good choice Yes, it seems so. Thanks for the recommendation. Looks like I'll be stopping by the book shop on the way home this evening :). Regards, setro -- View this message in context: http://r.789695.n4.nabble.com/Significance-test-tp3836155p3836770.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Kolmogorov-Smirnov test
Dear Dr. Snow, I would like to ask for help on my three questions regarding Kolmogorov Smirnov test. 1. 'With a sample size over 10,000 you will have power to detect differences that are not practically meaningful. ' -Is sample size of 3000 for each sample okay for using Kolmogorov Smirnov test? 2. I am checking whether my KS procedure is correct. I have compared results of KS tests using the following 3 softwares: 1. Statistica 2. http://www.wessa.net/rwasp_Reddy-Moores%20K-S%20Test.wasp 3. http://www.physics.csbsju.edu/stats/KS-test.html I have observed that the three softwares produced the same results only if the samples sizes are equal. However, when samples are not equal, I did not get similar results particularly from the wessa.net calculator. Is it allowed to do a KS test to compare samples with unequal sizes? 3. Is it allowed to use the raw data values in doing KS test? Or should I use the frequencies obtained from frequency distribution table of the raw data from each sample? I think that when I use the frequency, the KS test will construct new cumulative fractions from the frequencies, which I think is not right. Hope you can assist me. Thanks! -rommel -- View this message in context: http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-tp3479506p3836910.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R functions
Hi group, code: >m<-read.table("test.txt",sep='\t',header=TRUE,colClasses=c('character','integer','integer','numeric','numeric')) > >s<-data.frame(c(rle(m$Sample1)[[2]],rle(m$Sample2)[[2]]),c(rle(m$Sample1)[[1]],rle(m$Sample2)[[1]])) > > names(s)=c("Values","Probes") >G=1 > for(i in 1:length(s$Probes)){ + if(G==1){first<-unique(m$Chr[G:s$Probes[i]]) + second<-min(m$Start[G:s$Probes[i]]) + third<-max(m$End[G:s$Probes[i]]) + c<-cbind(first,second,third,s$Values[i],s$Probes[i]) + print (c) + G=(G+s$Probes[i])} + else if((G-1) < length(m$Sample1)) { + first<-unique(m$Chr[G:(G+s$Probes[i]-1)]) + second<-min(m$Start[G:(G+s$Probes[i]-1)]) + third<-max(m$End[G:(G+s$Probes[i]-1)]) + c<-cbind(first,second,third,s$Values[i],s$Probes[i]) + print (c) + G=(G+s$Probes[i])} + else { + G=1 + first<-unique(m$Chr[G:s$Probes[i]]) + second<-min(m$Start[G:s$Probes[i]]) + third<-max(m$End[G:s$Probes[i]]) + c<-cbind(first,second,third,s$Values[i],s$Probes[i]) + print (c) + G=(G+s$Probes[i])} + } so the out put is: first secondthird [1,] "chr2" "9896633" "14404502" "0" "4" first second third [1,] "chr2" "14421718" "16048724" "-0.43" "4" first second third [1,] "chr2" "37491676" "37703009" "0" "2" first secondthird [1,] "chr2" "9896633" "9896690" "0" "2" first second third [1,] "chr2" "14314039" "16048724" "-0.35" "6" first second third [1,] "chr2" "37491676" "37703009" "0" "2" So I need 2 modifications to this code: 1)since this is just a small part of the file (with 2 samples), but my actual file has 150 samples, so how do I write rle fuction for that? 2)how do I store all the executed c values as a dataframe? Thanks, Suji "Hi group, I am trying to right a code to do the following This is how the test file looks like: Chr start end sample1 sample2 chr2 9896633 9896683 0 0 chr2 9896639 9896690 0 0 chr2 14314039 14314098 0 -0.35 chr2 14404467 14404502 0 -0.35 chr2 14421718 14421777 -0.43 -0.35 chr2 16031710 16031769 -0.43 -0.35 chr2 16036178 16036237 -0.43 -0.35 chr2 16048665 16048724 -0.43 -0.35 chr2 37491676 37491735 0 0 chr2 37702947 37703009 0 0 Now I want to summarize the values like Sample Chr Start End Values Probes 1 chr2 9896633 14404502 0 4 1 chr2 14421718 16048724 -0.43 4 1 chr2 37491676 37703001 0 2 2 chr2 9896633 9896690 0 2 2 chr2 14314039 16048724 -0.35 6 2 chr2 37491676 37703009 0 2 Here the start for the first line would be the least value until values are similiar (4) then the end would be highest value. The values is the unique value among the common values. Can I get some ideas or suggestions to perform this because I am new to hard core program in R? " -- View this message in context: http://r.789695.n4.nabble.com/R-functions-tp3816748p3836806.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] spatstat => owin + image
Dear Community I am at my wits end and seek advice. My wish is to plot coordinates (x,y in WGS84_UMTS for the ones interested) of sampling points. This I can do by the standard spatstat prodcedure via owin. I then try to add an image, which is a map/satellite photo in the background. Firstly Problem: With the current code, I can not get the edges of the image to match the boarders of the plot itself (not the entire plot window, solely the coordinate system) The size of the image I have (from GPS work) Any ideas? Secondly, I am confused of how to get coordinates into an owin plot. It doesnt want to work. Thirdly, is with spatstat only always one mark possible? Or can I differentiate further? Code, for reference purposes CODE ~~ data data = read.xls("name.xls") x1=floor(min( data[,2],na.rm=T )*(1-b)) x2=ceiling(max(data[,2],na.rm=T )*(1+b)) y1=floor(min(data[,3],na.rm=T )*(1-c)) y2=ceiling(max(data[,3],na.rm=T )*(1+c)) x1 x2 y1 y2 w = owin(c(x1,x2),c(y1,y2)) w dat1 = as.ppp(data[,2:4],w) is.ppp(dat1) str(dat1) #Get the plot information so the image will fill the plot box, and draw it ima = readPNG("file.png") lim = par() rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4]) par(new=T) plot(dat1, use.marks=T) ~~~ Thank you for any advice. Kind Regards TKD -- View this message in context: http://r.789695.n4.nabble.com/spatstat-owin-image-tp3837023p3837023.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)
Take a look at http://biostat.mc.vanderbilt.edu/SweaveConvert The most general approach is to convert from PDF to word using one of the web sites. An example is given (input + output) in the above site. Frank Joshua Wiley-2 wrote: > > Hi Tal, > > Just another note, I recently joined the R2HTML team. I am still > slogging through the Sweave code trying to understand it better, but > in the coming months I will be working on implementing more of the > features in R's RweaveLatex() driver for HTML. This will not > precisely help a LaTeX to HTML conversion, but will perhaps make a > pure HTML implementation more palatable. > > HTML5 is theoretically supported on the latest browsers and has > supports mathml which *should* provide a means of including elegant > formulae in HTML pages. In my experience, there seems to be > considerable cross-browser/version variability. Here is an example > that seems to work fairly well for most browsers (thanks to mathjax): > http://www.ats.ucla.edu/stat/r/dae/rreg.htm > > Cheers, > > Josh > > On Thu, Sep 22, 2011 at 4:09 PM, Tal Galili> wrote: >> Hello dear R help members, >> I have found several references on how to do this, my question is if >> anyone >> is actually using them - and if there are some strong points on what to >> use, >> and how well it is working out. >> >> My goal is to be able to easily create docs from R, but to be able to >> share >> it with other researchers (who do not use LaTeX) so they could easily >> copy/paste the tables and edit them for their needs (pdf is not solving >> this >> for me). >> >> The only reasonable solution I came by so far is to use HTML markup >> coupled >> with R2HTML (or odfWeave or R2wd). But nothing that can work with >> LaTeX->HTML (easily) >> >> I have asked a similar question here: >> http://stackoverflow.com/questions/7512897/how-to-turn-a-latex-sweave-file-rnw-into-html >> And also noticed it was asked half a year ago here: >> http://tex.stackexchange.com/questions/4145/workflow-for-converting-latex-into-open-office-ms-word-format >> The general issue of TeX to HTML was discussed also in these places: >> http://tex.stackexchange.com/questions/50/how-can-i-convert-math-less-latex-documents-into-microsoft-word >> >> And obviously the following page offers other good resources to consider: >> http://cran.r-project.org/web/views/ReproducibleResearch.html >> >> p.s: I search the R-help for this topic, but "sweave html" didn't seem to >> yield good results - my apologies if this has been heavily debated before >> - >> links would be welcomed as well. >> >> >> Tal >> >> >> >> Contact >> Details:--- >> Contact me: tal.gal...@gmail.com | 972-52-7275845 >> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | >> www.r-statistics.com (English) >> -- >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > Programmer Analyst II, ATS Statistical Consulting Group > University of California, Los Angeles > https://joshuawiley.com/ > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/How-to-turn-a-LaTeX-Sweave-file-Rnw-into-HTML-odf-docx-under-windows-tp3835230p3836939.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Homography with R
Hello, I would like to know if it exists a package including something equivalent to this page: http://www.developpez.net/forums/d740403/autres-langages/algorithmes/contribuez/image-geometrie-projective-homography/ http://www.developpez.net/forums/d740403/autres-langages/algorithmes/contribuez/image-geometrie-projective-homography/ I've searched with these keywords: R-project homography warping, but with no success. I'm not very good at R and I don't know java. So any help is welcome. Have a nice week-end, Ptit Bleu. -- View this message in context: http://r.789695.n4.nabble.com/Homography-with-R-tp3837111p3837111.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] tikzDevice install problem
Hi everybody! I'm trying to install the tikzDevice package, and I keep on getting the > ERROR: dependency filehash is not available for package tikzDevice I tried install.packages('filehash') and I get > package filehash is not available Does anybody have the same problem or any hint? thank youhelena [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] identifying cells in data frames with the same value
Thanks very much to both of you. Duplicated does exactly what I'm looking for. Sorry -- I didn't realize that I was supposed to provide a subset of my data frame. A little late now, but here it is -- the data frame is called SubInfo, and it gives background informations on subjects from a survey: > dput(SubInfo) structure(list(Subject = 1:48, Workerid = structure(c(33L, 23L, 16L, 21L, 11L, 44L, 47L, 7L, 39L, 36L, 38L, 15L, 2L, 45L, 22L, 14L, 19L, 37L, 5L, 17L, 20L, 29L, 13L, 43L, 42L, 8L, 3L, 1L, 24L, 35L, 6L, 9L, 28L, 4L, 41L, 34L, 10L, 25L, 18L, 9L, 27L, 12L, 46L, 30L, 31L, 26L, 40L, 32L), .Label = c("A16BIY1187GJ8I", "A175PJR0W3LO8i", "A17AT6S84ZFYWG", "A18QT7CR516RCY", "A198LBD7JZ4MRN", "A1BRP5AG7W8ZHS", "A1E0EK09CA5OiO", "A1E3iEF9JNJi53", "A1E3IEF9JNJI53", "A1FKOJKKBNQWM0", "A1JQS9AN8LEAKZ", "A1LBK6WW8KWZ33", "A1N914XTP4CJ7X", "A1P5PJZSYJVDHW", "A1RG33R69110SS", "A1RWNYJA5X25YH", "A1S70ZQ1ZWQ9DL", "A1V7V575QQGVDR", "A1WGSW0SLN4Y91", "A1Y0KX38WMS7VE", "A1Y25W1Y7KDE5", "A1Z6YiiHH2BARZ", "A23GOiRMXZ2TWi", "A2BNOEYZ3VRW2R", "A2J734LHPHBFKL", "A2MGH3MBXMKD96", "A2V3P1XE33NYC3", "A39RBYX03I6A51", "A3F3K6UZXFECJ1", "A3ICTZEPK4YUG", "A3IRZNKWK21P7G", "A3KO392GXBRUNW", "A3OLBiOP3Q6ZTX", "A3OZ8KF0HWSVWK", "A3PXV3J5IEUTA9", "A3S5L3i8O3Q2G", "A3TYWTLNiKKD29", "A3UZTA5Z0i666X", "A5HNNY0JAiAEL", "A91OXJPTS9K30", "AAIVI6RFHIISN", "ADKVWT5G226AW", "AM43UEVBOUDTY", "AOMQPLPiBDFJ5", "AQTNAR72ARCAM", "ARB4PAABFRZA4", "AYJF016iTKKW9"), class = "factor"), Age = structure(c(17L, 25L, 30L, 23L, 16L, 14L, 11L, 24L, 11L, 9L, 12L, 10L, 11L, 4L, 9L, 31L, 20L, 3L, 9L, 27L, 24L, 28L, 19L, 22L, 15L, 6L, 8L, 1L, 29L, 5L, 8L, 5L, 7L, 26L, 7L, 21L, 13L, 13L, 17L, 7L, 18L, 6L, 9L, 26L, 2L, 19L, 12L, 15L), .Label = c("18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "34", "36", "37", "38", "40", "41", "44", "45", "47", "50", "53", "54", "55", "57", "58", "60", "61", "N/A"), class = "factor")), .Names = c("Subject", "Workerid", "Age"), class = "data.frame", row.names = c(NA, -48L )) The code that Jean suggested works perfectly: selrows <- SubInfo$Workerid %in% SubInfo$Workerid[duplicated(SubInfo$Workerid)] Thanks! Stevesp101 -- View this message in context: http://r.789695.n4.nabble.com/identifying-cells-in-data-frames-with-the-same-value-tp3831881p3837191.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] new package 'SeleMix' for selective editing
Dear R users, we would like to announce that on the CRAN a new package (SeleMix version 0.8.1) for selective editing is available. This package includes functions for identification of outliers and influential errors in numerical data. For each unit, it provides also anticipated values (predictions) for both observed and non observed variables. The method is based on explicitly modelling both true (error-free) data and error mechanism through a two-component Gaussian mixture. Specifically, true data (first mixture component) are supposed to follow normal or log-normal distribution. We assume that only a subset of data (second mixture component) is affected by error and that the error mechanism is specified through a Gaussian random variable with zero mean vector and covariance matrix proportional to the covariance matrix of the true data distribution. We would appreciate any feedback Sincerely, Teresa Buglielli and Ugo Guarnera -- Teresa Buglielli Methods, Tools and Methodological Support Italian National Institute of Statistics bugli...@istat.it Ugo Guarnera Methods, Tools and Methodological Support Italian National Institute of Statistics guarn...@istat.it ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tikzDevice install problem
On 23.09.2011 16:39, Helena Peña wrote: Hi everybody! I'm trying to install the tikzDevice package, and I keep on getting the ERROR: dependency ‘filehash’ is not available for package ‘tikzDevice’ I tried install.packages('filehash') and I get package ‘filehash’ is not available Which OS? Which version of R? Which mirror? I guess Windows or Mac and your version of R is seriously outdated. Uwe Ligges Does anybody have the same problem or any hint? thank youhelena [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sorting multiple columns of a matrix
Hi, I have a question about how to sort a matrix for multiple columns. dat<-sample(0:1,1000,replace=T) matrix(dat,ncol=5,nrow=200)->x I want to order like the following: x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x My problem: the number of columns of the matrix to be sorted is variable, in any way I would like to sort for all columns from 1:ncol(x). How to achieve this? Best Maxim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sorting multiple columns of a matrix
Use do.call(func, listOfArgs) when you don't know how many arguments will be passed to func. E.g., > x <- cbind(round(sin(1:10)), round(cos(1:10)), round(tan(1:10))) > x[do.call("order", split(x, col(x))), , drop=FALSE] [,1] [,2] [,3] [1,] -1 -11 [2,] -1 -11 [3,] -10 -3 [4,]0 -10 [5,]0 -10 [6,]010 [7,]10 -7 [8,]10 -2 [9,]111 [10,]112 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 Maxim > Sent: Friday, September 23, 2011 9:22 AM > To: r-help > Subject: [R] sorting multiple columns of a matrix > > Hi, > > > I have a question about how to sort a matrix for multiple columns. > > > dat<-sample(0:1,1000,replace=T) > > matrix(dat,ncol=5,nrow=200)->x > > > I want to order like the following: > > > x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x > > > My problem: the number of columns of the matrix to be sorted is variable, in > any way I would like to sort for all columns from 1:ncol(x). How to achieve > this? > > > Best > > > Maxim > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] LDA cutoff value
Hello, I have run a linear discriminant analysis for the simple 2 group case using the MASS package lda() function. With priors fixed at 0.5 and unequal n for each group, the output basically provides the group means and the LD1 value. There is no automatic output of the cutoff (decision boundary) value used to classify values of the response variable into the different groups. I have tried various unsuccessful approaches to extract this value. It is obvious that in the simple 2 group case the value will be close to the mean of the 2 group means and that the LD1 value is involved (perhaps grand mean * LD1?). I am probably missing (misunderstanding?) the obvious and would appreciate being educated in this matter. Thanks. Regards,BJ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] LDA cutoff value
This is not an R question. Post it on a statistics site like stackexchange, instead. http://stats.stackexchange.com/ -- Bert On Fri, Sep 23, 2011 at 9:49 AM, B Jessop wrote: > > > > > Hello, I have run a linear discriminant analysis for the simple 2 group > case using the MASS package lda() function. With priors fixed at 0.5 and > unequal n for each group, the output basically provides the group means and > the LD1 value. There is no automatic output of the cutoff (decision > boundary) value used to classify values of the response variable into the > different groups. I have tried various unsuccessful approaches to extract > this value. It is obvious that in the simple 2 group case the value will be > close to the mean of the 2 group means and that the LD1 value is involved > (perhaps grand mean * LD1?). I am probably missing (misunderstanding?) the > obvious and would appreciate being educated in this matter. Thanks. > Regards,BJ >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] image function help required
Hi, I have a question concerning the image function and how to generate custom axis labels: dat<-sample(0:1,1000,replace=T) matrix(dat,ncol=5,nrow=200)->x x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x I would like to have a heatmap kind of thing like this: image(t(x),col=c(0,1),axes=F) axis(1, 1:5, c(colnames(x))) I only do see parts of the axis (only an "A" is drawn, position is wrong in addition), what is wrong? For a normal xy-plot this type of axis-definition obviously works plot(1:5, rnorm(5), axes = FALSE) axis(1, 1:5, c(colnames(x))) What do I miss? I tried in addition lattice's levelplot (no luck yet) as well as a heatmap, which I find has not enough control to produce more complex pictures consisting of multiple plots! Where should I go? Maxim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] converting object elements to variable names and making subsequent assignments thereto
This has got to be incredibly simple but I nevertheless can't figure it out as I am apparently brain dead. I just want to convert the elements of a character vector to variable names, so as to then assign formulas to them, e.g: z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) and lm(y~x[,2]), to the variables "model1" and "model2". There are of course, many more than 2 models involved, so brute force is the option of absolute last resort. Thanks for any help. -- Jim Bouldin, Research Ecologist [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] LDA cutoff value
On Fri, 23 Sep 2011, B Jessop wrote: Hello, I have run a linear discriminant analysis for the simple 2 group case using the MASS package lda() function. With priors fixed at 0.5 and unequal n for each group, the output basically provides the group means and the LD1 value. There is no automatic output of the cutoff (decision boundary) value used to classify values of the response variable into the different groups. I have tried various unsuccessful approaches to extract this value. It is obvious that in the simple 2 group case the value will be close to the mean of the 2 group means and that the LD1 value is involved (perhaps grand mean * LD1?). I am probably missing (misunderstanding?) the obvious and would appreciate being educated in this matter. Thanks. Regards,BJ Yes: 'discrimination' is not 'classification'. However, this and the way to use LDA for classification are covered in the book for which MASS is support software, so please do your homework from that book. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] FW: ARIMA - Skipping intermediate lags
Sorry that forgot to put R-forum in the loop... -Original Message- From: Bogaso Christofer [mailto:bogaso.christo...@gmail.com] Sent: 23 September 2011 22:53 To: 'Prof Brian Ripley' Cc: 'leighton155' Subject: RE: [R] ARIMA - Skipping intermediate lags Dear Prof. Ripley, thanks for your reply. But 1st of all I would like to point that I did not want any **Free Statistical Consultancy**. I just followed the posting guide which says that "Questions about statistics: The R mailing lists are primarily intended for questions and discussion about the R software. However, questions about statistical methodology are sometimes posted. If the question is well-asked and of interest to someone on the list, it may elicit an informative up-to-date answer.".and neither my previous mail meant for any such. I saw your comment and I felt that you pointed not to ignore intermediate lag. However ofcourse there could be 2nd meaning of your statement, where your said that " Note that this is not recommended in general ". Does this mean that, you pointed not to use "'fixed' argument "? If not then the only meaning of your suggestion would be you are asking not to go with any omission of the intermediate lag. Would somebody else here in this forum correct me if I understood the English wrong? OP said "This would tell the program I am interested in AR lag 5, MA lag 5, and MA lag 7, all while skipping the intermediate lags ". Then your answer was " Note that this is not recommended in general ". Sorry to bother you but I am really confused. Thanks and regards, -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: 22 September 2011 21:57 To: Bogaso Christofer Cc: 'leighton155' Subject: RE: [R] ARIMA - Skipping intermediate lags On Thu, 22 Sep 2011, Bogaso Christofer wrote: > Dear Prof. Repley, may I know in details why ignoring intermediate > lags are sin? How the statistical properties will be worse than not > ignoring them? If Who said that? And no, R-help is not the place for free statistical consultancy, so it is offensive to even ask. > I am correct then, ignoring some parameters means we know the > population values for them. Therefore in this case, my MSE estimate > should be smaller (or, my prediction will be more accurate) isn't it? > > Thanks and regards, > > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Prof Brian Ripley > Sent: 21 September 2011 13:32 > To: leighton155 > Cc: r-help@r-project.org > Subject: Re: [R] ARIMA - Skipping intermediate lags > > On Tue, 20 Sep 2011, leighton155 wrote: > >> Hello, >> >> I am a new R user. I am trying to use the arima command, but I have >> a question on intermediate lags. I want to run in R the equivalent >> Stata command of ARIMA d.yyy, AR(5) MA(5 7). This would tell the >> program I am interested in AR lag 5, MA lag 5, and MA lag 7, all >> while skipping the intermediate lags of AR 1-4, and MA 1-4, 6. Is >> there any way to do this in R? Thank you. > > Yes. See the 'fixed' argument on the help page. Note that this is > not recommended in general > >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/ARIMA-Skipping-intermediate-lags-tp3828 >> 4 49p3828449.html Sent from the R help mailing list archive at >> Nabble.com. >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
The usual response to this sort of question is usually something like the following: assign() will do what you want; get() runs the other direction. But the more R way to do it is to put all the models in a list. Michael On Fri, Sep 23, 2011 at 1:03 PM, Jim Bouldin wrote: > This has got to be incredibly simple but I nevertheless can't figure it out > as I am apparently brain dead. > > I just want to convert the elements of a character vector to variable > names, > so as to then assign formulas to them, e.g: > z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) > and > lm(y~x[,2]), to the variables "model1" and "model2". > > There are of course, many more than 2 models involved, so brute force is > the > option of absolute last resort. > Thanks for any help. > -- > Jim Bouldin, Research Ecologist > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] image function help required
On 23.09.2011 19:03, Maxim wrote: Hi, I have a question concerning the image function and how to generate custom axis labels: dat<-sample(0:1,1000,replace=T) matrix(dat,ncol=5,nrow=200)->x x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x I would like to have a heatmap kind of thing like this: image(t(x),col=c(0,1),axes=F) axis(1, 1:5, c(colnames(x))) I only do see parts of the axis (only an "A" is drawn, position is wrong in addition), what is wrong? For a normal xy-plot this type of axis-definition obviously works plot(1:5, rnorm(5), axes = FALSE) axis(1, 1:5, c(colnames(x))) You have not spewcified the x coordinates in your image() call and hence got the things between 0 and 1 rather than 1:5. If you want the latter, specify it: image(x=1:5, z=t(x),col=c(0,1),axes=F) axis(1, 1:5, c(colnames(x))) Uwe Ligges What do I miss? I tried in addition lattice's levelplot (no luck yet) as well as a heatmap, which I find has not enough control to produce more complex pictures consisting of multiple plots! Where should I go? Maxim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] image function help required
Hi, image() resizes the range of the data to roughly 0-1 , as you can see with par()$usr so what you need is: axis(1, 1:5/5, colnames(x)) or something similar. the c() c(colnames(x)) is unnecessary, since colnames(x) already returns a character vector, but in the example you provided (thanks!), x doesn't have any colnames any way. Sarah On Fri, Sep 23, 2011 at 1:03 PM, Maxim wrote: > Hi, > > > I have a question concerning the image function and how to generate custom > axis labels: > > > > dat<-sample(0:1,1000,replace=T) > > matrix(dat,ncol=5,nrow=200)->x > > x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x > > > I would like to have a heatmap kind of thing like this: > > > > image(t(x),col=c(0,1),axes=F) > > axis(1, 1:5, c(colnames(x))) > > > I only do see parts of the axis (only an "A" is drawn, position is wrong in > addition), what is wrong? > > > For a normal xy-plot this type of axis-definition obviously works > > > plot(1:5, rnorm(5), axes = FALSE) > > axis(1, 1:5, c(colnames(x))) > > > > What do I miss? > -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Cross Spectrum : Conversion of 2-D spectrum into a single complex array
Hi, I'm wondering why the spectrum() phase of quadrature couple isn't purely +/-pi. But mostly, I'm looking for a recommended way to take a 2-D spectrum and convert it into a single complex array. Kindly consider: # 10 Hz sine wave 10 seconds long sampled at 50 Hz deltaT = 1/50 t = seq(0, 10, deltaT) w = 2 * pi * 10 x = ts( sin( w * t ), deltat = deltaT ) y = ts( sin( w * t ), deltat = deltaT ) # Want the cross spectrum between x and y Sxy = spectrum( cbind( x, y ), plot = F ) # The phase is perfectly zero plot( Sxy $ freq, Sxy $ phase[ ,1], type = 'l' ) # Make y a quadrature component of x y = ts( cos( w * t ), deltat = deltaT ) Sxy = spectrum( cbind( x, y ), plot = F ) # The phase should be either +pi or -pi # since exp(i pi) = exp(-i pi) = -1 + 0i # Why isn't it? Sampling issues? Nyquist has been satisfied. plot( Sxy $ freq, Sxy $ phase[ ,1], type = 'l' ) # The real question (limited to a 2-D input): # How to combine the amplitude/phase into a single # complex valued cross spectrum? mySxy = complex( real = Sxy $ spec[,1] * Sxy$ spec[,2], imaginary = Sxy $ phase[ ,1] ) # This does give something affine to a plot of Sxy # Compare plot( Sxy, log="dB" ) # to: plot( Sxy$freq, 10*log10( Re(mySxy) ), type='l') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] vegan rda na adaptation
Dear R users, I know, the topic is more related to the r-sig-ecology. I decided to post it to the r-help as some specific topics of my question deals with NA-values and RDA (R vegan) and an adaptated RDA code due to a specific study design (including a second matrix). I am calculating a RDA for a dependent matrix (different variables for tree performance) and different explanatory variables (species identitiy, diversity, soil data, ground vegetation). I would very much appreciate some help with my txt input file for the vegan function. As for standard RDA's I have different plots (lines, the dependent matrix) and for each plot a value for diversity, soil and vegetation (in columns, the environmental matrix). I additionally have different species for each plot (separated in columns). In standard RDA's for vegetational data you put your dependent variable (e.g. number of a specific species in the specific plot) below your species columns. Problem: I do not have vegetational data with values 0, 1,2, 3 for each plot and species. I have 6 species in total, but the plots have a predetermined diversity level (e.g. 1, 2, 4, 6). So in comparison to vegetational data I do not have '0' values. For example in my 4 species plot I have 4 species and two missing (NA) values. I have read some papers using the same analysis for biodiversity experiments, so it should be appropriate. So I decided to put the dependent variables separately in different variables and to give species values as the proportion within the plot (2-species plot: 0.5+0.5, 1-species plot: 1.0). My txt file looks like tree height - crown PA - tree biomass (all dependent variables) - 10 20 15 20 56 36 Diversity - Species A - Species B - Species C - Species D 2 0 0.5 0.5 0 30.33 0.33 0.330 Soil - Vegetation 2343 5678 So I changed the code for rda (dependent variable on the right of the tilde and the explanatory variable on the left of the tilde). In standad RDA the dependent variable would be on the left. I tried this, but then I was getting points for the dependent variables and not arrows. it is because RDA tried to do an RDA on the dfferent species (but there is no dependent variable, but just die identity). However, I get some error message changing the R-code: Error in model.frame.default(formula, data, na.action = na.fail, xlev = xlev) : invalid type (list) for variable 'height'. And a second problem is that I wanted to include the other environmental matrix (env). I tried to include the second matrix on the right of the tilde, but rda was producing an error. Many thanks for any hint or comments Sibylle ME<-read.table("ME_rda.txt", na.strings="*", header=TRUE) height<-ME[,3:6] mortality<-ME[,7:9] species<-ME[,11:16] env<-ME[,10:33] library(vegan) ME_rda<-rda(species~height, scale=TRUE) ME_rda plot(ME_rda, scaling=-1) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tikzDevice install problem
OS linux 2.6.38 R version 2.12.1 I tried the CRAN german mirrors http://mirrors.softliste.de/cran/ http://ftp5.gwdg.de/pub/misc/cran and others from the UK... -- View this message in context: http://r.789695.n4.nabble.com/tikzDevice-install-problem-tp3837315p3837457.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] metaMDS
Hello R-user community, I am applying the function metaMDS. However, I would like to know if there is any option to export the data I got from the axis as a data frame. I have tried as.data.frame.list but is not working. Any suggestion? Thank you in advance for your help, Lineth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Homography with R
On Sep 23, 2011, at 11:00 AM, PtitBleu wrote: Hello, I would like to know if it exists a package including something equivalent to this page: http://www.developpez.net/forums/d740403/autres-langages/algorithmes/contribuez/image-geometrie-projective-homography/ http://www.developpez.net/forums/d740403/autres-langages/algorithmes/contribuez/image-geometrie-projective-homography/ I've searched with these keywords: R-project homography warping, but with no success. You might want to look at the help page for 'persp'. It illustrates the use of the 'trans3d' function which I think does the transformations described in the paper that the first poster linked to. Mind you, I don't read French so I cannot be sure this will satisfy. I'm not very good at R and I don't know java. So any help is welcome. Have a nice week-end, Ptit Bleu. -- View this message in context: http://r.789695.n4.nabble.com/Homography-with-R-tp3837111p3837111.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
Jim Bouldin wrote on 09/23/2011 12:03:47 PM: > > This has got to be incredibly simple but I nevertheless can't figure it out > as I am apparently brain dead. > > I just want to convert the elements of a character vector to variable names, > so as to then assign formulas to them, e.g: > z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) and > lm(y~x[,2]), to the variables "model1" and "model2". > > There are of course, many more than 2 models involved, so brute force is the > option of absolute last resort. > Thanks for any help. > -- > Jim Bouldin, Research Ecologist It's not clear to me what you're trying to do. You say you want to assign formulae, such as lm(y~x[,1]) and lm(y~x[,2]), to the variables "model1" and "model2". Do you mean that you want the resulting formulae to be lm(y~model1) and lm(y~model2)? Could you give a more complete example of what you have and what you'd like to end up with? Jean [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
Yes, I tried to do it using assign. I couldn't get that to work. E.g: > z=1:2; zz=rep("model",2);zzz = paste(zz,z,sep='');zzz [1] "model1" "model2" > y = 1:10; v = rnorm(10,0,2); x2 = y + v; x3 = y + v^0.5 > x = data.frame(x2,x3) > for (i in 1:2){assign(zzz[i],lm(y~x[,i]))};zzz [1] "model1" "model2" stumped On Fri, Sep 23, 2011 at 1:08 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > The usual response to this sort of question is usually something like the > following: > > assign() will do what you want; get() runs the other direction. But the > more R way to do it is to put all the models in a list. > > Michael > > On Fri, Sep 23, 2011 at 1:03 PM, Jim Bouldin wrote: > >> This has got to be incredibly simple but I nevertheless can't figure it >> out >> as I am apparently brain dead. >> >> I just want to convert the elements of a character vector to variable >> names, >> so as to then assign formulas to them, e.g: >> z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) >> and >> lm(y~x[,2]), to the variables "model1" and "model2". >> >> There are of course, many more than 2 models involved, so brute force is >> the >> option of absolute last resort. >> Thanks for any help. >> -- >> Jim Bouldin, Research Ecologist >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > -- Jim Bouldin, PhD Research Ecologist [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] metaMDS
Lineth Contreras wrote on 09/23/2011 11:35:10 AM: > > Hello R-user community, > > I am applying the function metaMDS. However, I would like to know if there > is any option to export the data I got from the axis as a data frame. > > I have tried as.data.frame.list but is not working. Any suggestion? > > Thank you in advance for your help, > > Lineth When you say "the data I got from the axis" do you mean the coordinates contained in the $points of the resulting object? If so, something like this should work (using the example provide in ?metaMDS): data(dune) library(MASS) sol <- metaMDS(dune) df <- as.data.frame(sol$points) Jean [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
What exactly is the problem? Like I said, I'd personally put this in a list, but this seems like exactly what you wanted... > model1 Call: lm(formula = y ~ x[, i]) Coefficients: (Intercept) x[, i] 1.0489 0.7175 > model2 Call: lm(formula = y ~ x[, i]) Coefficients: (Intercept) x[, i] -0.4342 0.8734 On Fri, Sep 23, 2011 at 1:41 PM, Jim Bouldin wrote: > Yes, I tried to do it using assign. I couldn't get that to work. E.g: > > > z=1:2; zz=rep("model",2);zzz = paste(zz,z,sep='');zzz > [1] "model1" "model2" > > y = 1:10; v = rnorm(10,0,2); x2 = y + v; x3 = y + v^0.5 > > x = data.frame(x2,x3) > > for (i in 1:2){assign(zzz[i],lm(y~x[,i]))};zzz > [1] "model1" "model2" > > stumped > > > > On Fri, Sep 23, 2011 at 1:08 PM, R. Michael Weylandt < > michael.weyla...@gmail.com> wrote: > >> The usual response to this sort of question is usually something like the >> following: >> >> assign() will do what you want; get() runs the other direction. But the >> more R way to do it is to put all the models in a list. >> >> Michael >> >> On Fri, Sep 23, 2011 at 1:03 PM, Jim Bouldin wrote: >> >>> This has got to be incredibly simple but I nevertheless can't figure it >>> out >>> as I am apparently brain dead. >>> >>> I just want to convert the elements of a character vector to variable >>> names, >>> so as to then assign formulas to them, e.g: >>> z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) >>> and >>> lm(y~x[,2]), to the variables "model1" and "model2". >>> >>> There are of course, many more than 2 models involved, so brute force is >>> the >>> option of absolute last resort. >>> Thanks for any help. >>> -- >>> Jim Bouldin, Research Ecologist >>> >>>[[alternative HTML version deleted]] >>> >>> __ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> > > > -- > Jim Bouldin, PhD > Research Ecologist > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
OK, I see. I thought R was just returning the character strings of the model names without doing any assigning, since that's what it displayed. I had it right all along. Thanks for your help. On Fri, Sep 23, 2011 at 1:45 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > What exactly is the problem? Like I said, I'd personally put this in a > list, but this seems like exactly what you wanted... > > > model1 > > Call: > lm(formula = y ~ x[, i]) > > Coefficients: > (Intercept) x[, i] > 1.0489 0.7175 > > > model2 > > Call: > lm(formula = y ~ x[, i]) > > Coefficients: > (Intercept) x[, i] > -0.4342 0.8734 > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
assign() doesn't return anything in this case. It's your addtional (unnecessary?) call to "zzz" at the end which triggers a print statement. Michael On Fri, Sep 23, 2011 at 1:56 PM, Jim Bouldin wrote: > OK, I see. I thought R was just returning the character strings of the > model names without doing any assigning, since that's what it displayed. I > had it right all along. Thanks for your help. > > > On Fri, Sep 23, 2011 at 1:45 PM, R. Michael Weylandt < > michael.weyla...@gmail.com> wrote: > >> What exactly is the problem? Like I said, I'd personally put this in a >> list, but this seems like exactly what you wanted... >> >> > model1 >> >> Call: >> lm(formula = y ~ x[, i]) >> >> Coefficients: >> (Intercept) x[, i] >> 1.0489 0.7175 >> >> > model2 >> >> Call: >> lm(formula = y ~ x[, i]) >> >> Coefficients: >> (Intercept) x[, i] >> -0.4342 0.8734 >> > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with function "Truncate" in package "distr"
Am 21.09.2011 17:05, schrieb Uwe Ligges: > > > On 21.09.2011 11:53, Duarte Viana wrote: >> Hello all, >> >> Can someone tell me why the following mixture of two log-normal >> distributions does not get truncated? What puzzles me is that the >> function works almost always, but for certain combinations (like the >> one below), it does not. >> >> # R code example >> library(distr) >> mix<-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) >> >> mix.trunc<-Truncate(mix,lower=0.001,upper=3000) >> distr.sample<-r(mix.trunc)(100) >> range(distr.sample) >> >> Why do I get values over 3000 (which was the defoned upper limit)? >> >> Some help would be greatly appreciated. > > > Some question for the author of package distr, I believe. > > Uwe Ligges > seconded, Uwe, and settled off-line [BTW was an issue of the globally set accuracy]. Best, Peter (one of the authors of distr) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
OK. I was assuming that the call to zzz would print the model formulae, not the object names. That's what threw me. Jim On Fri, Sep 23, 2011 at 1:59 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: assign() doesn't return anything in this case. It's your addtional (unnecessary?) call to "zzz" at the end which triggers a print statement. Michael On Fri, Sep 23, 2011 at 1:59 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > assign() doesn't return anything in this case. It's your addtional > (unnecessary?) call to "zzz" at the end which triggers a print statement. > > Michael > > > On Fri, Sep 23, 2011 at 1:56 PM, Jim Bouldin wrote: > >> OK, I see. I thought R was just returning the character strings of the >> model names without doing any assigning, since that's what it displayed. I >> had it right all along. Thanks for your help. >> >> >> On Fri, Sep 23, 2011 at 1:45 PM, R. Michael Weylandt < >> michael.weyla...@gmail.com> wrote: >> >>> What exactly is the problem? Like I said, I'd personally put this in a >>> list, but this seems like exactly what you wanted... >>> >>> > model1 >>> >>> Call: >>> lm(formula = y ~ x[, i]) >>> >>> Coefficients: >>> (Intercept) x[, i] >>> 1.0489 0.7175 >>> >>> > model2 >>> >>> Call: >>> lm(formula = y ~ x[, i]) >>> >>> Coefficients: >>> (Intercept) x[, i] >>> -0.4342 0.8734 >>> >> >> > -- Jim Bouldin, PhD Research Ecologist [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting object elements to variable names and making subsequent assignments thereto
Two things: I think you are not aware of the R difference between a formula and a lm object. A formula is part of the input to the lm function while the output is a complicated object of lm class. If you want the formulas back from the model object, you can access them by way of model1$call with a little bit of string processing. The other: nothing ever changes values of zzz (exactly the point of assign) so it shouldn't surprise you it didn't change. What you may be looking for is get(zzz) Michael On Fri, Sep 23, 2011 at 2:05 PM, Jim Bouldin wrote: > OK. I was assuming that the call to zzz would print the model formulae, > not the object names. That's what threw me. > Jim > > > On Fri, Sep 23, 2011 at 1:59 PM, R. Michael Weylandt < > michael.weyla...@gmail.com> wrote: > assign() doesn't return anything in this case. It's your addtional > (unnecessary?) call to "zzz" at the end which triggers a print statement. > > Michael > > On Fri, Sep 23, 2011 at 1:59 PM, R. Michael Weylandt < > michael.weyla...@gmail.com> wrote: > >> assign() doesn't return anything in this case. It's your addtional >> (unnecessary?) call to "zzz" at the end which triggers a print statement. >> >> Michael >> >> >> On Fri, Sep 23, 2011 at 1:56 PM, Jim Bouldin wrote: >> >>> OK, I see. I thought R was just returning the character strings of the >>> model names without doing any assigning, since that's what it displayed. I >>> had it right all along. Thanks for your help. >>> >>> >>> On Fri, Sep 23, 2011 at 1:45 PM, R. Michael Weylandt < >>> michael.weyla...@gmail.com> wrote: >>> What exactly is the problem? Like I said, I'd personally put this in a list, but this seems like exactly what you wanted... > model1 Call: lm(formula = y ~ x[, i]) Coefficients: (Intercept) x[, i] 1.0489 0.7175 > model2 Call: lm(formula = y ~ x[, i]) Coefficients: (Intercept) x[, i] -0.4342 0.8734 >>> >>> >> > > > -- > Jim Bouldin, PhD > Research Ecologist > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Newbie question: Converting Table
On Sep 23, 2011, at 8:43 AM, Metronome123 wrote: Thanks, I will read the posting guide. Please do it NOW. Before any further postings. Q1: thanks for helping me out! Q2: What I mean is that given the dataset: subject1,class1_yes, class2_no, class3_yes, class4_no subject2, class1_no, class2_no, class3_no, class4_yes subject3, class1_yes, class2_no, class3_yes, class4_no I want to count for each unique class combination the number of subjects that share this whole combination. In this case the result should be: 2 counts for the combination class1_yes, class2_no, class3_yes, class4_no 1 count for the combination class1_no, class2_no, class3_yes, class4_yes Perhaps: with( datfrm, table( interaction( ) ) ) Had you read the Posting Guide you would have found that you are requested to post a working example and you are also given instruction how a proper working example can be created from your own data. The Posting Guide uses 'dump' but I usually use 'dput'. Then we would not have needed to post guesswork and pseudo-code. -- david. Regards, Lars Op 23 sep. 2011 (w38), om 14:12 heeft Petr Pikal [via R] het volgende geschreven: [R] Newbie question: Converting Table Hi, I'm new to R, and I have searched helpfiles and this forum on my 2 questions. Hope you guys can help me out! :-) You did not search enough. You probably want table or xtabs Q1 untested res <- xtabs(~subject+class, data=your.file) ifelse(res==1, "yes", "no") Q2 I do not understand what exactly do you want. Please be more specific. BTW, if you are in it you'd rather give a look to posting guide. Regards Petr Many thanks in advance! Cheers, Lars Q1: I imported a csv file with columnames subject and class. There are about 1000 different classes... It looks like this: subject1, class1 subject1, class2 subject2, class1 subject2, class3 ... subject999, class1 subject999, class2 Now I want to transform this in R into a table (with columnnames subject,class1,class2,...) like: subject1, yes, yes, no, ... subject2, yes, no, yes, ... ... Q2: I want to count the matching class patterns in the previous table (output: in a table with columns count, class1, ...). In this example for only the subjects1,2 and 999 it looks like this: 2,yes,yes,no,.. 1,yes,no,yes ... -- View this message in context: http://r.789695.n4.nabble.com/Newbie- question-Converting-Table-tp3836468p3836468.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836611.html To unsubscribe from Newbie question: Converting Table, click here. -- View this message in context: http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836711.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] randomForest - NaN in %IncMSE
You are not giving anyone much to go on. Please read the posting guide and see how to ask your question in a way that's easier for others to answer. At the _very_ least, show what commands you used, what your data looks like, etc. Andy > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Katharine Miller > Sent: Tuesday, September 20, 2011 1:43 PM > To: r-help@r-project.org > Subject: [R] randomForest - NaN in %IncMSE > > Hi > > I am having a problem using varImpPlot in randomForest. I > get the error > message "Error in plot.window(xlim = xlim, ylim = ylim, log = > "") : need > finite 'xlim' values" > > When print $importance, several variables have NaN under > %IncMSE. There > are no NaNs in the original data. Can someone help me figure > out what is > happening here? > > Thanks! > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Small Area Estimate Using Structural Equation Models
I am looking for study materisl on how to conduct 'small area estimation' using structural equations models in R for both longtudinal and repeated cross-section data. Tried google did not work. There are other regression technique my interest is on structural equation models. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Kolmogorov-Smirnov test
Are you doing the 2 sample KS test? Comparing if 2 samples come from the same distribution? With 3,000 points you will still likely have power to find meaningless differences, what exactly are you trying to accomplish by doing the comparison? I am really only familiar with the KS test done in R (which did not make your list, yet you are asking on an R mailing list). Differences could be due to errors, different assumptions, different algorithms, sunspots, or any number of other things. Are the differences meaningful? R lets you see exactly what it is doing so you can check errors/assumptions/algorithms, I don't know about the ones you show. You will need to ask someone who knows the programs you reference to determine what input they are expecting. R expects the raw data. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rommel Sent: Friday, September 23, 2011 7:51 AM To: r-help@r-project.org Subject: Re: [R] Kolmogorov-Smirnov test Dear Dr. Snow, I would like to ask for help on my three questions regarding Kolmogorov Smirnov test. 1. 'With a sample size over 10,000 you will have power to detect differences that are not practically meaningful. ' -Is sample size of 3000 for each sample okay for using Kolmogorov Smirnov test? 2. I am checking whether my KS procedure is correct. I have compared results of KS tests using the following 3 softwares: 1. Statistica 2. http://www.wessa.net/rwasp_Reddy-Moores%20K-S%20Test.wasp 3. http://www.physics.csbsju.edu/stats/KS-test.html I have observed that the three softwares produced the same results only if the samples sizes are equal. However, when samples are not equal, I did not get similar results particularly from the wessa.net calculator. Is it allowed to do a KS test to compare samples with unequal sizes? 3. Is it allowed to use the raw data values in doing KS test? Or should I use the frequencies obtained from frequency distribution table of the raw data from each sample? I think that when I use the frequency, the KS test will construct new cumulative fractions from the frequencies, which I think is not right. Hope you can assist me. Thanks! -rommel -- View this message in context: http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-tp3479506p3836910.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding weights to optim
I'm not at all sure that I understand your question, but since (as far as I am aware) no-one else has answered, I'll give it a go. The puzzle, to me, is what you mean by ``I would like to add weights to optim.'' What do you mean ``add weights''? If you want to minimize a weighted sum of squares, it seems to me to be trivial: logis.op <- function(p,x,y,w=1) { ypred <- 1.0 / (1.0 + exp((p[1] - x) / p[2])); sum(w*(y-ypred)^2) } (Note that your ``res <- ...'' and ``return(res)'' are unnecessary.) optim(c(0.0,1.0),logis.op,x=d1_all$SOA,y=as.numeric(md1[,i]), w=mind>) HTH cheers, Rolf Turner On 23/09/11 13:47, Ahnate Lim wrote: I realize this may be more of a math question. I have the following optim: optim(c(0.0,1.0),logis.op,x=d1_all$SOA,y=as.numeric(md1[,i])) which uses the following function: logis.op<- function(p,x,y) { ypred<- 1.0 / (1.0 + exp((p[1] - x) / p[2])); res<- sum((y-ypred)^2) return(res) } I would like to add weights to the optim. Do I have to alter the logis.op function by adding an additional weights parameter? And if so, how would I change the ypred formula? Would I just substitute x with x*w __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding weights to optim
Thanks for your help, what I meant was that each observation x had a corresponding count to them, and I wanted to use these counts as weights in the optim (so that the optim process would give more weight to the measurements that had more counts). I had forgotten if the weights should accounted for in the ypred formula, or in the sum of squares as you mentioned. On Fri, Sep 23, 2011 at 3:10 PM, Rolf Turner wrote: > > > I'm not at all sure that I understand your question, but since (as far > as I am aware) no-one else has answered, I'll give it a go. > > The puzzle, to me, is what you mean by ``I would like to add weights > to optim.'' What do you mean ``add weights''? > > If you want to minimize a weighted sum of squares, it seems to me to > be trivial: > > logis.op <- function(p,x,y,w=1) { > >ypred <- 1.0 / (1.0 + exp((p[1] - x) / p[2])); >sum(w*(y-ypred)^2) > } > > (Note that your ``res <- ...'' and ``return(res)'' are unnecessary.) > > optim(c(0.0,1.0),logis.op,x=**d1_all$SOA,y=as.numeric(md1[,**i]), >w= mind>) > > HTH > >cheers, > >Rolf Turner > > > > On 23/09/11 13:47, Ahnate Lim wrote: > >> I realize this may be more of a math question. I have the following optim: >> >> optim(c(0.0,1.0),logis.op,x=**d1_all$SOA,y=as.numeric(md1[,**i])) >> >> which uses the following function: >> >> logis.op<- function(p,x,y) { >> >> ypred<- 1.0 / (1.0 + exp((p[1] - x) / p[2])); >> >> res<- sum((y-ypred)^2) >> >> return(res) >> >> } >> >> I would like to add weights to the optim. Do I have to alter the logis.op >> function by adding an additional weights parameter? And if so, how would I >> change the ypred formula? Would I just substitute x with x*w >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ncdf - install error
Dear all, I'm having issues with the installation of the ncdf package. It returns a non-zero exit status. Can anyone suggest what I should do next? FYI, I do not have problems installing other packages. Thanks. Muhammad * installing *source* package ‘ncdf’ ... checking for nc-config... /usr/local/bin/nc-config configure: creating ./config.status config.status: creating src/Makevars ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf.c -o ncdf.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf2.c -o ncdf2.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf3.c -o ncdf3.o gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf.o ncdf2.o ncdf3.o -L/usr/local/lib -lnetcdf -L/usr/lib64/R/lib -lR /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 ERROR: compilation failed for package ‘ncdf’ * removing ‘/home/rahiz/R/x86_64-redhat-linux-gnu-library/2.13/ncdf’ The downloaded packages are in ‘/tmp/Rtmp5khIxy/downloaded_packages’ Warning message: In install.packages("ncdf") : installation of package 'ncdf' had non-zero exit status__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ncdf - install error
Perhaps start by reading the posting guidelines. --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Muhammad Rahiz wrote: Dear all, I'm having issues with the installation of the ncdf package. It returns a non-zero exit status. Can anyone suggest what I should do next? FYI, I do not have problems installing other packages. Thanks. Muhammad * installing *source* package âncdfâ ... checking for nc-config... /usr/local/bin/nc-config configure: creating ./config.status config.status: creating src/Makevars ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf.c -o ncdf.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf2.c -o ncdf2.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ncdf3.c -o ncdf3.o gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf.o ncdf2.o ncdf3.o -L/usr/local/lib -lnetcdf -L/usr/lib64/R/lib -lR /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 ERROR: compilation failed for package âncdfâ * removing â/home/rahiz/R/x86_64-redhat-linux-gnu-library/2.13/ncdfâ The downloaded packages are in â/tmp/Rtmp5khIxy/downloaded_packagesâ Warning message: In install.packages("ncdf") : installation of package 'ncdf' had non-zero exit status_ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] spatstat => owin + image
On 24/09/11 02:32, tkdweber wrote: Dear Community I am at my wits end and seek advice. My wish is to plot coordinates (x,y in WGS84_UMTS for the ones interested) of sampling points. This I can do by the standard spatstat prodcedure via owin. You appear to be rather confused from the very start. The function owin() does not *plot* anything; it is used to create an *observation window* for a spatial point pattern. In spatstat every spatial point pattern object must include such a window. I then try to add an image, which is a map/satellite photo in the background. You would probably do better by plotting the image first and then adding the points on top of the image. In general, in my experience, plotting an image on top of points obscures the points (hides them completely). To avoid this you have to mess around with the value of ``alpha'' somehow, and the game is not worth the candle. Firstly Problem: With the current code, I can not get the edges of the image to match the boarders of the plot itself (not the entire plot window, solely the coordinate system) The size of the image I have (from GPS work) I have absolutely no idea what you are asking here. Any ideas? Secondly, I am confused of how to get coordinates into an owin plot. It doesnt want to work. Likewise. This is far too vague for me (or anyone else) to be able to give a reasonable answer. Thirdly, is with spatstat only always one mark possible? Or can I differentiate further? I am again not sure what you are asking here, but I think the answer is ``No.'' That is, more than one mark is ``possible''. The marks component of a spatial point pattern (an object of class "ppp") can be a *data frame*. See ?ppp. Currently the tools available in spatstat don't do much with data frame marks, but such mark structures are allowed, and you can write your own code to deal with such structures in any manner you wish. Code, for reference purposes CODE ~~ data data = read.xls("name.xls") x1=floor(min( data[,2],na.rm=T )*(1-b)) x2=ceiling(max(data[,2],na.rm=T )*(1+b)) y1=floor(min(data[,3],na.rm=T )*(1-c)) y2=ceiling(max(data[,3],na.rm=T )*(1+c)) x1 x2 y1 y2 What (WTF) are b and c??? w = owin(c(x1,x2),c(y1,y2)) w dat1 = as.ppp(data[,2:4],w) is.ppp(dat1) str(dat1) #Get the plot information so the image will fill the plot box, and draw it ima = readPNG("file.png") lim = par() rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4]) par(new=T) plot(dat1, use.marks=T) ~~~ This code is not really much use to anyone since we don't have access to "name.xls" or "file.png". (Or, as indicated above, to the values of "b" and "c".) Read the posting guide. Examples given should be that ``people can actually run.'' Thank you for any advice. I don't have any experience with readPNG() (*from the png package*, which you might have mentioned!) nor with rasterImage(). However, after some thrashing around and experimenting with a toy example I have come to the conclusion that the problem arises from the fact that readPNG() creates a large border of white space around the image. To fix this, I cobbled together the function: raster2im <- function (A,xrange,yrange) { B <- apply(A,c(1,2),function(x){rgb(x[1],x[2],x[3])}) B <- B[nrow(B):1,] suppressWarnings({ i1 <- min(apply(B,2,function(x){min(which(x!="#FF"))})) i2 <- max(apply(B,2,function(x){max(which(x!="#FF"))})) j1 <- min(apply(B,1,function(x){min(which(x!="#FF"))})) j2 <- max(apply(B,1,function(x){max(which(x!="#FF"))})) }) C <- B[i1:i2,j1:j2] im(C,xrange=xrange,yrange=yrange) } I suggest that you try something like the following: require(spatstat) require(png) require(gdata) data <- read.xls("name.xls") X <- as.ppp(data[,2:3],window=ripras(data[,2:3],shape="rectangle")) R <- readPNG("file.png") IM <- raster2im(R,xrange=X$window$xrange,yrange=X$window$yrange) plot(IM,valuesAreColours=TRUE) plot(X,add=TRUE) Note that raster2im() strips away any white edges from an image. If you actually *want* this ``white space'' (or part of it) you'll have to do something else. cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.