similar to: Opinion: Why I find factors convenient to use

Displaying 20 results from an estimated 40000 matches similar to: "Opinion: Why I find factors convenient to use"

2012 Jul 24
1
Convenience function to get unevaluated ... function arguments
Folks: Herein is a suggestion for a little R convenience function mainly to obtain unevaluated ... function arguments. It arose from a query on R-help on how to get these arguments. The standard (I think) idiom to do this is via match.call(expand.dots=FALSE)$... However, Bill Dunlap pointed out that this repeats the argument matching of the function call and suggested a couple of alternatives
2013 Apr 01
1
Factor to numeric conversion - as.numeric(levels(f))[f] - Language definition seems to say to not use this.
Note the edited subject line! I don't know why I typed it as it was before. This says that as.numeric(as.character(f)) will work regardless of the implementation, and I agree. It's the recommendation to use as.numeric(levels(f))[f] that has me wondering about section 2.3.1 of the language definition. I expect that this idiom is in widespread use, and perhaps the language definition
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping. #some data L3 <- LETTERS[1:3] dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE))) #When x==1 and y==1 I want to replace the 1 values with NA #I can select the rows I want: dat2<-subset(dat1,x==1 & y==1) #replace the 1 with NA dat2$x<-rep(NA,nrow(dat2) dat2$y<-rep(NA,nrow(dat2) #select the other rows and rbind
2012 May 01
3
Data frame vs matrix quirk: Hinky error message?
AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? > mtest <- matrix(1:12,nr=4) > dftest <- data.frame(mtest) > ix <- cbind(1:2,2:3) > mtest[ix] <- NA > mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... > dftest[ix] <- NA Error in `[<-.data.frame`(`*tmp*`, ix, value
2011 Dec 12
1
Please delete my e-mail judit.barroso@montana.edu
Please, I am receiving lot of e-mails that I do not want. Please could you delete my e-mail. Thank, Judit -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Thomas Adams Sent: Monday, December 12, 2011 3:22 PM To: Bert Gunter Cc: r-help at r-project.org Subject: Re: [R] Boxplot of multiple vectors with different lengths Bert,
2012 May 04
2
Off-Topic: Crime Statistics Don't Pay
WARNING: COMPLETELY OFF TOPIC -- Nothing to do with R. I thought readers of this list might enjoy the following. The link to the full article is at the bottom. I hope this is not "too" inappropriate. ------- Overconfidence in crime statistics doesn?t pay. In a new study, a team of criminologists makes the case that reported crime rates should acknowledge uncertainty in the data. The
2011 Dec 16
1
Fortune? -- was Re: optim with simulated annealing SANN ...
Folks: I thought John Nash's comment below was profound and a possible Fortunes candidate: (Aside: I believe it applies to a great deal of what is discussed on this list, not just stochastic optimization.) Cheers, Bert ... (in the context of stochastic optimization) >... As with many tools in this domain, for effective use they > require more knowledge than many of their users
2012 Sep 20
1
Fortune nomination
On Thu, Sep 20, 2012 at 9:01 AM, David Winsemius <dwinsemius at comcast.net> wrote: (In response to an OP's aplogy for an "awkwardly worded question"): > Awkwardly worded questions will get much better answers if they are accompanied by some test data. Fortune nomination! Cheers, Bert > -- > David Winsemius, MD > Alameda, CA, USA > >
2013 May 25
3
When creating a data frame with data.frame() transforms "integers" into "factors"
Hello I am novice to R and i was learning how to do a scatter plot with R using an example from a website. My setup is iMac with Mac OS X 10.8.3, with R 3.0.1, default install, without additional packages loaded I created a .csv file in vim with the following content userID,user,posts 1,user1,581 2,user2,281 3,user3,196 4,user4,150 5,user5,282 6,user6,184 7,user7,90 8,user8,74 9,user9,45
2012 Oct 11
3
Sorting a data frame by specifying a vector
Hello all, I cannot seem to figure out this seemingly simple procedure. I want to sort a data frame by a specified character vector. So for : df.. <- data.frame(Season=rep(c("Summer","Fall","Winter","Spring"),4),Obs= runif(length(rep(c("Summer","Fall","Winter","Spring"),4)))) I want to sort the data frame
2013 Feb 20
3
NLS results different from Excel -- Tricky fortunes nomination
Folks: I thought the following excerpt from Bruce McCullough's post would be a good candidate for the R fortunes package -- except that it's about Excel, not R! So I nominate it... but leave it to others to say whether it's really "qualified" to be nominated. ---- "The idea that the Excel solver "has a good reputation for being fast and accurate" does not
2012 Sep 06
2
How can I improve an ugly, dumb hack
Hi Folks: Here's the situation: > m <- cbind(x=letters[1:3], y = letters[4:6]) > m x y [1,] "a" "d" [2,] "b" "e" [3,] "c" "f" ## m is a 2 column character matrix > d <- data.frame(a=1:3,b=4:6) > d$c <- m > d a b c.x c.y 1 1 4 a d 2 2 5 b e 3 3 6 c f ## But please note (as was remarked
2012 Apr 18
3
how to plot separate lm ablines on the same xyplot by group
Hi, I am trying to use xyplot to plot the relationship between size and day (y~x) by a food factor that has two levels, low and high. I have 3 reps per factor/day. I want the plots from each food treatment on the same axiss, so I used this code: xyplot(Size ~ Day, groups = Food, data = louis.data.means,col=1, pch=c(1,17), panel=function(x,y,groups,...){ panel.superpose(x,y,groups,...)
2012 Jul 19
1
expert opinion on lmer
Hello, I have the following design, counts were collected at different transects, different depths and different sites at different times. Time is continuous and assumed to be random, all the others are categorical fixed where transect is nested within depth which is nested within site. I would like an expert opinion about the following code where intercept is modeled as random (I am not sure
2011 Oct 24
1
How to create a new variable based on parts of another character variable: A generalization
... Well, this works in this simple case, but is too clumsy for a general formulation of this problem: given a "dictionary" consisting of two character vectors of unique "names" (or two columns in a data frame), x and y, how does one convert a factor z with levels in x into the corresponding equivalent with levels in y? There are likely a zillion ways to do this with various
2013 Jun 18
2
find closest value in a vector based on another vector values
Dear All, would you please provide your thoughts on the following: let us say I have: a <-c(1,5,8,15,32,69) b <-c(8.5,33) and I would like to extract from "a" the two values that are closest to the values in "b", where the length of this vectors may change but b will allways be shorter than "a". So at the end based on this example I should have the result
2013 Apr 20
1
Assigning factor to character vector
Hi! Yesterday I accidentally discovered this: > a <- LETTERS[1:5] > a [1] "A" "B" "C" "D" "E" > > a[1] <- factor(a[1]) > a [1] "1" "B" "C" "D" "E" BUT: > b <- factor(LETTERS[1:5]) > b [1] A B C D E Levels: A B C D E > b[1] <- factor(b[1]) > b [1] A B C D E
2013 Apr 08
3
Reshaping a table
Hello all, I have data in the form of a table: X Y1 Y2 0.1 3 2 0.2 2 1 And I would like to transform in the form: X Y 0.1 Y1 0.1 Y1 0.1 Y1 0.1 Y2 0.1 Y2 0.2 Y1 0.2 Y1 0.2 Y2 Any ideas how? Thanks in advance, IOanna [[alternative HTML version deleted]]
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2013 Mar 11
3
Test of Parallel Regression Assumption in R
Hi, I am running an analysis with an ordinal outcome and I need to run a test of the parallel regression assumption to determine if ordinal logistic regression is appropriate. I cannot find a function to conduct such a test. >From searching various message boards I have seen a few useRs ask this same question without a definitive answer - and I came across a thread that indicated there is no