Displaying 20 results from an estimated 1000 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
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))
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 Feb 21
3
Plot Many Data to same plot
Dear all,
I have a function that for a variable number of inputs plots them to the same plot
I am doing this quite simply by
plot(seq(from=start, to=stop, length.out=np), datalist[[1]]$dataset
xlim=c(start, stop), ylim=c(0, 1), type="l")
2008 Dec 16
2
Problem assigning "NA" as a level name in a list
I want to generate a list (called "dataList" below) where each of its
levels is named. These names are assigned to nameList, which contains
all possible permutations of size two taking letters from a larger
alphabet, e.g., "aa",...,"Fd",..,"Z1",... One of these permutations is
the character string "NA". It seems that when I try to name one
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 =
2007 Dec 20
1
auto named savings (pngs & data-frames)
Hello, i only got a small problem.
i try to create automatic new dataframes, or png?s. the main problem i
got is:
how can i create automatic a new name for a file (read out by simply
"for") -
i tried to use "(paste...) but theres an errormessage, about a wrong
declination. R told it is as.character, but need as.Real.
Should i use another method than "paste"?
i tried as
2012 May 22
1
confused with indexing
Dear all,
I have a code that looks like the following (I am sorry that this is not a reproducible example)
indexSkipped<-NULL
....code Skipped that might alter indexSkipped
if (length(indexSkipped)==0)
spatial_structure<-spatial_structures_from_measurements(DataList[[i]]$Lon,DataList[[i]]$Lat,meanVector)
else