Re: [R] How to select one value per row (different columns) from array

2017-03-01 Thread Wolfgang Waser
e may be other datasets where you have more columns than rows and >never >want to sample each column more than once, in which case you would set >replace=FALSE. > >Best Regards. > > > >On Wed, Mar 1, 2017 at 5:38 AM, peter dalgaard >wrote: > >> >> array[cbi

[R] How to select one value per row (different columns) from array

2017-03-01 Thread Wolfgang Waser
Dear all, I have to pick one value per row from an array, but from row to row from a different column. The column positions of the values for each row are stored in a vector. array: 999 rows, 48 columns vector: 999 values (each between 1 and 48) indicating for each row which value to pick from t

Re: [R] How to extract same columns from identical dataframes in a list?

2016-02-10 Thread Wolfgang Waser
[2,]11 4 > [3,]323 > [4,]241 > > Or, brute-force-and-ignorance: > >> sapply(l, function(e) e[, 2]) > [,1] [,2] [,3] > [1,]432 > [2,]114 > [3,]323 > [4,]241 > > &g

Re: [R] How to extract same columns from identical dataframes in a list?

2016-02-09 Thread Wolfgang Waser
myarray) <- c(nrow(mylist$a), ncol(mylist$a), length(mylist)) > dimnames(myarray) <- list(hour = rownames(mylist$a), > week = colnames(mylist$a), > other = names(mylist)) > # now you can do: > mean(myarray[, "week1", &quo

[R] How to extract same columns from identical dataframes in a list?

2016-02-08 Thread Wolfgang Waser
Hello, I have a list of 7 data frames, each data frame having 24 rows (hour of the day) and 5 columns (weeks) with a total of 5 x 24 values I would like to combine all 7 columns of week 1 (and 2 ...) in a separate data frame for hourly calculations, e.g. > apply(new.data.frame,1,mean) In some wa

[R] repeat(?) measurement ANOVA or (general? mixed?) linear model?

2009-10-07 Thread Wolfgang Waser
Hi all, after browsing the archives for hours I'm still not sure about the proper analysis for my dataset. I subjected each of about 50 critters (about 10 each in 5 distinct populations) to 4 consecutive treatments (exposure to increasing concentrations), with one measurement per treatment and

[R] how to pass additional parameters to a function called in tapply?

2008-09-01 Thread Wolfgang Waser
Hi all, the following problem is still beyond my R-knowledge: I have one data vector containing the signal from 4 channels that are measured subsequently and in repeating cycles (with one factor vector for cycle and one for channel identification). To extract the mean of each channel during ea

Re: [R] nls: different results if applied to normal or linearized data

2008-03-05 Thread Wolfgang Waser
Thanks for your comments! > Yes. You are fitting by least-squares on two different scales: > differences in y and differences in log(y) are not comparable. > > Both are correct solutions to different problems. Since we have no idea > what 'x' and 'y' are, we cannot even guess which is more appro

[R] nls: different results if applied to normal or linearized data

2008-03-05 Thread Wolfgang Waser
Dear all, I did a non-linear least square model fit y ~ a * x^b (a) > nls(y ~ a * x^b, start=list(a=1,b=1)) to obtain the coefficients a & b. I did the same with the linearized formula, including a linear model log(y) ~ log(a) + b * log(x) (b) > nls(log10(y) ~ log10(a) + b*log10(x), start=l