All Questions
8,998
questions
0
votes
0
answers
46
views
How can I get my for loop to work in R to count occurrences? [closed]
I am running a for loop in R for a data frame "WOS" searching in its columns "Article Title" and "Abstract" for specific terms listed in the data frame "Combined_633&...
0
votes
2
answers
53
views
Sorting columns and adding new variables using setdiff in R
I am a researcher and R novice working with a large dataset consisting of many small excel files to be read together. I have imported these into R using the read_excel functions and have them all in a ...
1
vote
2
answers
51
views
How to update for-cycle control vector from inside loop in R
I have the following dataframe
df <- data.frame(
ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20),
value = c(0, 3, 8, 10,17, 18, 20, 23, 27, 34, 43, 53, 56, 61, 67,...
0
votes
1
answer
52
views
Is there a way to loop through a custom function to generate multiple ggplot2 graphs in R?
I created a custom function in R to standardize multiple graphs. The function is essentially as follows:
CustomFunction <- function(SpecificEvent) {
ggplot()+
geom_point(data = df[df$...
0
votes
1
answer
65
views
How to check if elements of one list are also elements of another list in R
Let's assume I have two lists in R, a long one and a shorter one, for example:
list1 = list(571,572,573,574,561,562,563,564,595,570,571,573)
list2 = list(c(571,564,565,600))
Please note that numbers ...
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
2
answers
31
views
Export to html from cells on a dataframe using R and name the files according to content from another cell
I would like to export content from cells in a dataframe into separate html files. I would also like to name the files according to the corresponding cell in another column, but cannot make it work.
I ...
0
votes
0
answers
12
views
Custom function to create sequential index variable in longitudinal data [duplicate]
This is probably very basic but I'm having a hard time finding an answer to my question in existing posts. I'm working with longitudinal data and need to create a sequential index variable that ...
0
votes
2
answers
34
views
Loop in r with subset makes incomplete selection
I have a data frame (words) containing words with five letters, in which each letter appears in one of five columns. The sixth column represents the log probability of the word based on letter ...
-1
votes
1
answer
40
views
How can I select a value from one dataframe based on two other values in another dataframe
From the following two dataframes, I want to substitute all data$code columns with the corresponding code$atc_code. To do this, the data$name value should correspond with code$med_name, and the data$...
1
vote
1
answer
59
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
47
views
For loop returning same value in r
I'm trying to loop through a list of stocks in the and calculate the minimum for each stock and then place that into a separate list. I've looked up similar issues, but none seem to solve the problem ...
0
votes
1
answer
69
views
How can I go through all possible numbers in one loop?
I am quite new with R and trying to turn a larger SpatRaster into SpatVector.
Unfortunately using
vec <- as.polygons(raster)
I get Error: [as.polygons] the raster is too large
So I figured I can ...
0
votes
2
answers
51
views
For loop ggplot not working- plotting same plot [closed]
I am trying to use the followig code to plot several columns of frequency data into histograms.
colsToPlot <- c(61,63,65,67,69,71,73,75)
for (i in 1:length(colsToPlot)){
Outcome = ResearcherData[,...