similar to: creating tables with replacement

Displaying 20 results from an estimated 10000 matches similar to: "creating tables with replacement"

2017 Oct 18
0
creating tables with replacement
Hi maybe there is another more elegant solution but something like this > idx <- 1:nrow(dat1) > lll <- split(idx, dat1$group) > dat1[unlist(lapply(lll, sample, rep=TRUE)),] gives you selected rows. You could use for cycle or save those data frames manually Cheers Petr > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Marna
2017 Oct 18
1
creating tables with replacement
Building on Petr's suggestion, you could modify his code to get all 10 samples at once in a compact format: > Samples <- lapply(lll, function(x) replicate(10, sample(x, rep=TRUE))) # Samples is a list containing 3 matrices, one for each group # Each column gives the index (row) numbers for a particular sample > str(Samples) List of 3 $ A: int [1:3, 1:10] 2 1 3 1 1 3 2 3 1 2 ... $
2017 Aug 23
2
strange nlme augpred behaviour
Dear all I encountered strange behaviour of augPred with virtually the same data First I made groupedData object. > mar.g<-groupedData(rutilizace~doba|int, data=mar) When I perform nlme on complete dataset I get an error with augPred > fit<-nlsList(rutilizace~SSasymp(doba, Asym, R0, lrc), data=mar.g) Warning message: c("1 error caught in nls(y ~ cbind(1 - exp(-exp(lrc) * x),
2018 Mar 12
1
Help on Aggregation
Dear All, 1.I have been trying to aggregate my data but I have not been getting it correctly. In the data I want to convert hourly data into daily averages. Here is a sample of the data: Neph_no Date Time Temp_C Pressure_kPa RH 9 2014/03/28 10:00:00 38.4 95.9 29.7 9 2014/03/28 11:00:00 37.8 95.8 29.2 9 2014/03/28 12:00:00 36.7 95.8 35.1 9 2014/03/28 13:00:00 35.4 95.8 38.9 9
2017 Aug 23
2
strange nlme augpred behaviour
Hi Well, yes I tried it about two weeks ago but my post did not get through as it still awaits moderator approval. I could check which column is offending but actually it is only minor nuisance, I can live with selection of columns before fitting a model. What seems to me strange is that both full dataset and only selected colums gave me identical fit results but only one works within augPred.
2017 Aug 23
0
strange nlme augpred behaviour
Better posted on r-sig-mixed-models , no? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Aug 23, 2017 at 5:17 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote: > Dear all > > I encountered strange
2017 Oct 20
1
Error messages using nonlinear regression function (nls)
Hi Keep your messages in the list, you increase your chance to get some answer. I changed your data to groupedData object (see below), but I did not find any problem in it. plot(wlg) gives reasonable picture and I am not such expert to see any problem with data. Seems to me, that something has to be wrong with nlsList function. > wheat.list <- nlsList(Prop ~ SSlogis(end,Asym, xmid,
2017 Oct 20
1
create a loop
Hi R Users, I do have very big data sets and wanted to run some of the analyses many times with randomization (1000 times). I have done the analysis using an example data but it need to be done with randomized data (1000 times). I am doing manually for 10000 times but taking so much time, I wonder whether it is possible to perform the analysis with creating a loop for many replicated datasets?
2017 Aug 24
0
strange nlme augpred behaviour
> On Aug 23, 2017, at 8:08 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote: > > Hi > > Well, yes I tried it about two weeks ago but my post did not get through as it still awaits moderator approval. It got through just fine. It appeared on Aug 15. It just didn't get any replies. As I read your original question in this thread, it was not clear to me that you had
2017 Jul 10
0
dplyr help
Hi something like dcast(temp2, minuty~pokus) ? > dput(temp2) structure(list(pokus = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L ), .Label = c("T42", "T43", "T44", "T45", "T46", "T47", "T48", "T49"), class = "factor"), minuty = structure(c(2L,
2017 Jul 10
4
dplyr help
HI all, Is it possible to use one column spread on multiple columns values. example spread( Key_col, value1:value7) spreading Key_col to variable value1, value2, ....... Value7 Please advise, Kind regards Mangalani Peter Makananisa (5786) South African Revenue Service (SARS) - HO +2782 456 4669 / +2712 422 7357 Please Note: This email and its contents are subject to our email legal notice
2017 Nov 09
2
weighted average grouped by variables
Hi Thanks for working example. you could use split/ lapply approach, however it is probably not much better than dplyr method. sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles)) gives you averages aggregate(mydf$n_vehicles, list(mydf$type), sum)$x gives you sums Cheers Petr > -----Original Message----- > From: R-help
2017 Nov 11
0
weighted average grouped by variables
> On 9 Nov 2017, at 14:58, PIKAL Petr <petr.pikal at precheza.cz> wrote: > > Hi > > Thanks for working example. > > you could use split/ lapply approach, however it is probably not much better than dplyr method. > > sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles)) > gives you averages > The
2017 Nov 22
1
mystery "158"
Well, ?factor does not say anything about this behaviour (assigning numeric code instead of level of factor). And actually if you do assignment for whole vector the result is different (vector in data frame is changed to factor). > temp2$fff[1]<-vec[1] > head(temp2,2) pokus minuty fff 1 T42 240 3 2 T42 300 <NA> > temp2$fff<-vec > head(temp2,2) pokus
2017 Nov 21
0
mystery "158"
Your data frame fam contains factors. Turn it into character strings using fam$Family = as.character(fam$Family) and try again. It may be helpful if you read up on R's factors, see ?factor. HTH, Peter On Tue, Nov 21, 2017 at 2:14 PM, Glen Forister <gforister at gmail.com> wrote: > This is a simple problem, but a mystery to me. > I'm trying to grab $Family
2017 Nov 21
2
mystery "158"
This is a simple problem, but a mystery to me. I'm trying to grab $Family "Scelionidae" from one dataframe and put it into another dataframe occupied with NA in $Family. The result is a "158" ends up there instead of Scelionidae. Simply put fam$Family[1] <- least$Family[1] If I have made a mistake here, can somebody point it out. I've included the simple
2017 Nov 09
4
weighted average grouped by variables
hi all I have this dataframe (created as a reproducible example) mydf<-structure(list(date_time = structure(c(1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000), class = c("POSIXct", "POSIXt"), tzone = ""), direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class =
2018 May 29
2
Convert daily data to weekly data
Dear all, I have daily data in wide-format from 01/01/1986 to 31/12/2016 by ID. I would like to convert this to weekly average data. The data has been generated by an algorithm. I know that I can use the lubridate package but that would require me to first convert the data to long-form (which is what I want). I am at a bit of loss of how to extract the date from the variable names and then
2017 Nov 09
0
weighted average grouped by variables
Hello an update about my question: I worked out the following solution (with the package "dplyr") library(dplyr) mydf%>% mutate(speed_vehicles=n_vehicles*mydf$speed) %>% group_by(date_time,type) %>% summarise( sum_n_times_speed=sum(speed_vehicles), n_vehicles=sum(n_vehicles), vel=sum(speed_vehicles)/sum(n_vehicles) ) In fact I was hoping to manage everything in a
2017 Aug 16
5
strange behaviour read.table and clipboard
Hi Duncan The simples spreadsheet is: Put a name in the cell, let say "a1" Put number e.g. 1 below "a1" Copy the number to enough rows Select this column and press ctrl-c result is > temp<- read.delim("clipboard") > str(temp) 'data.frame': 1513 obs. of 1 variable: $ a1: Factor w/ 2 levels "1","a1": 1 1 1 1 1 1 1 1 1 1 ...