similar to: recode involving a count rule

Displaying 20 results from an estimated 2000 matches similar to: "recode involving a count rule"

2010 Oct 18
2
Getting tripped up on NAs in trying to create new variable
Hello R help: I have the following data: a <- c(NA, 2, 2, 3, 2, NA) b <- c(NA, NA, 3, NA, 1, 3) df <- data.frame(a, b) > df a b 1 NA NA 2 2 NA 3 2 3 4 3 NA 5 2 1 6 NA 3 I want to create variable c such that if there is a 3 in either variable a or variable b, variable c is 1(rows 3, 4 & 6 below). If 3 not in a or b and a value appears in a or b, then c is 0(row 2
2009 Jan 08
1
library error on start up, error on update packages
Hello, I am unable to update packages. I am running R version 2.8.1 (2008-12-22) under VISTA. When I start R I get the following error: Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Error in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,
2005 Aug 25
1
Attempting to recode elements contained in a list
Hello R-Masters, I have a list 's' with three elements, as shown below. I want to recode a.a, a.a2, and a.a3 to NA if the value in a.a is less than 3. I reivewed my Modern Applied Statistic Book, the online help and did some searching of R-help on the internet. I explored unlist and as.list.data.frame in an attempt to isolate the third element of the list s, but this was not helpful.
2003 Jan 06
2
R and file size
I will be involved with an analysis based on a file that will be roughly 25 meg. Assuming I have enough memory, is their any limitations to using R on a file this large. Thank you, Gregory L. Blevins Vice President, Partner The Market Solutions Group, Inc. gblevins at marketsolutionsgroup.com Office phone: 612 392-3163 Cell phone: 612 251-0232
2008 Jan 24
2
boxplot axis labelling
Hi, i'm very new to R, so sorry for what i'm sure is a very basic question. I'm producing a boxplot with the data below: df3<-data.frame( x=c(10,11,115,12,13,14,16,17,18,21,22,23,24,26,27,28,29,3,30,32,33,34,35,4,4 1,45,5,50,52,56,58,6,67,6738,68,7,8,9), fq=c(8,11,1,2,4,4,2,2,6,3,4,2,2,1,1,1,4,51,3,1,1,1,1,35,1,1,19,2,1,1,1,14,1, 1,1,10,13,5),
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]
2017 Nov 01
0
Adding Records to a Table in R
Hi Paul, #First I set up some sample data since I don't have a copy of your data dtOrig <- as.Date( c("1985-04-01","1985-07-01","1985-12-01","1986-04-01")) dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325), CargoTons=c(1000,1080,3785,4200) ) #Generate the complete set of dates as a data frame dfDates<- data.frame(
2009 Aug 12
4
paste first row string onto every string in column
Hi, I am trying to edit a data frame such that the string in the first line is appended onto the beginning of each element in the subsequent rows. The data looks like this: > df V1 V2 V3 V4 1 DPA1* DPA1* DPB1* DPB1* 2 0103 0104 0401 0601 3 0103 0103 0301 0402 . . and what I want is this: >dfnew V1 V2 V3 V4 1 DPA1* DPA1* DPB1* DPB1* 2 DPA1*0103
2003 Oct 07
3
Problem getting an ifelse statment to work
This is a "long" way; i.e., not necessarily efficient: > qs2 [1] 2 1 1 4 4 4 1 1 1 4 2 4 3 1 4 3 3 2 4 3 > qs9 [1] 4 4 1 3 4 3 1 3 1 4 1 2 3 3 4 4 1 4 2 3 > decision <- function(a, b) { + if (a == 1 || b == 1) return(1) + if (a == 2 || b == 2) return(2) + if (a == 3 || b == 3) return(3) + if (a == 4 || b == 4) return(4) + NA + } > mapply(decision,
2004 Jun 06
4
Request help writing a function
I have been wrestling with this function for quite a while, and am not making headway. 1) I want to apply a function to the following columns of a dataframe: myfunction. <- apply(ph5028[,c(83:107)],2,function(x) ... 2) Within each of the above columns there is a single numeric code, 1, 2 or 3 or an NA. 3) My goal is to determine the percent of time each person used a 2 code. So if a person
2004 Mar 04
4
A file manipulation question
Hello R experts, The following problem outstrips my current programming knowledge. I have a dataframe with two fields that looks like the following: ID Contract 01 1 01 1 02 2 02 3 02 1 03 2 03 2 03 2 03 1 03 1 03 1 etc... I would like to end up with a dataframe with one row per ID where the value in the contract field would be the
2004 Dec 21
2
How to display each symbol in a different color using plot with summary.formula.reverse
Dear R Masters, I have searched high and low (the help archives and my various R reference material and help files) for a solution to what appears to me to be quite a simple problem. In the following syntax, variable n10 has three levels. I would like the symbols that appear in the graph for these three levels to be different colors. The best I have been able to do is to have the Key display
2004 Jun 08
2
Recoding a multiple response question into a series of 1, 0 variables
Hello R folks. 1) The question that generated the data, which I call Qx: Which of the following 5 items have you performed in the past month? (multipe response) 2) How the data is coded in my current dataframe: The first item that a person selected is coded under a field called Qxfirst; the second selected under Qxsecond, etc. For the first Person, the NAs mean that that person only selected
2017 Nov 08
3
Adding Records to a Table in R
Dear Eric, Hope you are doing great. I also tried the following: #First I created the complete date sequence TransitDateFrame <- data.frame(TransitDate=seq(as.Date(dataset1[1,1]), as.Date(dataset1[nrow(dataset1),1]), by = "month")) #Then I did the merging dataset1NEW <- merge(TransitDateFrame, dataset1, by="TransitDate", all.x=TRUE) Now it has, as expected the
2004 Oct 06
8
Dataframe manipulation question
Hello, I have a data frame that has three fields. Resp# ActCode ProdUsed 100 3 2 100 3 2 100 4 3 100 4 3 101 3 6 102 2 1 102 3 1 103 5 1 103 5 1 103
2017 Nov 08
0
Adding Records to a Table in R
Hi Instead of attachments copy directly result of dput(TransitDateFrame) and dput(dataset1) to your email. Or, if your data have more than about 20 rows you could copy only part of it. dput(TransitDateFrame[,1:20]) dput(dataset1[,1:20]) Only with this approach we can evaluate your data in all aspects and provide correct answer. Cheers Petr > -----Original Message----- > From: R-help
2003 Aug 18
1
Would like to apply a weight variable to the summary function in Hmisc
Hello, In the Hmisc package, functions describe and summarize can explicitly take a weight variable. My question is can a weight variable be applied when using 'summary'? For example, using...summary(var1 ~ var2) I would like to weight the data by var 3 (same length). Is this possible? Thanks a lot. Greg Blevins The Market Solutions Group, Inc.
2004 Jun 14
1
error running sammon
Hello, I am inputing a 17 x 17 symetric matrix to sammon. The matrix is a co-occurance matrix with no missing data. If this is at all relevant, running hclust on this matrix works. > samx <- sammon(q23axproduct) I receive the following error: Error in sammon(q23axproduct) : initial configuration must be complete In addition: Warning messages: 1: some of the first 2 eigenvalues are
2004 Apr 03
3
Seeking help for outomating regression (over columns) and storing selected output
Hello, I have spent considerable time trying to figure out that which I am about to describe. This included searching Help, consulting my various R books, and trail and (always) error. I have been assuming I would need to use a loop (looping over columns) but perhaps and apply function would do the trick. I have unsuccessfully tried both. A scaled down version of my situation is as follows:
2004 Nov 29
1
Seeking help with a simple loop construction
Hello, I have a df, pp, with five variables: > nobs(pp) q10_1 q10_2 q10_3 q10_4 actcode 1620 1620 1620 1620 1620 I want to create a loop to run four xtabs (the first four variables above by the fifth) and then store the results in a matrix. Below I make my intent clear by showing the output of one xtab which is inserted into a matrix. > a <- xtabs(q10_1 ~