similar to: recode() function results in logical output, not factor output

Displaying 20 results from an estimated 3000 matches similar to: "recode() function results in logical output, not factor output"

2007 Oct 28
1
tree problem
I am trying to use tree to partition a data set. The data set has 3924 observations. Partitioning seems to work for small subsets of the data, but when I use the entire data set, no partitioning occurs. The variables are: RESP respondent to a survey (0 = not a respondent, 1 = respondent) AGE_P Age (continuous) ORIGIN_I Hispanic Ethnicity (1 = Hispanic, 2 = non-Hispanic) RACRECI2 Race
2007 Jul 03
1
Please help with legend command
Hi R-ers: I'm drawing a plot and have used different line types (lty) for different race/ethnicity groups. I want a legend that explains what line types correspond to the different race/ethnicity groups. I used the following code: legend( 1992 , 42 , c("Hispanic" , "non-Hispanic white (NHW)" , "non-Hispanic black" , "AI/AN" , "Asian" ) ,
2009 Nov 09
2
Complicated For Loop (to me)
Hello, I'm trying to run a loop that will subset my data into specific sets by regions and by race/ethnicity. I'm trying to do this fairly compactly, and I cannot get this to work. A "simple" version of the code that I am trying to run is: names <- c("white", "black", "asian", "hispanic") for(j in names){ for(i in 1:9){
2008 May 28
1
manipulating multiply imputed data sets
Hi folks, I have five imputed data sets and would like to apply the same recoding routines to each. I could do this sort of thing pretty easily in Stata using MIM, but I've decided to go cold turkey on other stats packages as a incentive for learning more about R. Most of the recoding is for nominal variables, like race, religion, urbanicity, and the like. So, for example, to recode race
2018 Oct 16
2
Comprobar los nombres de columnas entre varios dataframes
Buenas tardes, Quiero aplicar la función rbind y necesito tener los mismos nombres de columnas. Como tengo unas 195 variables en cada dataframe, necesito hacerlo de una forma rápida. Tengo 9 bases de datos y tengo que fusionar todas. ¿Como puedo comprobar que los nombres de las variables son los mismos? Y de lo contrario, ¿como detecto las diferencias? He probado con
2010 Oct 02
3
Non-Parametric Adventures in R
I just started using R and I'm having all sorts of "fun" trying different things. I'm going to document the different things I'm doing here as a kind of case study. I'm hoping that I'll get help from the community so that I can use R properly. Anyways, in this study, I have demographic data, drug usage data, and side effect data. All of this is loaded into a csv
2012 Dec 03
2
Excluding all missing values with dcast ("reshape2" package)
Hello--I'm doing a simple crosstab using dcast: rawfreq <- dcast(nh11brfs, race3~CHCCOPD, length) with the results race3 Yes No NA 1 White non-Hispanic 446 5473 21 2 Other non-Hispanic 29 211 0 3 Hispanic 6 81 1 4 <NA> 10 83 1 How would I modify this call to exclude all missing values; that is, to obtain race3
2010 Jul 02
1
help with the xtable package
HI, Dear R community, I am using the xtable to create the table, but how can I see the table? The following is the codes I used: > data(tli) > tli.table <- xtable(tli[1:10, ]) > digits(tli.table)[c(2, 6)] <- 0 > print(tli.table, floating = FALSE) % latex table generated in R 2.11.0 by xtable 1.5-6 package % Thu Jul 1 20:43:43 2010 \begin{tabular}{rrlllr} \hline &
2017 Jul 09
2
Help with ftable.svyby
Hi all, When I try the following with pkg Survey it returns the error below: ftable(svyby(~INCOME, ~AGECL+RACECL, svymean, design=q50), rownames=list(AGECL=c("<35", "35-44", "45-54", "55-64", "65-74", ">=75"), RACECL=c("white non hispanic", "non white or
2009 Oct 31
1
Help me improving my code
Hi, I am new to R. My problem is with the ordered logistic model. Here is my question: Generate an order discrete variable using the variable wrwage1 = wages in first full calendar quarter after benefit application in the following way: * wage*1*Ordered *= 1 *if*0 *· wrwage*1 *< *1000 2 *if*1000 *· wrwage*1 *< *2000 3 *if*2000 *· wrwage*1 *< *3000 4 *if*3000 *· wrwage*1 *<
2010 Mar 25
3
Returning Data Frame from Function for use Outside Function
I have a function (see below) that does some bootstrapping (I am happy to expand offline why I could use existing functions.) I put my results into and empty matrix and add a row of results with each iteration. My problem is i am a new user to R and I don't understand data frames, matrices, elements, and vectors well. What I would like is to have a data frame I can manipulate outside of the
2009 Jun 04
4
Binning or grouping data
Newbie here. Many apologies in advance for using the incorrect lingo. I'm new to statistics and VERY new to R. I'm attempting to "group" or "bin" data together in order to analyze them as a combined group rather than as discrete set. I'll provide a simple example of the data for illustrative purposes. Patient ID | Charges | Age | Race 1 |
2010 Jun 15
1
Problem with the recode function
Hello, I am using the recode() function in Rcmdr and the result is not what I expect so I am almost sure I did something wrong but what... > test <- data.frame(x=1:10) > library(car) > recode(test$x,'1:5=0 ; else=1', as.factor.result=TRUE) [1] 0 0 0 0 0 1 1 1 1 1 Levels: 0 1 BUT > library(Rcmdr) # recode from the car package is now masked Now I recode test$x
2003 Dec 06
1
recode{car} does not work as expected?
Hi to all, I am having a problem when using recode from the car package. I have a variable that is char and when I use recode to create a new variable that is supposed to be numeric I get a factor variable. Here is the code I am using: > FCI$PRE1 <- recode (PRE1RES, " c('C', 'c')=1 ; else = 0 ; as.factor.result=FALSE ") So, if I understand correctly the recode
2003 Nov 04
2
line breaks in recode
Dear all, it seems to be that 'recode' can't handle any line breaks in its code. The following command causes no problem: datameta$smpid.r <- recode(datameta$smpid,"c(101,25,167,45,75)=25;c(104,51)=51") But if I type ... datameta$smpid.r <-recode(datameta$smpid, "c(101,25,167,45,75)=25; c(104,51)=51") ... the result is a syntax error.
2005 Jul 28
1
Unexpected behavior in recode{car}
Thanks to the R creators for such a great statistical system. Thanks to the R help list, I have (finally) gotten far enough in R to have a question I hope to be worth posting. I'm using the recode function from John Fox's car package and have encountered some unexpected behavior. Consider the following example: ## Begin cut-and-paste example require( car ) set.seed(12345) nn <-
2017 Jul 09
0
Help with ftable.svyby
try resetting your factor levels and re-run? q50 <- update( q50 , INCOME = factor( INCOME ) , AGECL = factor( AGECL ) , RACECL = factor( RACECL ) ) On Sun, Jul 9, 2017 at 2:59 PM, Orsola Costantini via R-help < r-help at r-project.org> wrote: > Hi all, > > When I try the following with pkg Survey it returns the error below: > > ftable(svyby(~INCOME, ~AGECL+RACECL,
2011 Jul 29
1
Apostrophes in R Commander in recode
Dear colleagues, I'm using R64 (2.13) on Mac OS 10.6.8 and I've encountered a problem with the recode function in Rcommander. The application cannot deal with apostrpohes ( ' ) do not. I've got a factor from the 2008 Canada Election study (highest level of schooling) and some of the values include "Bachelor's Degree" , "Master's Degree". I've
2010 Apr 07
2
recoding variables-recode not working
Hi, I have numerical variable that I want to recode into categories '0' and '1 and more' and do analysis with that data. I have tried various of possibilities to do so, but I am sucked and nothing is working. recode(Q12, "0='A';1:30='B'") cut(Q12, breaks=c(0,1,30), lables=c('0', '1 and more')) cat(Q12, "0=0;1-33=1") What should
2009 Nov 18
2
recode according to old levels
Dear R-users, i try to recode a factor according to old levels F <- factor(sample(c(rep("A", 4), rep("B",2), rep("C",5)))) recode(F, "levels(F)[c(1,3)]='X'; else='Y'") i tried to work with eval or expression around levels(F)[c(1,3)], but nothing seems to work. Many thanks if anyone could tell me what i've missed and what's