similar to: Subscripting specified variables in a function

Displaying 20 results from an estimated 300 matches similar to: "Subscripting specified variables in a function"

2004 Apr 14
1
Variable Descriptors
Is there a way to associate text descriptions with variables in a data.frame? For example... Let's say that in my data.frame I have a variable named var1. var1 represents the responses to the question "When was the last time you saw your physician?" When I tabulate the variable var1 I'd like the output to be a bit more descriptive and contain the more descriptive
2003 May 07
2
"Program" files
Is there any such thing as a program file in R? That is, is it possible to compile and save code for performing data management and analytic tasks for a given project into a single/multiple file(s) (i.e., like a script file (S-Plus), a do file (STATA), or a *.sas file (SAS))? Any words of wisdom or a point in the direction of some documentation would be helpful. If it is not possible to work
2000 Aug 10
2
help with matrix creation
hi R-help! I would like to know a simple and easy way (if posible) to do the following data manipulation. I have a matrix of experimental data (with replicae in time) >experiment<-data.frame(times=c(0,0,10,10,20,20,30,30),expval=c(1,1,2,2,3,3,4,4)) > experiment times expval 1 0 1 2 0 1 3 10 2 4 10 2 5 20 3 6 20 3 7 30 4 8
2003 Apr 24
3
Detailed contingency tables
Is there any existing function for creating contingency tables that will display counts, row, column, and cell percentages in the same tables....anything similar to crosstabs in S? Marc W. Zodet, MS Health Statistician Center for Cost and Financing Studies Division of Statistical Research and Methods 2101 East Jefferson Street, Suite 500 Rockville, Maryland 20852 Phone: 301-594-7072 Fax:
2004 Jul 23
2
Complex Surveys...Specifying Design
I need some guidance from someone who is familiar/has some experience with the survey package. The data that I am using is from the Medical Expenditure Panel Survey (www.meps.ahrq.gov <http://www.meps.ahrq.gov/> ). The STRATA and PSU variables are varstr01 and varpsu01 respectively. When I try to specify them with the svydesign function I get an error message. An excerpt of my session
2006 Sep 20
1
Simulation help
I'm trying to simulate trend data over a five year period. I want different trend profiles...the simplest being a linear trend. I've been using the following code: patBdta1 <- NULL for(i in 1:100) patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)), yr2 =mean(rbinom(50,1,.51)), yr3 =mean(rbinom(50,1,.52)),
2009 May 29
1
RODBC sqlSave with DB2
I am running R version 2.8.1 on Windows XP OS. This works fine. (Data.frame dta is created with records from the DB2 table.): sql <- "select * from storage.testappend_slt order by uut" dta <- sqlQuery(channel,sql) But when I try to append records (from data.frame newdta) to the same DB2 table. I get an error: sqlSave(channel, newdta, tablename = storage.testappend_slt, append
2003 Sep 30
1
Stepwise procedures
Is there a function in R which performs stepwise estimation in ways similar to SAS/STATA (i.e., allows the analyst to specify the significance levels for removal/addition of terms). I've been asked to evaluate two final models: one resulting from a backwards selection in R (stepAIC) and one resulting from a backwards selection using PROC LOGISTIC in SAS. The final terms are slightly
2003 Jul 24
1
geoR size limit problem
Hi all, I tried to produce some kriged surfaces with geoR (latest version). The size of the grid should be around 900 x 650 cells (what I find is not a very big grid), and the number of points is around 2500. The command krige.conv stopped after arround 5 min saying it can not allocate a vector with around 1.5 billion units. Sounds reasonable. Is there a workaround? How would I partition the
2010 Aug 18
1
svyquantile w/ svyby is returning an error
svymean w/ svyby is working for me... > svyby(~visitcnt, ~agegrp3.f, svymean, design=svydes) agegrp3.f visitcnt se.visitcnt 18-44 18-44 8.755552 0.4953235 45-64 45-64 10.131555 0.5347806 65+ 65+ 9.588802 0.4323629 svyquantile is working for me... > svyquantile(~visitcnt, quantiles=c(.25, .5, .75), ties="rounded", design=svydes) 0.25
2000 Aug 10
0
help with matrix creation (merging data frames)
> Date: Thu, 10 Aug 2000 15:33:39 -0700 > From: Jesus Maria Frias Celayeta <iosu at bureau.ucc.ie> > > hi R-help! > > I would like to know a simple and easy way (if posible) to do the following > data manipulation. I have a matrix of experimental data (with replicae in time) actually, they seem to be data frames. > >
2003 Sep 11
2
Sorting
What is the best way to sort a dataframe? For example, how would I go about sorting a dataframe (with variables V1-V5) by ascending V1, V2 and descending V3 while retaining V4 and V5. Also, is there a relatively easy way by which to re-order my columns? Thank you for your time. Marc Marc Zodet [[alternative HTML version deleted]]
2017 Dec 13
3
match and new columns
Hi all, I have a data frame tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE) I want match tdat$B with tdat$A and populate the column values of tdat$A ( col A and Col B) in the newly created columns (col D and col E). please find my attempt and the desired output below Desired output
2017 Dec 13
2
match and new columns
Thank you Rui, I did not get the desired result. Here is the output from your script A B C Y D E 1 A12 B03 C04 0.70 0 0 2 A23 B05 C06 0.05 0 0 3 A14 B06 C07 1.20 0 0 4 A25 A23 A12 3.51 1 1 5 A16 A25 A14 2,16 4 4 On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote: > Hello, > > Here is one way. > > tdat$D <- ifelse(tdat$B %in% tdat$A,
2017 Dec 14
1
match and new columns
Hi Bill, I put stringsAsFactors = FALSE still did not work. tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE ,stringsAsFactors = FALSE) tdat$D <- 0 tdat$E <- 0 tdat$D <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)) tdat$E <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0))
2017 Dec 14
0
match and new columns
Use the stringsAsFactors=FALSE argument to read.table when making your data.frame - factors are getting in your way here. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Dec 13, 2017 at 3:02 PM, Val <valkremk at gmail.com> wrote: > Thank you Rui, > I did not get the desired result. Here is the output from your script > > A B C Y D E > 1 A12 B03 C04 0.70 0 0
2017 Dec 13
0
match and new columns
Hello, Here is one way. tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0) tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0) Hope this helps, Rui Barradas On 12/13/2017 9:36 PM, Val wrote: > Hi all, > > I have a data frame > tdat <- read.table(textConnection("A B C Y > A12 B03 C04 0.70 > A23 B05 C06 0.05 > A14 B06 C07 1.20 > A25 A23 A12 3.51
2007 Dec 06
5
Help rewriting looping structure?
Hey Folks, Could somebody help me rewrite the following code? I am looping through all records across 5 fields to calculate the cumulative percentage of each record (relative to each individual field). Is there a way to rewrite it so I don't have to loop through each individual record? ##### tdat is my data frame ##### j is my field index ##### k is my record index ##### tsum is the sum of
2018 May 18
3
exclude
Hi All, I have a sample of data set show as below. tdat <- read.table(textConnection("stat year Y AL 2003 25 AL 2003 13 AL 2004 21 AL 2006 20 AL 2007 12 AL 2009 16 AL 2010 15 FL 2006 63 FL 2007 14 FL 2007 25 FL 2009 64 FL 2009 47 FL 2010 48 NY 2003 50 NY 2004 51 NY 2006 57 NY 2007 62 NY 2007 36 NY 2009 87 NY 2009 96 NY 2010
2006 Sep 07
1
Running/submitting script files
All: Is there any way to run an R script file (i.e., *.R) from the command prompt in the console window. Ultimately, I'm looking to put such code in a script file so that it can set off other R scripts/programs as needed. Thanks. Marc [[alternative HTML version deleted]]