similar to: Recoding variable levels in R

Displaying 20 results from an estimated 5000 matches similar to: "Recoding variable levels in R"

2002 Jan 08
3
Finding functions in uninstalled libraries
(Many thanks to David Barron & Jonathan Baron for pointing me to 'recode' in the 'car' package). I think I've been told this before, but how do I search for a function/keyword in libraries I don't yet have installed? (ie. on the CRAN site I tried the search engines with "recode" etc., but didn't pick up the car package this way) Stuart Dr Stuart Leask
2012 Jun 22
3
removing NA from a data frame
Removing rows with NAs, using na.omit(), doesn't seem to be working for me. Dataset: > str ( ex10s ) 'data.frame': 2189576 obs. of 5 variables: $ LOPNR : int 58 58 58 58 64 64 64 64 64 64 ... $ DIAGNOS: Factor w/ 173 levels "F20","F200","F2000",..: 128 128 128 128 105 105 105 160 105 105 ... $ X_DATE : int 20060821 20061207 20080102 20090904
2011 Sep 01
2
Automatic Recoding
I have a text file full of numbers (it's a edgelist for a graph) and I would like to recode the numbers as they are way too big to work with. So for instance the following: 676529098667 1000198767829 676529098667 100867672856227 676529098667 91098726278 676529098667 98928373 1092837363526 716172829 would become: 0 1 0 2 0 3 0 4 5 6 i.e. all 676529098667 would become
2001 Dec 03
0
Summary on R script editor
Thanks for the advice, folks! Shravan Vasishth <vasishth at ling.ohio-state.edu> Try pico. There's no substitute for/comparison with emacs, though, IMHO. but just to be sure: you don't have to have ESS to use (x)emacs for editing R scripts. Sven Garbade <garbade at psy.uni-muenchen.de> ESS can be installed via rpm on Mandrake. baron at cattell.psych.upenn.edu (Jonathan
2002 Jan 18
0
RE: z-scores for different factor levels
Brian Ripley pointed out that there is already an R function scale() that does the work of my standardize(). -Greg -----Original Message----- From: Warnes, Gregory R Sent: Friday, January 18, 2002 9:38 AM To: 'Stuart Leask' Cc: 'r-help at stat.math.ethz.ch' Subject: RE: z-scores for different factor levels Hi Stuart, I often use this small function standardize <-
2002 Jan 18
1
RE: z-scores for different factor levels
Hi Stuart, I often use this small function standardize <- function(x) ( x - mean(x, na.rm=T) ) / sqrt(var(x, na.rm=T)) to standardize variables. You should be able to use this to do what you want by splitting the data frame into sections based on the factor level, using standardize() to create a new variable in each section, then paste the data frame back together. Something like: #
2001 Sep 18
4
help in a separate window under linux
Hi there. R v1.3.0, Slackware linux 7.1 or Windows 98SE, PII 266, 64Mb RAM. I notice that under windows, R puts help info (ie. the response to '?<function>') into a new window, whereas under linux, it puts it into the main console window. I find the former much more helpful when checking a function's syntax. Is there a simple way of configuring R under linux to put its help
2003 May 23
1
Fw: write.table only writes the first 256 variables/columns
Thanks. I was "believing" an Excel import of the file - as you say, a re-import into R still has 333 columns. I shall look elsewhere for the cause of the mysterious truncation. Stuart > ----- Original Message ----- > From: "Thomas Lumley" <tlumley at u.washington.edu> > To: "Stuart Leask" <stuart.leask at nottingham.ac.uk> > Cc:
2004 Jul 03
3
Recoding scores of negatively worded item
Hi, I'm new to R so please fogive if I write someting silly ... I need to recode a series of responses from a number of questionnaires. The data is read via ODBC from a database where all responses are coded as tables of the form (id, question, score). After dealing with recoding of missing values, I need to "invert" the scores of some questionnaire's item in the form x <-
2005 Aug 23
1
Seeking help with an apparently simple recoding problem
Hello, I have struggled, for longer than I care to admit, with this seemingly simple problem, but I cannot find a solution other than the use of long drawn out ifelse statements. I know there has to be a better way. Here is stripped down version of the situation: I start with: a <- c(1,0,1,0,0,0,0) b <- c(1,1,1,1,0,0,0) c <- c(1,1,0,1,0,0,0) rbind(a,b,c) [,1] [,2] [,3] [,4] [,5]
2002 Feb 21
1
Factor analysis of categorical or mixed categorical/continuous data in
Are there any suitable routines that perform factor analysis of categorical or mixed categorical/continuous data in R? Stuart Dr Stuart Leask MA MB BChir (Cantab) MRCPsych Clinical Lecturer in Psychiatry, University of Nottingham Dept Psychiatry Duncan Macmillan House, Porchester Road, Nottingham. NG3 6AA. UK tel. 00 44 115 969 1300 xtn 40784 fax 0115 955 5352
2001 Aug 23
2
Missing Values from Spss-Data
Hello, i'm a newbie of the really fantastic "R" , but have some problems to define Missing Values from Spss-Files which i import with the read.spss(data) command ! What should i do to recode i.e. the values 9,99 & 999 to NA. Something like this x <- c(9,99,999,NA) x==NA ...do not what i want, because the data.frame show the values 9,99 & 999 and not NA in this fields ?
2007 Jun 11
1
Recoding
I want to do some recoding of variables: code Age into groups and recode a factor into a smaller number of levels. There are a couple of options for recode functions, in the car package and in memisc, and I think in gmisc. Does anyone have any opinions on the the easiest, most reliable approach for these problems? David Scott _________________________________________________________________
2011 Feb 19
1
Conditional recoding
I am trying to recode a variable into another variable and while the package 'car' works well when it is only recoding A into B, I am not sure I can do the same with recoding (A or C) into B. If i can use recode please advise on how to. So i am using an if/else if conditions. My sample dataset is below along with the code and the warning and results i get. TIA Krishnan #****Code****
2003 Mar 06
1
[stuart.leask@nottingham.ac.uk: R in your pocket on a Sharp Zaurus]
Ah, but the interesting thing is that they are coming out with a 'clam' version like the 5MX. Details are limited at the moment, but that could mean the combination of 5MX usability with a supported linux distro. I am drooling in anticipation. Sounds like a "I've finally finished my PhD and deserve a treat" situation to me :) Dave On Thu, Mar 06, 2003 at 09:17:20AM
2002 Jan 06
2
Passing names of variables to functions
Hi, I am still new to R and have a programming question. I have created a small function which takes a parameter. In the function I want to be able to refer to the names of the variables sent to the function (specifically I want to be able to use the name of the variable given to the function in an output table). For example, in the following (fictional) function I want some way of printing
2004 Oct 18
2
Recoding factors
I'm having a bit of trouble recoding factors in a fields. I have a field which has the factors Singleton, Twin and Triplet. I want to recode the field to have only the factors Singleton and Multiple. Any advice? Cheers, Neil
2010 Nov 03
1
Recoding -- test whether number begins with a certain number
Dear R community, I have a question concerning recoding of a variable. I have a data set in which there is a variable devoted to the ISCO code describing the occupation of this certain individual (http://www.ilo.org/public/english/bureau/stat/isco/isco88/major.htm). Every type of occupation begins with a number and every number added to this number describes th occupation more detailed. Now my
2006 Jun 23
1
numeric variables converted to character when recoding missing values
Dear R helpers, I have a data frame where missing values for numeric variables are coded as 999. I want to recode those as NAs. The following only partially succeeds because numeric variables are converted to character in the process: df <- data.frame(a=c(999,1,999,2), b=LETTERS[1:4]) is.na(df[2,1]) <- TRUE df a b 1 999 A 2 NA B 3 999 C 4 2 D is.numeric(df$a) [1] TRUE
2002 Feb 21
2
Re: Factor analysis of categorical or mixed categorical/continuousdata in
I am looking to fit one or more latent categorical variables to data that is a mixture of categorical and continuous variables. Factor analysis would work for continuous data, latent class analysis for categorical data. I understand that in a package such as MPlus I could perform a single analysis of both data types. Are there similar routines available in R? Stuart -----Original Message-----