All Questions
9,644
questions
1
vote
1
answer
58
views
Loop models multiple times
I am trying to run the following code multiple times with different values for the 'aux' object.
time <- seq(0, 30, 1)
stock <- c(sK=0, sF=1)
aux <- c(aH=0.4, aRel=0.5, aRes=0.5, aS=0.8)
...
1
vote
1
answer
29
views
Pass element form character vector in loop to function and use in assign
I have a function that chooses, reads and formats Excel reports from Workday, and produces data.frames. I've simplified for purposes of begging for your help. :-)
In the function, I pass a parameter ...
0
votes
2
answers
36
views
Is there an easy way to separate out model coefficient values into different variables?
I am looking to simplify the following:
> model$coefficients
(Intercept) x1 x2 c
-1.51730659 0.28487690 0.10034603 0.08629699
b0_i = model$coefficients[1]
...
0
votes
1
answer
31
views
Error in eval(substitute(list(...)), `_data`, parent.frame()) : object 'start_lat' not found
I am a really new R programming user and I am trying to figure this problem out. I am trying to use a loop to go through a list of tables that I imported and am trying to clean. I am trying to set 4 ...
-1
votes
1
answer
26
views
Loop over multiple regressions to store clustered standard errors [closed]
I need a loop to generate the clustered std. errors for several lm-s. The models are named m1_1 …m1_7. To export the results with stargazer I need a vector with the clustered std. errors for every ...
-1
votes
0
answers
32
views
Loop over enumerated dataframes and adding new column [closed]
I would like to run a loop over my dataframes which are enumared and add to each dataframe a new column with the same numbering of dataframes.
Here an example:
/*dataframe */
df2001
df2002
df2003
/...
1
vote
1
answer
38
views
Adding conditions to loop to generate class intervals using ClassInt in R for areas with fewer n classes
I have issues with assigning classes to intervals that dont meet the criteria in my loop function using the classInt library in R. How do a include a condition for an automatic class if the rows in ...
0
votes
1
answer
32
views
R: looping over variable names [duplicate]
I have a dataframe that is an ID variable and a bunch of date variables. There's a lot of missing data, and I want to convert any date value to a 1, and leave the missing values as-is. I don't care ...
0
votes
1
answer
51
views
Making a Loop function and table in R
*How can I change the following code to compute D for various values of r and display all D values corresponding to r in a table?
library(powerSurvEpi)
r=seq(from = 0, to = 1,by=0.1)
D <- numDEpi....
0
votes
3
answers
41
views
Create new column and add row value based on string in existing column using data.table [duplicate]
Because I can't quite find what I am looking for on stack, I decided to write my first question! If I do something wrong, apologies in advance.
I work with large datasets which I cannot share ...
2
votes
4
answers
58
views
modify/create column based on groups defined externally
I have a predefined list containing a list of items as below:
group_1<-c("A","B","C")
group_2<-c("D","E","F")
item<-c("A"...
0
votes
2
answers
46
views
Adding a counter for the position of a record in a R dataframe in a "for" loop
I have some code that runs a sports league table standings simulation, using a "for" loop in R. For each iteration of the loop, a table of standings (i.e. a dataframe) df is produced like ...
1
vote
1
answer
58
views
How can I use 2 for loops together (one for each year and one for each day)?
I think I calculated correctly the average distance between three consecutive values when the condition (described in the code) is met. However, I did this calculation only for a single year and I don'...
0
votes
2
answers
30
views
How to get a value from a column from a dataframe if the id is present in multiple columns in another dataframe?
I have 2 dataframes, df1 which are ID numbers of participants (some have more than one ID but is the same person)
df1 <-data.frame(hospid_1=c("A", "B", "C"),
...
0
votes
1
answer
41
views
R: passing foreach loop number (i) to an object and then passing that object to a function
In R,
I'm attempting to run the following foreach loop in parallel using the doFuture package
For some reason the loop number (i) is not being passed to set the object "Current_File"
(I ...