similar to: Assigning a variable value based on multiple columns

Displaying 20 results from an estimated 1000 matches similar to: "Assigning a variable value based on multiple columns"

2023 Oct 15
2
Create new data frame with conditional sums
Under the hood, sapply() is also a loop (at the interpreted level). As is lapply(), etc. -- Bert On Sun, Oct 15, 2023 at 2:34?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > That's very helpful and instructive, thank you! > > Jason Stout, MD, MHS > Box 102359-DUMC > Durham, NC 27710 > FAX 919-681-7494 > ________________________________ > From: John
2023 Oct 14
1
Create new data frame with conditional sums
That's very helpful and instructive, thank you! Jason Stout, MD, MHS Box 102359-DUMC Durham, NC 27710 FAX 919-681-7494 ________________________________ From: John Fox <jfox at mcmaster.ca> Sent: Saturday, October 14, 2023 10:13 AM To: Jason Stout, M.D. <jason.stout at duke.edu> Cc: r-help at r-project.org <r-help at r-project.org> Subject: Re: [R] Create new data frame with
2023 Oct 14
2
Create new data frame with conditional sums
Well, here's one way to do it: (dat is your example data frame) Cutoff <- seq(0, .15, .01) Pop <- with(dat, sapply(Cutoff, \(p)sum(Totpop[Pct >= p]))) I think there must be a more efficient way to do it with cumsum(), though. Cheers, Bert On Sat, Oct 14, 2023 at 12:53?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > This seems like it should be simple but I
2023 Oct 13
1
Create new data frame with conditional sums
This seems like it should be simple but I can't get it to work properly. I'm starting with a data frame like this: Tract Pct Totpop 1 0.05 4000 2 0.03 3500 3 0.01 4500 4 0.12 4100 5 0.21 3900 6 0.04 4250 7 0.07 5100 8 0.09
2023 Dec 18
3
Function with large nested list
Hello list, I want to make a large rulebased algorithm, to provide decision support for drug prescriptions. I have defined the algorithm in a function, with a for loop and many if statements. The structure should be as follows: 1. Iterate over a list of drug names. For each drug: 2. Get some drug related data (external dataset). Row of a dataframe. 3. Check if adaptions should be made to
2009 May 22
1
bug in rpart?
Greetings, I checked the Indian diabetes data again and get one tree for the data with reordered columns and another tree for the original data. I compared these two trees, the split points for these two trees are exactly the same but the fitted classes are not the same for some cases. And the misclassification errors are different too. I know how CART deal with ties --- even we are using the
2006 Mar 26
1
Newbie clustering/classification question
My laboratory is measuring the abundance of various proteins in the blood from either healthy individuals or from individuals with various diseases. I would like to determine which proteins, if any, have significantly different abundances between the healthy and diseased individuals. Currently, one of my colleagues is performing an ANOVA on each protein with MS Excel. I would like to analyze
2009 Feb 26
1
error message and convergence issues in fitting glmer in package lme4
I'm resending this message because I did not include a subject line in my first posting. Apologies for the inconvenience! Tanja > Hello, > > I'm trying to fit a generalized linear mixed model to estimate diabetes prevalence at US county level. To do this I'm using the glmer() function in package lme4. I can fit relatively simple models (i.e. few covariates) but when
2009 May 12
1
questions on rpart (tree changes when rearrange the order of covariates?!)
Greetings, I am using rpart for classification with "class" method. The test data is the Indian diabetes data from package mlbench. I fitted a classification tree firstly using the original data, and then exchanged the order of Body mass and Plasma glucose which are the strongest/important variables in the growing phase. The second tree is a little different from the first one. The
2009 Oct 27
1
"ipredknn" - How may I find values?
Hi everybody! I want to find a closer neighbourins observation. This is my code: ########################## library(klaR) library(ipred) library(mlbench) data(PimaIndiansDiabetes2) dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)] dane[,2]=log(dane[,2]) dane[,1:2]=scale(dane[,1:2]) zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
2008 Jan 22
2
Help - linear regression
Hi, I am trying a linear regression model where the dependent variable is the size of the heart corrected for the patient's height and weight. This is labelled as LAVI. The independent variables are race (european or non-eurpoean), age, sex (male or female) of the patient and whether they have diabetes and high blood pressure. sample size 2000 patients selected from a community. when I
2009 Feb 26
1
(no subject)
Hello, I'm trying to fit a generalized linear mixed model to estimate diabetes prevalence at US county level. To do this I'm using the glmer() function in package lme4. I can fit relatively simple models (i.e. few covariates) but when expanding the number of covariates I usually encounter the following error message. gm8 <-
2013 Feb 04
2
reshape help
Dear R users - I have a list of patient identifiers and diagnoses from inpatient admissions. I would like to reorganize the list, presently in a long format to a wide format in reshape, but in the absence of a "time" element, I am uncertain how to do this - any help greatly appreciated. ID Dx A nausea A diabetes A kidney failure A heart attack A fever B fever B
2024 Jan 17
1
Is there any design based two proportions z test?
Hello Everyone, I was analysing big survey data using survey packages on RStudio. Survey package allows survey data analysis with the design effect.The survey package included functions for all other statistical analysis except two-proportion z tests. I was trying to calculate the difference in prevalence of Diabetes and Prediabetes between the year 2011 and 2017 (with 95%CI). I was able to
2010 Mar 09
1
create picture (k -the nearest neighbours)
Hi I want to create a nice picture about my result of k -the nearest neighbours algorithm. Here is my easy code: ################################# library(klaR) library(ipred) library(mlbench) data(PimaIndiansDiabetes2) dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)] dane[,2]=log(dane[,2]) dane[,1:2]=scale(dane[,1:2]) zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
2003 Jun 13
1
lars - lasso problem
hello I tried to use lars() but neither with my own data nor with the sample data it works. I get in both cases the following error prompt: > data(diabetes) > par(mfrow=c(2,2)) > attach(diabetes) > x<-lars(x,y) Error in one %*% x : requires numeric matrix/vector arguments > x<-lars(x,y, type="lasso") Error in one %*% x : requires numeric matrix/vector arguments
2024 Jan 17
1
Is there any design based two proportions z test?
Dear Md Kamruzzaman, To answer your second question first, you could just use the svychisq() function. The difference-of-proportion test is equivalent to a chisquare test for the 2-by-2 table. You don't say how you computed the confidence intervals for the two separate proportions, but if you have their standard errors (and if not, you should be able to infer them from the confidence
2018 Feb 27
2
scale.default gives an incorrect error message when is.numeric() fails on a sparse row matrix (dgeMatrix)
I am attempting to use the lars package with a sparse input feature matrix, but the following fails: library(Matrix) library(lars) data(diabetes) attach(diabetes) x = as(as.matrix(as.data.frame(x)), 'dgCMatrix') lars(x, y, intercept = FALSE) Error in scale.default(x, FALSE, normx) : > > length of 'scale' must equal the number of columns of 'x' > > More
2007 Jun 12
1
LASSO coefficients for a specific s
Hello, I have a question about the lars package. I am using this package to get the coefficients at a specific LASSO parameter s. data(diabetes) attach(diabetes) object <- lars(x,y,type="lasso") cvres<-cv.lars(x,y,K=10,fraction = seq(from = 0, to = 1, length = 100)) fits <- predict.lars(object, type="coefficients", s=0.1, mode="fraction") Can I assign
2010 May 13
1
What's data() for?
Hi there, >library(faraway) >pima pregnant glucose diastolic triceps insulin bmi diabetes age test 1 6 148 72 35 0 33.6 0.627 50 1 2 1 85 66 29 0 26.6 0.351 31 0 >data(pima) >pima pregnant glucose diastolic triceps insulin bmi diabetes age test 1 6 148 72 35 0 33.6