similar to: variable substitution in for loops

Displaying 20 results from an estimated 300 matches similar to: "variable substitution in for loops"

2008 Jan 22
1
row-wise conditional update in dataframe
Hi! I need to conditionally update a dataframe field based on values in other fields and can't find even how to search for this right. Sorry if this has been asked before. But, specifically, I have a 490 X 221 dataframe and need to count, by row, how many fields in Dataframe$field_a...Dataframe$field_zz are non-null and enter this value in Dataset$ABCtaskNum. I have field name
2010 Feb 18
1
variable substitution
Hi I would like to write a script that reads a list of variable names. These variable names are some of the column headers in a data.frame. Then I want do a for-loop to execute various operations on the specified variables in the data.frame, but can't figure out how to do the necessary variable substitution. In bash (or C) I would use "$var", but there seems to be no equivalent in
2010 Jun 09
1
generate list of variable names
Hi! Would anyone know how to generate a list of variable names from a data frame by the class of the variable? I have large tables with different numbers of columns and am trying to script some rote analyses. There are several categorizing variables (factors) and many response variables (integers and numeric). I want to extract a list of classifier column names in one list and response variable
2010 Dec 09
4
lapply getting names of the list
Hello All, I have a toy dataframe like this. It has 8 columns separated by tab. Name SampleID Al1 Al2 X Y R Th rs191191 A1 A B 0.999 0.09 0.78 0.090 abc928291 A1 B J 0.3838 0.3839 0.028 0.888 abcnab A1 H K 0.3939 0.939 0.3939 0.77 rx82922 B1 J K 0.3838 0.393
2010 Dec 09
1
set dataframe field value from lookup table
Hi This is (hopefully) a bit more cogent phrasing of a previous post. I'm trying to compute a z-score to rows in a large dataframe based on values in another dataframe. Here's the script (that does not work). 2 questons, 1) Anyone know of a more elegant way to calculate the "rounded" age value than the nested ifelse's I've used? 2) how to reference the lookup table
2005 Feb 08
5
How to get variable names in a function?
Hello, applying a function to a list of variables I face the following problem: Let's say I want to compute tables for several variables. I could write a command for every single table, like bravo<-c(1,1,2,3,5,5,5,);charly<-c(7,7,4,4,2,1) table(bravo); table(charly) > table(bravo); table(charly) bravo 1 2 3 5 2 1 1 3 charly 1 2 4 7 1 1 2 2 The results are two tables with the
2003 Oct 08
2
Generating automatic plots
Hello, I have been trying to write a small program to generate automatic plots. What I want is to draw boxplots for some variables in my data frame, contrasting with a variable called 'missing' that has value 1 if some variable in a concrete case has at least one missing value, in order to check if the cases that don't enter in my analysis are biased. The first attempt was to
2012 Mar 10
1
Treat Variable as String and a String as variables name
Dear all. I am having ten variables (let's call the four of them as Alpha, Beta, Gamma and Delta.....) For each variable I have to print around 100 (plots). E So far I was copying paste the code below many times. pdf(file="DC_Alpha_All.pdf", width=15) # First Variable is treated as string plot_dc_for_multiple_kapas(Alpha, 4, c(5, 4), coloridx=c(24, 32)) # First Variable is
2007 Oct 22
3
Elasticity in Leslie Matrix
Dear R-users, I would like to calculate elasticities and sensitivities of each parameters involved in the following transition matrix: A <- matrix(c( sigma*s0*f1, sigma*s0*f2, s, v ), nrow=2, byrow=TRUE,dimnames=list(stage,stage)) The command "eigen.analysis" avaliable in package "popbio" provides sensibility matrix and elasticity matrix
2016 Dec 13
2
syntax difference clusterExport in parallel and snow
We got some errors and eventually figured out that parallel::clusterExport second argument is "varlist" while in snow::clusterExport it is "list". The user had loaded parallel first, but did something else which inadvertently loaded snow, then clusterExport failed because we had "varlist" and not "list". Are these different on purpose? pj -- Paul E.
2012 Nov 24
1
Bootstrap lmekin model
Hi,I use the 'lmekin' model of the 'kinship' package of R in order to estimate heritability. I want to estimate the confidence interval of the variance coefficient and so I should use a bootstrap simulation. The pedigree file has 1386 subjects so I create a kinship matrix [1386*1386].This is the code of R I use: kfit2 <- lmekin(IT~1+AGE +(1|ID), dati1,
2009 Oct 11
1
How do you test if a number is in a list of numbers?
Hi, I want to subset a data frame if one of the variables matches any in a list. I could of course do something like this: subset(dataset, var == 1 | var == 2 | var ==3) but that's tedious. I tried varlist = c(1,2,3,4) subset(dataset, any(var == varlist)) but it doesn't work because 'any' doesn't go row-by-row and hence always returns TRUE. Is there any simple way to do this?
2013 Feb 18
3
foreach loop, stata equivalent
Hi! I'm a recent convert from Stata, so forgive my ignorance. In Stata, I can write foreach loops (example below) foreach var of varlist p1-p14 { foreach y of varlist p15-p269 { reg `var' `y' } } It's looping p1-p15, p1-p16...., p1-p269, p2-p15, p2-p16,... p2-p269,... variable pairs. How can I write something similar in R? I 'tried' understanding the
2017 Jun 26
3
Jagged ROC curves?
Hi, I was trying to draw some ROC curves (prediction of case/control status), but seem to be getting a somewhat jagged plot. Can I do something that would 'smooth' it somewhat? Most roc curves seem to have many incremental changes (in x and y directions), but my plot only has 4 or 5 steps even though there are 22 data points. Should I be doing something differently? How can I provide a
2011 Apr 15
1
no solution yet, please help: extract p-value from mixed model in kinship package
I am making the question clear. Please help. > Dear R experts > > I was using kinship package to fit mixed model with kinship matrix. > The package looks like lme4, but I could find a way to extract p-value > out of it. I need to extract is as I need to analyse large number of > variables (> 10000). > > Please help me: > > require(kinship) > > #Generating
2010 Nov 11
3
Evaluation puzzle
The survexp function can fail when called from another function. The "why" of this has me baffled, however. Here is a simple test case, using a very stripped down version of survexp: survexp.test <- function(formula, data, weights, subset, na.action, rmap, times, cohort=TRUE, conditional=FALSE, ratetable=survexp.us, scale=1, npoints, se.fit,
2010 Jul 16
1
read.table input array
Hello to all! I am new with R and I need your help. I'm trying to read a file which contests are similar to this: A B C T Lengths 1 4.0 0.0015258789 18 c(1,2,3) 1 1.0 0.0017166138 24 c(1,1,4) So all the columns are numeric values, except Lengths, which is supposed to be an variable length array of integers. How can I make R read them as arrays of integers?
2012 Oct 18
1
Getting a table of coefficients from R
Hi,? I'm trying to obtain a table of coefficients and confidence intervals from a logistic regression analysis in R. My code is as follows: # read in csv file datafile<-read.csv("file.csv", row.names=1) # read in the variable list varlist<-names(datafile)[66:180] models<-lapply(varlist, function(x) {glm(substitute(outcome ~ i, list(i=as.name(x))), data=datafile, family =
2010 Oct 12
1
Help with function writing
Hello all I have what seems like a simple question but have not been able to find an answer on the forum. I'm trying to define a function which involves regression models and a large number of covariates. I would like the function to accept any number of covariates and, ideally, I would like to be able to enter the covariates in a group (e.g. as a list) rather than individually. Is there any
2004 May 14
2
Help needed with bri-stuff.0.02. slw91 k2.6.5
Running slackware 9.1 with compiled kernel from source 2.6.5 running ok. I have 2 HFC-S chipbased Billion Bipac PCI ISDN BRI cards installed in PC. Would like to use one card as in TE and one in NT mode. System works fine running pbx4linux.But want to use SIP functionality, so I would like to try out the Asterisk. Trying to install the bri-stuff.0.0.2.tar.gz (May 10 2004)package, getting the