similar to: subset() wish: allow "select" for non-dataframes

Displaying 20 results from an estimated 20000 matches similar to: "subset() wish: allow "select" for non-dataframes"

2009 May 25
2
apply fn to many dataframes
Hi, Say I have dataframes d1, d2, ... , dn, and I want to apply a function to all of them. For example, say I want to change the name of the second variable in each dataframe to "x2". The following doesn't work: a = list(d1,d2,d3,d4) lapply(a,function(x) names(x)[2] = "x2") What would work? Thanks for any help.
2008 Jun 03
3
How to solve a non-linear system of equations using R
Dear R-list members, I've had a hard time trying to solve a non-linear system (nls) of equations which structure for the equation i, i=1,...,4, is as follows: f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0 (1) In the expression above, both f_i and k_i are known functions and l, m and s are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4) which is solution
2009 Feb 22
2
how to recover a list structure
I am experiencing some problems at working with lists at high level. In the following "coef" contains the original DWT coefficients organized in a list. Thorugh applying the following two commands: coef.abs <- lapply(unlist(coef,recursive=FALSE,use.names =TRUE),abs) coef.abs.sorted <- sort(unlist(coef.abs),decreasing=TRUE) I get vector "coef.abs.sorted" containing
2017 Jun 23
4
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
For certain reason, the content was not visible in the last mail, so posting it again. Dear Members, I have two different dataframes with a different number of rows. I need to apply a set of functions to each possible combination of rows with one row coming from 1st dataframe and other from 2nd dataframe. Though I am able to perform this task using for loops, I feel that there must be a more
2010 Sep 14
3
extracting objects from lists
If you have 5 data frames and you append them to a list, how do you access the first data frame, not the first value of the first data frame while iterating in a for loop? list = c(d1,d2,d3,d4,d5) where d1..d5 are dataframes. for(i in 1: length(list)){ print(list[1]) } -- View this message in context: http://r.789695.n4.nabble.com/extracting-objects-from-lists-tp2539412p2539412.html Sent from
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, The obvious way would be to preallocate the resulting data.frame, to expand an empty one on each iteration being a time expensive operation. n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D4 <- data.frame(distance=integer(n),difference=integer(n)) k <- 0 for (i in 1:nrow(D1)){ for (j in 1:nrow(D2)) { k <- k + 1 D4[k, ] <-
2011 Jan 15
2
Rounding variables in a data frame
Hi All I am trying to use the round function on some columns of a dataframe while leaving others unchanged. I wish to specify those columns to leave unchanged. My attempt is below - here, I would like the column d3 to be left but columns d1, d2 and d4 to be rounded to 0 decimal places. I would welcome any suggestions for a nicer way of doing this. d1= rnorm(10,10) d2= rnorm(10,6) d3=
2007 Aug 29
1
Plot command drops part of the plot for large plots in multiple figure environment
I have run into some surprising behaviour when plotting data in a 3x2 grid: random parts of the data on my graphs aren't rendered. Not on screen, not on file, and not when I send the plot to a printer. I don't get any error messages either. When I do the individual plots (not in a grid) they are each rendered correctly. My questions are: - Has anyone encountered something like this,
2011 Apr 21
1
Help with matching rows
Dear Sir, Please excuse my akwardness as I a new to R and computers, but would kindly appreciate help. { a <- sample (1:10,100,replace=T ) b <-sample(10:20,100,replace=T) c <- sample(20:30,100,replace=T) d <- sample(30:40,100,replace=T) e <- sample(40:50,100,replace=T) } d1 <- a d2 <- b d3 <-c d4 <- d d5 <- e data.frame(d1,d2,d3,d4,d5) dd <-
2017 Jun 23
1
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, Another way would be n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D5 <- data.frame(distance=integer(n),difference=integer(n)) D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) t(sapply(seq_len(nrow(D2)), function(j){ c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2) } )))) identical(D3, D5) In my first answer I forgot to say that
2009 Mar 20
4
how to make aggregation in R ?
Hi, I am trying to aggregate the sum of my test data.frame as follow: testDF <- data.frame(v1 = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d",
2009 Feb 09
2
How to plot multiple graphs each with multiple y variables
I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow.  The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1))
2010 Jun 14
2
Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ?
Hi R help, Hi R help, Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ? Sincerely, Andrea Bernasconi DG PROBLEM EXAMPLE I consider the latin squares example described at page 157 of the book: Statistics for Experimenters: Design, Innovation, and Discovery by George E. P. Box, J. Stuart Hunter, William G. Hunter. This example use
2011 May 17
2
Minimum value by ID
Hello, I have a longitudinal dataset where each individual has a different number of entries. Thus, it is of the following structure: x <- runif(12) id.var <- factor(c(rep("D1",4),rep("D2",2),rep("D3",3),rep("D4",3))) dat <- as.data.frame(x) dat$id.var <- id.var dat > dat x id.var 1 0.9611269 D1 2 0.6738606 D1 3
2012 Nov 22
1
Data Extraction - benchmark()
Hi Berend, I see you are one of the contributors to the rbecnhmark package. I am sorry that I am bothering you again. I have tried to run your code (slightly tweaked) involving the benchmark function, and I am getting the following error message. What am I doing wrong? Error in benchmark(d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df), : could not find function
2023 Nov 14
1
data.frame weirdness
On Tue, 14 Nov 2023 at 09:41, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > Also why should that difference result in different behavior? That's justifiable, I think; consider: > d1 = data.frame(a = 1:4) > d2 = d3 = data.frame(b = 1:2) > row.names(d3) = c("a", "b") > data.frame(d1, d2) a b 1 1 1 2 2 2 3 3 1 4 4 2 > data.frame(d1,
2009 Jul 20
1
Regression function lm() not giving proper results
* * Hi , Can anyone help me please with this problem?* * *CASE-I* all_raw_data_NAomitted is my data frame.It has columns with names i1 ,i2, i3,i4…, till i15.It has 291 rows actually ,couldn’t show here. The data frame looks like this:-- i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 2 2 2 2 2 2 2 2 2 2 2 1 2 2 3 2 3 2 2 2 2 3 2 2 3 3
2023 Nov 14
1
data.frame weirdness
Also why should that difference result in different behavior? On Tue, Nov 14, 2023 at 9:38?AM Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > In that case identical should be FALSE but it is TRUE > > identical(a1, a2) > ## [1] TRUE > > > On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar > <deepayan.sarkar at gmail.com> wrote: > > > >
2010 Jul 19
3
invalid type error
>myDF = data.frame(id=c("A10","A20"),d1=c(.3,.3),d2=c(.4,.4),d3=c(-.2,.5),d4=c(-.3,.6),d5=c(.5,-.2),d6=c(.6,-.4),d7=c(-.9,-.5),d8=c(-.8,-.6)) >doit=function(x)c(x[1],sum_LK_positive=sum(x[-1][x[-1]>0]),sum_LK_negative=sum(x[-1][x[-1]<0])) > myDF id d1 d2 d3 d4 d5 d6 d7 d8 1 A10 0.3 0.4 -0.2 -0.3 0.5 0.6 -0.9 -0.8 2 A20 0.3 0.4 0.5 0.6 -0.2
2018 Jul 10
9
[PATCH 0/7] PowerPC64 performance improvements
The following series adds initial vector support for PowerPC64. On POWER9, flac --best is about 3.3x faster. Amitay Isaacs (2): Add m4 macro to check for C __attribute__ features Check if compiler supports target attribute on ppc64 Anton Blanchard (5): configure.ac: Remove SPE detection code configure.ac: Add VSX enable/disable configure.ac: Fix FLAC__CPU_PPC on little endian, and add