search for: splitdf

Displaying 5 results from an estimated 5 matches for "splitdf".

Did you mean: split
2018 May 19
0
Split a data.frame
Hello, Maybe something like the following. splitDF <- function(data, col, s){ n <- nrow(data) inx <- which(data[[col]] %in% s) lapply(seq_along(inx), function(i){ k <- if(inx[i] < n) (inx[i] + 1):(inx[i + 1]) data[k, ] }) } splitDF(DF, "name", split_str) Hope this helps, Rui Barrada...
2018 May 19
5
Split a data.frame
Hi, I am struggling to split a data.frame as will below scheme : DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF split_str = c('a', 'c') Now, for each element in split_str, R should find which row of DF contains that element, and return DF with all rows starting from next row of the corresponding element and ending with the preceding value of the
2005 May 17
2
cumsum on chron objects
...NA NA NA 15/10/03 16:30:05 NA NA ... and I've been trying to replace the NA's so that a date/time sequence is created starting with the preceding available value. Because the number of rows with NA's following each available date/time is unknown, I've split the data frame using: splitdf <- split(df, as.factor(df$DateTime)) so that I can later use lapply to work on each "block" of data. I thought I could use cumsum and set the NA's to the desired interval to create the date/time sequence starting with the first row. However, this function is not defined for chron...
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community, I'm working with the data.frame attached ( http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it df1. I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames= TRUE) Then I splited randomly df1 using splitdf function (http://gettinggeneticsdone.blogspot.com/2011/03/splitting- dataset-revisited-keeping.html) So now, I have df1 divided in another 2 dataframes: trainset and testset. (They both have the same row names and column names as df1) I'd like to change df1$v1 and df1$v2 values in the...
2005 Feb 03
1
Efficient selection and alteration of dataframe records
...#5. replace delsp params with params randomly selected from remaining spp: for (x in 1:length(plotdf.del$pspp)){ newsp = sample(plotdf.old$pspp, size=1);#print(newsp[1]) plotdf.del$pspp[x]=newsp[1] } #6. rbind plotdf and splitdf into plotdf, plotdf=rbind(plotdf.old,plotdf.del);plotdf[1,] #b. calculate standing crop,etc #1. merge plotdf and traitdf plotdft=merge(plotdf, traitdf, by.x ="pspp", by.y="tspp") #2. calculate crop in plotdft plotdft$crop=plotdft...