similar to: how to recode an ordered factor

Displaying 20 results from an estimated 10000 matches similar to: "how to recode an ordered factor"

2012 Dec 10
3
equivalent of group command of the egen function in Stata
Dear R listers, I am trying to create a new variable that uniquely identifies groups of observations in a dataset. So far I couldn't figure out how to do this in R. In Stata I would simply type: egen newvar = group(dim1, dim2, dim3) Please, find below a quick example to show what I am dealing with: I have a dataset with 4 variables: var <- runif(50) ## a variable that I want to group
2012 Oct 24
2
Recode function car package erases previous values
Hi all, I am attempting to create a new variable based on values of other variables. The variable is called pharm. It basically takes the numeric code of 1 as yes and 0 to be No from the variable B20_C1 (a question on a survey). However, I would also like to have a level for non-respondents and these are captured in the variable nr.B20C, which is a 1 when there is a non-response on the whole group
2012 Dec 23
1
Esttab error while exporting regression results
Dear listers, I am trying to export a regression output to a latex document using the R package eststo. I have two variables: an ordered factor: group <- gl(3,5,20, labels=c("Ctl","Trt","prp")) and a continuous variable: weight <- runif(20) I want to regress weight over group, therefore I run: reg1 <- lm(weight ~ group) I wish to include the output of my
2013 Jan 10
1
help with knit_hooks
Dear R-listers, does anybody can suggest some manual where I can learn more about how the hooks in knitr work? I am trying to enclose the output of an R command in the Latex verbatim environment. I defined a hook as follows: knit_hooks$set(fsverb = function(x, options) { paste("\\begin(verbatim)\n", x, "\\end(verbatim)\n", sep = "") } then I set a chunk as
2013 Jan 08
2
how to label two figures in the same chunk independently with knitr
Dear R helpers, I am using knitr to run analysis with R and edit my document with Latex. I am wondering whether there is a way to include 2 or more pictures per chunk and being able to refer them in the text independently and eventually whether it is possible to give them different captions. Let me give you an example.Rnw: \documentclass{article} \title{Example} \author{FS} \begin{document}
2012 Aug 13
4
if else elseif for data frames
Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='L' else #chuch a warning? Note that col2 was not an existing column and was newly assigned for this
2012 Dec 22
1
how to control the naming of factors in regression
Dear R listers, I am regressing an ordered variable over an ordered independent variable using polr. The output lists every level of the ordered independent variable repeating its name and adding a suffix. In my case my variable is called "o.particip" and in my regression table I get the following: o.particip.L o.particip.Q o.particip.C o.particip^4 o.particip^5 o.particip^6 Is
2011 Oct 12
3
labels in a boxplot
Dear R-listers, I have a little problem with a boxplot and I hope you can help me figuring it out. I'll try to make up some data to illustrate the issue. Sorry, if my procedures look naive, but these are my first steps in R. Any comments and/or suggestions are very welcome. let's create a vector var1: var1 <- rnorm(100) and 5 five logical vectors. In this case the vectors don't
2012 Apr 12
4
Recode Variable
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120412/74331e9a/attachment.pl>
2012 Jul 01
2
list to dataframe conversion-testing for identical
HI R help, I was trying to get identical data frame from a list using two methods. #Suppose my list is: listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2)) #Creating dataframe using cbind dat1<-data.frame(do.call("cbind",listdat1)) colnames(dat1)<-c("Var1","Var2","Var3") #Second dataframe conversion
2012 Dec 20
2
how to make a table of summary statistics
Dear R-listers, I am a newbie with R and I am struggling with something I consider very basic. I wish to produce a table (to import in a latex file) of summary statistics, but for as much as I've been looking around and trying various alternatives (plyr, reporttools, pastecs and Hmisc) I haven't found what I am looking for. Probably I am doing something wrong, but I can't figure out
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all, Without a loop, I would like transform 3 numeric vectors empty of 0/1 of same length Vec1 : transform 1 to A and 0 to "" Vec2 : transform 1 to B and 0 to "" Vec3 : transform 1 to C and 0 to "" to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC, BC, AC, AB,...) Any idea ? Thank you for your help -- Michel ARNAUD
2013 Jun 06
2
generating a bar chart with two axis for co-linear variable
Hello Dimitris, I was goggling for some help on Sensitivity vs 1-specificity and saw your link. I hope you can be of help to me in one of the issue that I am facing in generating combo chart(bar chart and plot). I am a novice and have some difficulty in getting this logic correct. I am give a dataset (I am attaching a sample dataset). I am using a barplot() and passing values for
2011 Jun 23
2
Merging multiple data sets
Hi, I am trying to merge data similar to the example data below > dat0 id var1 var2 var3 2 1 0 1 3 1 0 1 4 0 1 1 5 0 1 1 > dat1 id var4 var5 var6 2 1 0 1 3 1 0 1 6 0 1 1 7 0 1 1 > dat2 id
2013 Apr 24
1
matching observations and ranking
Hi, It is not that clear. If VAR1 is a match between columns AB001A, AB0002A, VAR2? between AB001A, AB362 and VAR3 between AB0002A and AB362: Also, I assume row8 match would be taken as 1. dat1<- read.table(text=" ? S.No AB001A AB0002A AB362 ?? 1?? -/-??????? C/C?? A/A??????????????????????? ??? 2?? C/C??????? C/C?? A/A??????????????????????? ??? 3?? C/C??????? C/C??
2013 Feb 17
6
histogram
HI Elisa, You could use ?cut() vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i) paste(i[1],"<x<=",i[2],sep="")))
2012 Oct 17
2
cut2 error
To R users, I am trying to use cut2 function from the 'Hmisc' library. However, when I try and run the function on the following variable, I get an error message (displayed below). I suspect it is because of the NA but I have no idea how to address the error. Many thanks to any insights. structure(list(var1 = c(97, 97, 98, 98, 97, 99, 97, 98, 99, 98, 99, 98, 98, 97, 97, 98, 99, 98,
2013 May 03
3
color by group in ggplot
Hey, I have a dataset like this: ID Var1 Var2 Group A1 1 1 BB A2 1 2 AA B1 2 1 CC B2 1 3 DD C1 1 2 EE I would like to plot the points of Var1 and Var2, use "ID" as X-axis, but color the points by "Group". I can
2005 Apr 15
2
Help with "MERGE" gratefully accepted
Hello How do I use function 'MERGE" to combine the FILE A and FILE B below to make FILE C? Thank you FILE A 140 151 167 30.1 11.4 40 FILE B 140 167 5.7 30.3 FILE C 140 151 167 30.1 11.4 40 5.7 NA 30.3
2007 Mar 23
2
concatenate 2 data.frames
Dear all, I would like to know how can I concatenate 2 data.frames into a single one. Both data frames have the same number of columns and the same class type in each correspondent column. So what I want is to have a new data.frame where I have first the values from one data.frame and then the values from a second data.frame would came after in this new data.frame. Thanks in advance. Med