Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
114 views

Keep file names merging list with lapply? [duplicate]

I am importing several .csv files of temperature registers from a folder, and need to create a single table mergind them all, in which the first 15 lines must be skipped and the file names must be ...
Marta Román's user avatar
2 votes
3 answers
67 views

use for loop to rbind dataframes of different sizes

I'm new writing for loops, but this dataset is too large to do this one by one (though open to suggestions). I have a list of dataframes (A), and I am trying to rbind each of them to specific, ...
Evelyn Abbott's user avatar
1 vote
1 answer
89 views

Speed up R function that combines linestrings into a single linestring [closed]

I have a function that i run on a large dataset that gets incredibly slow as rows are being incorporated. Is there a better way to run this function to speed up processing time? The function combines ...
jsimpsno's user avatar
  • 460
0 votes
0 answers
42 views

Error in summary(model_component)$coefficients : $ operator is invalid for atomic vectors

there is a model.results list which has multiple elements and sub elements in it. Here using this list trying to extract certain values and convert into proper format for storing purpose. Below is ...
Trend's user avatar
  • 11
0 votes
2 answers
79 views

How to count number of rows in a data frame filtered with complete.case function?

I am working on an assignment to find the title. But I can't get the result to match exactly what the assignment requires. The iteration does count the observation in both columns, "sulfate" ...
Nubie coder's user avatar
0 votes
3 answers
62 views

Bind each dataframe in a list to each dataframe of another list

I have two lists composed of dataframes (in the example 3 dataframes per list). I would like to bind the rows of dataframes of the two lists. I was thinking to couple rbind() with Map(), map() or ...
C. Guff's user avatar
  • 478
1 vote
3 answers
106 views

R bind two data frames with different time observations

I have two data frames f1 and f2 row11 <- c("a", "c", "2000", "2001", "2005") row12 <- c("", "", 7, 10, 15) f1 <- as....
MPB_2022's user avatar
  • 303
1 vote
2 answers
51 views

how filter a dataframe to remove rows in which no column contains a value higher than X or lower than Y

I am trying to remove any rows of data that do not contain any values that are greater than 5 or less than -5 in order to exclude them from my data analysis. I could not find a way to use an OR ...
timnick23's user avatar
1 vote
0 answers
40 views

Is there a clean way to call stepfun many times to generate a matrix?

MWE: library(stats) months <- 1:12 months_plus_one <- months |> append(months[length(months)] + 1) hours_list <- lapply(months_plus_one, \(m)(stepfun(c(m), c(0, 50))(months))) hours <-...
Mohan's user avatar
  • 8,773
0 votes
0 answers
28 views

Adding second set of points to pairs2 plots

I’m hoping that there is a simple answer to this question - is there a way to plot a second set of points on top of pairs2 plots, from a second dataframe? This question was somewhat answered here ...
ASchnur's user avatar
  • 13
0 votes
1 answer
144 views

Reading JSON files in R and creating a dataset

I am trying to create a dataset in R from 3k JSON files. (This is the data: Nauman, F. (2023). Clothing Dataset for Second-Hand Fashion (Version 1) [Data set].Available at: Zenodo. https://doi.org/10....
CodeCraft's user avatar
0 votes
1 answer
35 views

Organising list() of a calculated function by descending day order within patients in R

I'm trying to calculate the time in bed (TIB) for a dataset containing a lot of data, among which the time they went to bed (inbed) and the time they got out of bed (uitbed). The code I have works in ...
froggishrock's user avatar
0 votes
1 answer
191 views

Is there an R function for binding two tables next to each other but having a title over the whole thing?

I have been using the gt package in R to create tables for a paper. I have been using rbind to stack the two tables on top of each other but would rather they are next to each other with one title ...
Kelly's user avatar
  • 3
-1 votes
2 answers
60 views

R cbind two dataframes of different length throwing error invalid 'nrow' value (< 0)

I am trying to cbind two dataframes of different lengths. Category = c("New", "New","New","New","Old","Old","Old","Old", ...
Sam's user avatar
  • 550
3 votes
2 answers
65 views

R How to calculate the sum of existing rows to add new rows of data

How do i add a new Category into comb_df where the value of this new newcat is sum of Category = New Jan 2014 + Category = Old Jan 2014 Category = c("New") value = c(4,7,6) Date= c ("...
Sam's user avatar
  • 550
0 votes
0 answers
46 views

merging .csv files with different number of variables in R

I have an R code which takes a set of .csv files and put all of them together. files <- list.files() for(i in 1:length(files)) assign(files[i], read.csv(files[i],header=F,stringsAsFactors=F,na....
ajestudillo's user avatar
0 votes
1 answer
91 views

Why does rbind change one value when appending to a data frame?

I am working with vectors of datetimes and time zones. A few of the time zones were recorded incorrectly and I want to adjust the times to fit the correct time zone. I want to output a data frame. ...
user23451421's user avatar
0 votes
0 answers
57 views

Creating function to group data with %like% pipeline giving errors

I am trying to create a function that will take data with a description column, match a phrase in that column (using %like% from the data.table package), and add a grouping variable with a group name. ...
Elizabeth Wallace's user avatar
2 votes
4 answers
107 views

Why does R colnames ignore the vector with specified names and only pay attention to the index?

I came across some weird behavior in R. Imagine that I have this data frame, and I want to change the names of the columns by using colnames and a vector: df <- data.frame(a = seq(1,10), b = seq(11,...
mauraeh's user avatar
  • 37
2 votes
1 answer
238 views

Convert nested lists to a dataframe in R

My goal is to convert the nested lists produced by my code into a dataframe. I have the following which extracts some data from several urls in a loop and stores them in lists. library(rvest) library(...
Michael's user avatar
  • 345
1 vote
1 answer
64 views

Fast way to create dataframe in a rbind() style

I have two survey datasets I'm working with. The first one (survey1) is a population/household survey (like the American CPS or the European EU-SILC) with around 150,000 observations; the second one (...
Joao Francisco Cabral Perez's user avatar
1 vote
2 answers
42 views

rbind 2 data frames by the elements in 2 columns, avoiding nested loops

I have two data frames like the following: df1 <- data.frame(Marker1=c('+','+','+','-','-'), Marker2=c('+','+','+','+','-'), Marker3=c('+','-','+','-','+'), Sample=c(1,1,2,3,3), ...
DaniCee's user avatar
  • 3,197
0 votes
2 answers
103 views

How to improve the speed of rowbinds when the size of the final dataframe is unknown

I want to rowbind multiple dataframes each with a varying number of rows. I understand that using a for loop in which something like a final_df is overwritten in each iteration is very slow as R has ...
degeso's user avatar
  • 181
1 vote
2 answers
78 views

c-/r-bind from a list of data tables w/o recycling and w/ using list names as part of col names

there many post which shed some light on individual parts of my problem but I can't puzzle it together and need help. I'm trying to bind many data tables with varying row-count but identical column-...
MarkH's user avatar
  • 320
0 votes
2 answers
178 views

rbindlist with different variable names / positions in R: Creating an output dataframe/file

I have a question that is a combination of two different posts. Combine (rbind) data frames and create column with name of original data frames Compare the column names of multiple CSV files in R I am ...
Eric Boorman's user avatar
1 vote
0 answers
82 views

Missing data files in R

I use R bind to combine multiple files into 1 df. When I close R, about 6 of those files disappear from my environment. The code is still saved with those file names in the script where I type the ...
Gillian Michalczyk's user avatar
0 votes
1 answer
55 views

Using for loop to combine a filter and rbind to a new data frame

Raw file I have data as shown in the image, I want to filter the data by the year column, while ensuring that the months are continuous as in the picture below filtered file, the format I want I ...
NeverLate's user avatar
2 votes
1 answer
95 views

I want to rbind 2 rows but without overlapping rows in R

I have data1 and data2. data1 <- data.frame(date = c(123, 124, 125, 126), peter = c(10, 11, NA, NA), turner = c(20, 21, NA, NA)) data2 <- data.frame(date ...
Lee's user avatar
  • 369
1 vote
1 answer
51 views

Modify the code of dataframes for multiple txt files

Following code is for dataframes df1, df2. The code is reading the data columns (var) and look in each dataframe, if the var column is not present, it adds it and put NA in that particular column. ...
Alexia k Boston's user avatar
0 votes
2 answers
143 views

Unable to obtain: Columns missing in one input file but present in other files should return NA in output file

I have various txt files, where each file contains multiple columns but not all columns are present in all the files. For example, Columns of Txt File1 D/T City_Name Temp Pres Wind_Hor Wind_Ver ...
Alexia k Boston's user avatar
0 votes
0 answers
56 views

How to add a new column in output csv with name derived from input file?

I have multiple txt files stored in different folders. 1 folder for each city. Each txt file contains data at an interval of 5 minutes. I run following code to obtain daily data successfully. for (idx ...
Alexia k Boston's user avatar
0 votes
1 answer
37 views

do.call(rbind, ... ) exhibits unexpected behaviour inside a loop

I'm trying to download some data and have the following library(RJSONIO) first.day <- as.Date(paste0("202201","01"), "%Y%m%d") today <- Sys.Date() months <- ...
Illimar Rekand's user avatar
0 votes
2 answers
53 views

how to extract rows which match based on two conditions from two dataframes

I have two dataframe one is snp region and other is Hic region. dput(hic_region[1:15,1:4]) structure(list(rf1 = c(57584944, 57584944, 57584944, 57584944, 57584944, 57584944, 57584944, 57584944, ...
Rhea Bedi's user avatar
  • 129
0 votes
1 answer
136 views

How to use Rbind when datasets I am using have different names in the variables, but they each mean the same thing

I am having a hard time combining these datasets and it's because the names of the variables are different. How would I do this? [I want to combine this, but the response I get from R is "Error ...
Bpop Vroom's user avatar
0 votes
1 answer
126 views

How to match column names across two dataframes and add a new variable?

data <- rbind(c(1,2,3,4,5,6), c(1,2,3,4,5,6), c(1,2,3,4,5,6)) colnames(data) <- c("A", "B", "C", "D", "E", "F&...
Jak Carty's user avatar
0 votes
1 answer
57 views

how to select rows in which there is more than 1 value across columns

I have a dataframe: dput(gene1[1:5,1:5]) structure(list(en_Adipose_Subcutaneous.db = c(0.0531016390078734, -0.00413407782001034, -0.035434632568444, 0.00968736935965742, 0.0523714252287003), ...
rheabedi1's user avatar
-1 votes
1 answer
25 views

Combine more than 3 data.frames while keeping the extra-rows from the master file that didn't match

I have the following data.frame "A" in R: ID 1 456 200 550 110 and the following data.frame "B" defined in R ID Interaction Student Date 1 email_sent Isabel Gauss 10/20/...
jsaab's user avatar
  • 15
1 vote
1 answer
60 views

error while using rbind function in R: add the same rows multiple times

I have a dataframe in R: dput(trans_eqtl[1:5,1:6]) structure(list(Gene = c("ENSG00000166086", "ENSG00000166086", "ENSG00000265688", "ENSG00000265688", "...
rheabedi1's user avatar
0 votes
1 answer
110 views

rbind two different data frames that have different column names

I want to rbind two different data frames that have different column names DF1 has 4 columns Year Month Prec_CAN_45 Prec_CAN_85 2015 Jan 0.5 0.65 2100 Jan 0.6 0.75 DF2 has 3 columns Year Month ...
Sana's user avatar
  • 87
0 votes
2 answers
49 views

Is there a way to stack dataframes in an rbind fashion where there is a single different column name in R

Is there a way to stack dataframes in a row wise fashion. Consider the following code motors <- c("audi", "honda", "ford") age <- c(1, 2, 3) motors1 <- motors ...
TheBoomerang's user avatar
0 votes
3 answers
212 views

Want to use grep to get dataframe names from environment and then stack the rows with rbind function in R

I have thousands of dataframes and want to grep their names into a character vector. Then use the vector to complete the rbind function. Any suggestions? dat1lkq6 <- data.frame(color = c('COLOR: ...
seehorse's user avatar
0 votes
0 answers
1k views

How to merge two different vcf files with different samples' number on R?

I have two different vcf files with snps from different samples (119 samples in vcf file n1 and 21 in vcf file n2).I'd like to have a single vcf file with same meta and combined fixed and gt region. I ...
ALESSANDRA's user avatar
1 vote
2 answers
464 views

Append same values to multiple columns of a data.frame

I have a short vector of values: five_values <- (c("17", "93", "119", "399", "439")) and a dataframe: df <- data.frame("Col1" = ...
Peter Thwaites's user avatar
1 vote
1 answer
235 views

Combining two data frame date columns into one column - in order

My temperature data had missing values that I needed to fill in, however when I went to rbind the new Date values from the newly made dataframe of missing dates, it ended up on the bottom of the ...
EcoQuestions's user avatar
0 votes
0 answers
33 views

Keep the identifier for each row in a rolling window of functions R

I have managed to apply a rolling window of functions per column of my accelerometer data where each row is associated with a behaviour. However, the output doesn't include the behaviour associated. ...
mari davies's user avatar
0 votes
2 answers
42 views

In R, rbind dataframes repeting only some elements

I have 4 dataframes (df, df1, df2 and df4) and I want to create df3. df <- data.frame( Date = c("28/04/2010", "26/09/2010"), HolidayType = c("MUNICIPAL", "...
CelloRibeiro's user avatar
0 votes
1 answer
68 views

Condensing wide dataframe with columnwise operations

I'm still learning R and was wondering if I there was an elegant way of manipulating the below df to achieve df2. I'm not sure if it's a loop that is supposed to be used for this, but basically for ...
bilmawr's user avatar
  • 51
1 vote
1 answer
56 views

feeding a list of objects to rbind.fill

I have a large number or tables in the environment I wish to bind into a single table. There are many tables in the environment, but all the ones I want to bind are similarly named ending in "...
xtufer's user avatar
  • 169
0 votes
0 answers
39 views

how to keep on adding rows to the dataframe

I am running a loop through all the genes present in my datasets and creating a matrix. The matrix columns is 49 and rows will depend upon rsid. I want to create one big matrix in which all the genes ...
rheabedi1's user avatar
0 votes
1 answer
101 views

Create clean data frame in R from list generated by ocr

I have a table I imported into R using the ocr function from tesseract which I need to format into a table that can be used to create graphical representations from. I have done a bunch of different ...
data_life's user avatar
  • 399

1
2 3 4 5
19