similar to: dynamic argument names and values as variables inside a loop

Displaying 20 results from an estimated 2000 matches similar to: "dynamic argument names and values as variables inside a loop"

2008 Apr 03
2
iterative loop with user input?
Hello R-Users, I would like to use an iterative loop to collect user input from within a function. I'm sure that this would be some combination of "for","break", and "next" but have not been able to get the syntax down. I would like to print some text to the screen at each step in the loop, ask the user for input which is saved in an object, and then advance the
2007 Jun 18
3
String manipulation, insert delim
Hello All, I've been using R for two years now and I am happy to say this is the first time I could not find the answer to my problem in the R-help archives. Here is the pending problem: I want to be able to insert delimiters, say commas, into a string of characters at uneven intervals such that: foo<-c("haveaniceday")#my string of character bar<-c(4,1,4,3) # my vector of
2007 Dec 20
2
factor manipulation: edgelist to a matrix?
Hello All, I have had considerable bad luck with attempting the following with for loops. Here is the problem: # Suppose we have a data.frame with the following data, which can be considered a type of edgelist (for those with networks backgrounds): # # V1 V2 # 1 A # 1 A # 1 B # 2 A # 3 C # 3 A # 3 C # 3 B # # I want the output of the function to produce a matrix, such that #each factor of
2018 Jun 18
2
incomplete results from as.character.srcref() in some cases involving quote()
Hi, The result of as,character() on 'srcref' objects doesn't have the closing ')' in some cases involving 'quote': > e4 <- quote({2+2}) > class(attr(e4, "wholeSrcref")) [1] "srcref" > as.character(attr(e4, "wholeSrcref")) [1] "e4 <- quote({2+2}" As a result printing the object also lacks it and gives an
2018 Jun 20
0
incomplete results from as.character.srcref() in some cases involving quote()
wholeSrcref attribute is documented in ?parse to be the source reference corresponding to the already parsed text. The implementation in the parser matches the documentation - the code stops at the last byte/character of the expression, that is, on the closing brace - which is the "already parsed text". I think this works as documented (also source() uses the current implementation
2011 Sep 12
2
Automated generation of combinations
Hello,   I'd like to generate automatically all the possible combinations of a set of 8 variables (there are 535, too many to do it by hand). For example:   input: varA, varB, varC output: varA+varB+varC             varA+varB             varA+varC             varB+varC             varA             varB             varC Is there any function that produces this option?   Thank you [[alternative
2008 Mar 16
2
How to loop through all the columns in dataframe
Hi: Can anyone advice me on how to loop and perform a calculation through all the columns. here's my data xd<- c(2.2024,2.4216,1.4672,1.4817,1.4957,1.4431,1.5676) pd<- c(0.017046,0.018504,0.012157,0.012253,0.012348,0.011997,0.012825) td<- c(160524,163565,143973,111956,89677,95269,81558) mydf<-data.frame(xd,pd,td) trans<-t(mydf) trans I have these values that I need to
2012 Jan 01
1
How to pass in a list of variables as an argument to a function?
Hello, I have some code that currently works fine and I am endeavoring to convert the major pieces of it into functions. This involves taking "hard coded" names of variables that are used in various places and figuring out how to abstract them out into functions where the arguments (i.e. a list of variables)?can be passed to the parent function and used within that function for various
2011 Aug 03
1
Coefficient names when using lm() with contrasts
Dear R Users, Am using lm() with contrasts as below. If I skip the contrasts() statement, I get the coefficient names to be > names(results$coef) [1] "(Intercept)" "VarAcat" "VarArat" "VarB" which are much more meaningful than ones based on integers. Can anyone tell me how to get R to keep the coefficient names based on the factor levels
2007 Dec 07
5
Grouping by interval
Hello, I have a dataframe of say 20 lines with one line per individual. I want to group these 20 individuals by length class (eg. of 5cm) and get the mean value of all the other variables (eg VarA and VarB) for each length class My dataframe is as follow: Length <- 10:30 VarA <- seq(1000,1200,10) VarB <- seq(500,700,10) Data <- cbind(Length,VarA,VarB) And I want to get something
2004 Dec 21
3
R code for var-cov matrix given variances and correlations
Dear list members, Where can I find code for computing the p*p variance-covariance matrix given a vector of p variances (ordered varA, varB, ..., varp) and a vector of all possible correlations (ordered corAB, corAC, ..., corp-1,p)? I know that the covariance between 2 variables is equal to the product of their correlation and their standard deviations: corAB * varA^.5 * varB^.5 and so:
2011 Jun 16
0
Update: Is there an implementation of loess with more than 3 parametric predictors or a trick to a similar effect?
Dear R developers! Considering I got no response or comments in the general r-help forum so far, perhaps my question is actually better suited for this list? I have added some more hopefully relevant technical details to my original post (edited below). Any comments gratefully received! Best regards, David Kreil. ---------- Dear R experts, I have a problem that is a related to the question
2017 Dec 11
1
possible bug in utils::removeSource - NULL argument is silently dropped
Dear R-Core Team, I found an unexpected behaviour in utils::removeSource (also present in r-devel as of today). --- # create a function which accepts NULL argument foo <- function(x, y) { if (is.null(y)) y <- "default foo" attr(x, "foo") <- y x } # create a function which utilizes 'foo' testSrc <- function() { x <- 1:3 x <- foo(x,
2008 Oct 29
0
reporting interactions of factors in linear mixed effects models
Hi, I have a question about how I should report the results for a linear mixed effects model where the model includes as predictors three factors (facA, facB and facC), one of which (facA) interacts with the other two. facA and facB have two levels and facC has 3 levels. There are also several other continuous predictors (e.g. varA, varB, varC). My mixed model is specified with the following
2012 Jul 18
1
fitting several lme sistematically
Dear R-list, I have a data set (in the following example called "a") which have: one "subject indicator" variable (called "id") three dependent variables (varD, varE, var F) three independent variables (varA, varB, varC) I want to fit 9 lme models, one per posible combination (DA, DB, DC, EA, EB, EC, FA, FB, FC). In stead of writting the 9 lme models, I want to
2007 Sep 28
1
fitted values in LMER for the fixed-effects only
Hi, I would like to extract the fitted values from a model using LMER but only for the fix portion of the model and not for the fix and random portion (e.g it is the procedure outpm or outp in SAS). I am aware of the procedure fitted() but I not sure it give the fitted values both for the fixed and random or only the fixed. I looked in the r help and the r list and I haven?t not found much
2011 Jan 05
2
convert expressions to characters
Hi, Suppose I have x = parse(text = " {y=50+50+50#'asfasf' } ") now x is an expression with some src attributes. > x expression({y=50+50+50#'asfasf' }) attr(,"srcfile") <text> attr(,"wholeSrcref") {y=50+50+50#'asfasf' } My question is, how can I get my string back (the string passed to parse() as the text argument)? >
2005 Oct 30
1
smbmount codepage/iocharset settings vs NT4
Hi, I'm in the process of setting up a backup server for a somewhat antiquated NT4 server. Backup server is CentOS-4 (~ RHEL-4), kernel-2.6.9-11.EL, samba-client-3.0.10-1.4E, rsync-2.6.3-1, LANG=en_US.UTF-8. NT4 shares are mounted on the server and rsynced to local disk. This setup is working pretty well, however on the NT box there are some files with names containing odd characters like
2004 Nov 01
1
plot time series / dates (basic)
Dear R users, I'm having a hard time with some very simple things. I have a time series where the dates are in the format 7-Oct-04. I imported the file with read.csv so the date column is a factor. The series is rather long and I want to plot it piece by piece. The function below works fine, except that the labels for date are meaningless (ie 9.47e+08 or 1098000000 - apparently the number of
2018 Oct 15
0
sys.call() inside replacement functions incorrectly returns *tmp*
Hi, Agreed that it would be better if sys.call() were to return "x" instead of "*tmp*", as it behaves as a local variable. Although I'm not sure what problem it would solve, the effect here is comparable to what happens when calling a function indirectly (although then you could use sys.call(2), which here doesn't work). But your other suggestion, accepting