similar to: Recoding Multiple Variables in a Data Frame in One Step

Displaying 20 results from an estimated 1000 matches similar to: "Recoding Multiple Variables in a Data Frame in One Step"

2010 Mar 10
1
Strange result in survey package: svyvar
Hi R users, I'm using the survey package to calculate summary statistics for a large health survey (the Demographic and Health Survey for Honduras, 2006), and when I try to calculate the variances for several variables, I get negative numbers. I thought it may be my data, so I ran the example on the help page: data(api) ## one-stage cluster sample dclus1<-svydesign(id=~dnum, weights=~pw,
2011 Oct 24
4
Problem with svyvar in survey package
I am facing a problem with a function in survey package. The function svyvar gives the estimated population variance from a given sampling scheme. I am working with a data having more than four continuous variables. In order to have have population total for all those cont. variables I have written in the following format svyvar(~var1+var2+var3+var4+var5+var6,data) ; var1,var2,...,var6 are 6
2010 Feb 18
1
survey package question
Should the svyby function be able to work with svyquantile? I get the error below ... data(api) dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) svyby(~api00, design=dclus1, by = ~stype, quantiles=c(.25,.5,.75), FUN=svyquantile, na.rm=T ) > Error in object$coefficients : $ operator is invalid for atomic vectors A
2012 Jun 28
1
SVY: variance inflation factor VIF with complex survey
Hello, Seeking a way to get the variance inflation factor VIF for a model of regression in complex survey, I have understood that without this package (SURVEY) RGui VIF obtained as follows: fit <- lm(mpg~disp+hp+wt+drat, data=mtcars) vif(fit) But I want to know if survey, Vif is obtained so vif( svyglm(api00~ell+meals+mobility, design=dstrat)) Thank you, happy day
2012 Jun 21
4
crosstable and regression for survey data (weighted)
I have survey data that I am working on. I need to make some multi-way tables and regression analyses on the data. After attaching the data, this is the code I use for tables for four variables (sweight is the weight variable): > a <- xtabs(sweight~research.area + gender + a2n2 + age) > tmp <- ftable(a) Is this correct? I don't think I need to use the strata and cluster
2012 Oct 18
3
svyplot and svysmooth with hexbin
Hi all- So sorry to bother you all with something pretty basic. I am trying to add the lines method output from svysmooth to a svyplot with style="grayhex". However, the line either appears in the wrong place or if I am running in R Studio it causes the system to crash. I know this is something to do with Lattice graphics, but for the life of me I can not figure out how. Dr. Lumley
2012 Sep 21
1
Exactly Replicating Stata's Survey Data Confidence Intervals in R
Hi everyone, apologies if the answer to this is in an obvious place. I've been searching for about a day and haven't found anything.. I'm trying to replicate Stata's confidence intervals in R with the survey package, and the numbers are very very close but not exact. My ultimate goal is to replicate Berkeley's SDA website with R (http://sda.berkeley.edu/), which seems to
2009 Nov 02
2
"object not found" within function
Hi, I am trying to write a function to compute many cross-tabulations with the -svytable- command. Here is a simplified example of the structure of my code (adapted from the -svytable- help file): data(api) func.example<-function(variable){ dclus1<-svydesign(id=~1, weights=~pw,data=apiclus1, fpc=~fpc) svytable(~ variable, dclus1) } When I call this function with:
2017 Nov 17
3
Complicated analysis for huge databases
Hi all .., I have a large dataset of around 600,000 rows and 600 columns. The first col is codes for Meal A, the second columns is codes for Meal B. The third column is customers IDs where each customer had a combination of meals. Each column of the rest columns contains values 0,1,or 2. The dataset is organised in a way so that the first group of customers had similar meals combinations, this
2017 Nov 17
0
Complicated analysis for huge databases
Combine columns 1 and 2 into a column with a single ID like "33.55", "44.66" and use split() on these IDs to break up your dataset. Iterate over the list of data frames split() returns. B. > On Nov 17, 2017, at 12:59 PM, Allaisone 1 <allaisone1 at hotmail.com> wrote: > > > Hi all .., > > > I have a large dataset of around 600,000 rows and 600
2017 Nov 18
2
Complicated analysis for huge databases
Thanks Boris , this was very helpful but I'm struggling with the last part. 1) I combined the first 2 columns :- library(tidyr) SingleMealsCode <-unite(MyData, MealsCombinations, c(MealA, MealB), remove=FALSE) SingleMealsCode <- SingleMealsCode[,-2] 2) I separated this dataframe into different dataframes based on "MealsCombination" column so R will recognize each meal
2017 Nov 18
0
Complicated analysis for huge databases
Something like the following? AllMAFs <- list() for (i in length(SeparatedGroupsofmealsCombs) { AllMAFs[[i]] <- apply(SeparatedGroupsofmealsCombs[[i]], 2, function(x)maf(tabulate(x+1))) } (untested, of course) Also the solution is a bit generic since I don't know what the output of maf() looks like in your case, and I don't understand why you use tabulate because I would have
2017 Nov 18
2
Complicated analysis for huge databases
Although the loop seems to be formulated correctly I wonder why it gives me these errors : -object 'i' not found - unexpected '}' in "}" the desired output is expected to be very large as for each dataframe in the list of dataframes I expect to see maf value for each of the 600 columns! and this is only for for one dataframe in the list .. I have around 150-200
2017 Nov 18
0
Complicated analysis for huge databases
> On Nov 18, 2017, at 1:52 AM, Allaisone 1 <allaisone1 at hotmail.com> wrote: > > Although the loop seems to be formulated correctly I wonder why > it gives me these errors : > > -object 'i' not found > - unexpected '}' in "}" You probably did not copy the entire code offered. But we cannot know since you did not "show your code",
2012 Oct 16
1
Package survey: Compute standard deviations from complex survey designs
Hello, svyvar from the survey package computes variances (with standard errors) from survey design objects. Is there any way to compute standard deviations and their standard errors in a similar manner? Thanks a lot, Sebastian
2017 Nov 18
3
Complicated analysis for huge databases
The loop : AllMAFs <- list() for (i in length(SeparatedGroupsofmealsCombs) { AllMAFs[[i]] <- apply( SeparatedGroupsofmealsCombs[[i]], 2, function(x)maf( tabulate( x+1) )) } gives these errors (I tried this many times and I'm sure I copied it entirely) :- Error in apply(SeparatedGroupsofmealsCombs[[i]], 2, function(x) maf(tabulate(x + : object 'i' not found > }
2009 Sep 15
2
Viewing Function Code
Hi All, I'd like to see the function code behind the barplots2() function in the gplots package, however i come across a bit of a stumbling block of a hidden function, can anyone help? > library(gplots) > methods(barplot2) [1] barplot2.default* Non-visible functions are asterisked > barplot2 function (height, ...) UseMethod("barplot2") <environment:
2010 Mar 26
1
return.replicates in survey pkg
How do I retrieve the replicates estimates from a crosstab done using svyby? Here is an example from the help page for svyby in the package: > data(api) > dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) > rclus1<-as.svrepdesign(dclus1) > > a <- svyby(~api99, ~stype, rclus1, svymean, return.replicates=TRUE) > a$replicates NULL But, compare to > b
2017 Nov 18
0
Complicated analysis for huge databases
On 18/11/2017 4:40 PM, Allaisone 1 wrote: > > The loop : > > > AllMAFs <- list() > > for (i in length(SeparatedGroupsofmealsCombs) { > AllMAFs[[i]] <- apply( SeparatedGroupsofmealsCombs[[i]], 2, function(x)maf( tabulate( x+1) )) > } > > > gives these errors (I tried this many times and I'm sure I copied it entirely) :- > > Error in
2008 Jul 04
4
Re ad in a file - produce independent vectors
Is there a way of reading in a file in a way that each line becomes a vector: for example: meals.txt breakfast bacon eggs sausage lunch sandwich apple marsbar crisps dinner chicken rice custard pie I want to read in this file and end up with 3 different vectors, one called breakfast which contains "bacon", "eggs", sausage" One called