similar to: Dynamic reference, right-hand side of function

Displaying 20 results from an estimated 2000 matches similar to: "Dynamic reference, right-hand side of function"

2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi! Thanks for the replies! I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The syntax from Peter Dalgaard was really clever, and I learned a lot from it, even though it didn't solve my problem (I guess it wasn't very well explained). My problem was basically that I have a data matrix
2017 Dec 04
0
Dynamic reference, right-hand side of function
The generic rule is that R is not a macro language, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_", 2000:2007) datalist <- lapply(datanames, get) names(datalist) <- datanames col1 <- lapply(datalist, "[[", 1) colnum <- lapply(col1, as.numeric) (The 2nd
2017 Dec 04
0
Dynamic reference, right-hand side of function
Um, if you insist on doing it that way, at least use assign(varname, as.vector(get(varname))) -pd > On 4 Dec 2017, at 22:46 , Love Bohman <love.bohman at sociology.su.se> wrote: > > Hi! > Thanks for the replies! > I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The
2017 Dec 04
2
Dynamic reference, right-hand side of function
:-) I don't insist on anything, I'm just struggling to learn a new language and partly a new way of thinking, and I really appreciate the corrections. I hope I someday will be able to handle lists in R as easy as I handle loops in Stata... Thanks again! Love -----Ursprungligt meddelande----- Fr?n: peter dalgaard [mailto:pdalgd at gmail.com] Skickat: den 4 december 2017 23:09 Till:
2017 Dec 05
3
Dynamic reference, right-hand side of function
Hi again! I know you don't find loops evil (well, at least not diabolic :-) ). (After many hours googling I have realized that thinking about loops rather than lists is a newbie thing we Stata-users do, I just jokingly pointed it out). Anyway, I'm really happy that you try to teach me some R-manners. Since I still get questions about what the h**k I mean by my strange question, I sort it
2017 Dec 04
0
Dynamic reference, right-hand side of function
Loops are not evil, and no-one in this thread said they are. But I believe your failure to provide a reproducible example is creating confusion, since you may be using words that mean one thing to you and something else to the readers here. ################################ # A reproducible example includes a tiny set of sample data # Since we cannot reproducibly refer to filenames (your
2017 Dec 05
0
Dynamic reference, right-hand side of function
By the way, R 'vectors' are not the equivalents of mathematical 'vectors'. In R, a vector is something that can have arbitrary length and which has no 'attributes', other than perhaps element names. Vectors can be numeric, character, complex, lists, etc. Functions, names, and NULL are not vectors. In my opinion, the typical data scientist will rarely find the R vector
2012 Nov 08
3
Extracting columns
Hi, I have 22 files (A1, A2, ..., A22) with different number of columns, totaling 10,000 columns: c1, c2, c3, ..., c10000 I have another file with a list of 100 columns that I need to extract. These 100 columns are distributed in 22 files. How to extract the 100 columns of the 22 files? I have done it "manually" with the following commands, for example: cromo1 = read.table ("~
2012 Nov 09
1
Mean of matrices entries in list of lists
Hey there, I've got a list of lists with matrices: A list with 13 entries (representing years), each of them another list with 12 matrices (representing one month). In each matrix there are as many rows as there are hours in the different months and 2 columns, since two meteorological parameters are measured. What I want to do is to calculate the hourly mean values for each month over the
2023 Oct 19
12
[Bug 3629] New: Building with Clang-17 fails due to -fzero-call-used-regs
https://bugzilla.mindrot.org/show_bug.cgi?id=3629 Bug ID: 3629 Summary: Building with Clang-17 fails due to -fzero-call-used-regs Product: Portable OpenSSH Version: 9.5p1 Hardware: amd64 OS: Mac OS X Status: NEW Severity: critical Priority: P5 Component: Build system
2010 Jul 27
6
Eval() or parse() do not work inside function
I am writing a function where the arguments are names of objects or variable names in a data frame. To convert the strings to the objects I am using eval(parse(text=name)): f.graph.two.vbs<-function(dataname,v1){ val<-paste(dataname,v1,sep="$") val<-eval(parse(text=val)) val } However running this returns an error:
2011 Jan 21
3
confidence interval
Hi, I have a circular shaped set of point on the plane (X,Y) centered in zero. The distribution is more dense close to zero and less dense far from zero. I need to find the radius of a circle centered in zero that contains 65% of the points in the sample. Is there any R directive that can do this? I wanna start with 2D set of points, but the real case scenario is with a 5D set of points.
2011 Nov 11
1
Formula variable help
I have an R script with the following applicable lines: xshort <- window(s, start=st, end=ed) . . . xshort <- ts(xshort, frequency=1, start=1) . . . m1 <- m2 <- m3 <- m4 <- m5 <- m6 <- NULL m1 <- tslm(xshort ~ trend) I get an error: Error in get(dataname) : object 'xshort' not found When I do traceback() I get: 3: get(dataname) 2: tslm(xshort ~
2011 Sep 20
1
Data
Hey everybody, i am using the rugarch-package and its great! I have a pretty easy problem, but i just dont get it, so thanks if you can help me. Normally i use: / data(DATANAME) spec = ugarchspec() fit = ugarchfit(data = x[,1], spec = spec) fit slotNames(fit) names(fit at fit) coef(fit) infocriteria(fit) likelihood(fit) nyblom(fit) signbias(fit) head(as.data.frame(fit)) head(sigma(fit))
2013 Feb 28
11
new question
Hi, directory<- "/home/arunksa111/data.new" #first function filelist<-function(directory,number,list1){ setwd(directory) filelist1<-dir(directory) direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), full.names = FALSE, recursive = TRUE) list1<-lapply(direct, function(x) read.table(x,header=TRUE, sep =
2012 Feb 16
2
Problem building up ggplot graph in a loop.
Folks, I want to automate some graphing using ggplot. Here is my code graphChargeOffs2<-function(coffs) { ggplot(coffs, aes(levels)) dataNames<-names(coffs)[!names(coffs) == "levels"] for(i in dataNames) { thisData<-coffs[[i]] last_plot() + geom_line(aes(y = thisData, colour = i)) } last_plot() + ylab("Total Chargeoffs") } coffs is a data.frame.
2012 Dec 10
3
equivalent of group command of the egen function in Stata
Dear R listers, I am trying to create a new variable that uniquely identifies groups of observations in a dataset. So far I couldn't figure out how to do this in R. In Stata I would simply type: egen newvar = group(dim1, dim2, dim3) Please, find below a quick example to show what I am dealing with: I have a dataset with 4 variables: var <- runif(50) ## a variable that I want to group
2000 May 02
2
Variable names in model formula
At 10:37 PM 5/1/00 -0400, E. S. Venkatraman wrote: >I have the following problem. I have survival data (time, status) along >with several covariates (X1, X2,..., Xn). I want to fit a Cox model for >each of the covariate (univariately) and obtain the fitted probability of >survival at a fixed time point t0 and covariate value Xi0. I tried to do >this in a for loop where the index
2009 Oct 08
3
error message - unexpected input
I have been using R the past couple of years to run models on data we are collecting. I recently got a new computer and updated to a new version of R (2.60 -> 2.90). Since the update, I cannot get my syntax to run. I have tried copying the file it is looking for into many different directories to try and run it. In the last version, I found that it was easiest if the file was copied into the R
2008 Jul 29
4
Graphics function question
Hello I have created a graph using the following commands: <<< startBReP3O1T <- diffs$BReP3O1T - diffs$diff_BReP3O1T endBReP3O1T <- diffs$BReP3O1T x <- seq(47,89, length = 10) ymin <- min(min(startBReP3O1T), min(endBReP3O1T)) ymax <- max(max(startBReP3O1T), max(endBReP3O1T)) y <- seq(ymin, ymax, length = 10) plot(x,y, type = 'n', xlab = 'Age', ylab =