similar to: Nested loop and output help

Displaying 20 results from an estimated 200 matches similar to: "Nested loop and output help"

2009 Oct 07
3
two plots on the same axis
Good morning. I wish to plot two data on the same axis. I tried plot(x,y, type = "l") for the first and tried to use lines or points(x,y, lty = 2, col = 4) to add or plot the second data on alongside the first. However, what I got was not encouraging. I have attached the two data and would be pleased if anybody could be of help. Thank you Best regards Ogbos -------------- next part
2023 Jan 27
3
implicit loop for nested list
> > I am looking for a more elegant way to write below code. > > #Simulation results have different dimensions > mysim <- lapply(1:10, function(y) { > two.mat <- matrix(rnorm(4), nrow = 2) > four.mat <- matrix(rnorm(16), nrow = 4) > list(two.mat = two.mat, four.mat = four.mat) #results with different dimensions > }) > > #Collect different
2013 Jan 31
2
Writing audio files (.wav) in a different directory
Hi. I'm trying to export a .wav file using the writeWave function from tuneR package in a different folder than the default getwd(). After reading through the manuals of some audio packages I couldn't figure it out. I'm picking one 3-hour .wav file and asking the function to take a sample of 1 minute (from minute 100 to minute 101 of the 3-hour file) and saving it in an object
2023 Jan 27
1
implicit loop for nested list
I would use replicate() to do an operation with random numbers repeatedly: ``` mysim <- replicate(10, { two.mat <- matrix(rnorm(4), 2, 2) four.mat <- matrix(rnorm(16), 4, 4) list(two.mat = two.mat, four.mat = four.mat) }) ``` which should give you a matrix-list. You can slice this matrix-list just like normal, then cbind it in one step: ``` two.mat <-
2011 Apr 03
1
Asterisk 1.6 => No sound/voice when i redirect the call
Hi i use this into my extension : exten => _00339xxxxxxxx,1,Set(foo=${SIP_HEADER(To)}) exten => _00339xxxxxxxx,2,Set(cut1=${CUT(foo,:,2)}) exten => _00339xxxxxxxx,3,Set(CLI=${CUT(cut1,>,1)}) exten => _00339xxxxxxxx,4,Set(toexten=${CUT(CLI,@,1)}) exten => _00339xxxxxxxx,5,Noop(ORIGINAL NUMBER : [ ${toexten} ]) exten =>
2012 Oct 17
2
loop of quartile groups
Greetings R users, My goal is to generate quartile groups of each variable in my data set. I would like each experiment to have its designated group added as a subsequent column. I can accomplish this individually with the following code: brks <- with(data_variables, cut2(var2, g=4)) #I don't want the actual numbers, I need a numbered group data$test1=factor(brks,
2011 Oct 11
1
warning with cut2 function
Dear r user, please find my attached sample of the dataset i? am using to create a crosstable and eventually plot a histogram from the output. I am using? the cut2 function to create bins, about 7 of them using the code after reading the data: cluster <- cut2(cross_val$value, g=7) I get the warning: Warning message: In min(xx[xx > upper]) : no non-missing arguments to min; returning Inf
2012 Oct 17
2
cut2 error
To R users, I am trying to use cut2 function from the 'Hmisc' library. However, when I try and run the function on the following variable, I get an error message (displayed below). I suspect it is because of the NA but I have no idea how to address the error. Many thanks to any insights. structure(list(var1 = c(97, 97, 98, 98, 97, 99, 97, 98, 99, 98, 99, 98, 98, 97, 97, 98, 99, 98,
2004 Jul 06
3
Improving effeciency - better table()?
Hi, I've been running some simulations for a while and the performance of R has been great. However, I've recently changed the code to perform a sort of chi-square goodness-of-fit test. To get the observed values for each cell I've been using table() - specifically I've been using cut2 from Hmisc to divide up the range into a specified number of cells and then using
2009 May 20
1
sem with categorical data
I am trying to run a confirmatory factor analysis using the SEM package. My data are ordinal. I have read http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf. When I apply the hetcor function, I receive the following error: Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr, : at least one element of 'lower' is larger than 'upper' Example:
2009 Oct 23
1
cut2 once, bin twice...
Hello, I'm using the Hmisc cut2 function to bin a set of data. It produces bins that I like with results like this: [96,270]:171 [69, 96): 54 [49, 69): 40 [35, 49): 28 [28, 35): 14 [24, 28): 8 (Other) : 48 I would like to take a second set of data, and assign it to bins based on factors defined by my call to cut 2. Does anyone know how I can do this? Thank you, -S -- View this message
2012 Nov 12
5
Matrix to data frame conversion
I have a matrix which I wanted to convert to a data frame. As I could not succeed and resorted to export to csv and reimport it again. Why did I fail in the attempt and how can I achieve what I wanted without this roundabouts? The original matrix: > str(comb_model0) num [1:90, 1:4] 3.5938 0.0274 0.0342 0.0135 0.0207 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:90]
2008 Oct 20
4
aggregating along bins and bin-quantiles
Dear all, I would like to aggregate a data frame (consisting of 2 columns - one for the bins, say factors, and one for the values) along bins and quantiles within the bins. I have tried aggregate(data.frame$values, list(bin = data.frame $bin,Quantile=cut2(data.frame$bin,g=10)),sum) but then the quantiles apply to the population as a whole and not the individual bins. Upon this
2010 Mar 08
1
Help with Hmisc, cut2, split and quantile
Hello, I have a set of data with two columns: "Target" and "Actual". A http://n4.nabble.com/file/n1584647/Sample_table.txt Sample_table.txt is attached but the data looks like this: Actual Target -0.125 0.016124906 0.135 0.120799865 ... ... ... ... I want to be able to break the data into tables based on quantiles in the "Target" column. I can see (using
2007 Dec 13
3
what does cut(data, breaks=n) actually do?
Hello, I'm trying to bin a quantity into 2-3 bins for calculating entropy and mutual information. One of the approaches I'm exploring is the cut() function, which is what the mutualInfo function in binDist uses. When it's called in the format cut(data, breaks=n), it somehow splits the data into n distinct bins. Can anyone tell me how cut() decides where to cut? Thanks, Melissa
2004 Sep 27
8
cannot assign dimnames
Dear list, If anyone knows how to assign dimnames to matrices or arrays I would be most grateful for help. I've tried various permutations of likely-looking code but get error messages every time. I could find no example in the documentation. Many thanks, Dan Bebber Department of Plant Sciences University of Oxford South Parks Road Oxford OX1 3RB UK Tel. 01865 275000
2009 Sep 22
1
cut and re-factor data
Hello R-users, I have a data frame with a factor of ages in 5 year increments, and various count data for each age group. I only have this summary information in R at the moment. I want to create a new factor that aggregates the age factors if the existing factors have insufficient counts. Then I can use aggregate to build a new data set. I figured out I can get the cut values I want using cut2
2009 Oct 12
1
Position of legend box
Good morning to you. I have about 4 different lines in one plot. I have used legend to indicate the colour of each plot. But the box contain the legend covers part of the lines thereby blurring the legend. There are some spaces in the plot that are empty and large enough to accommodate the legend box. If there a command I could use to set the position of the legend myself. I added the legend
2012 Feb 22
2
rank with uniform count for each rank
Hello, What is the best way to get ranks for a vector of values, limit the range of rank values and create equal count in each group? I call this uniform ranking...uniform count/number in each group. Here is an example using three groups: Say I have values: x = c(3, 2, -3, 1, 0, 5, 10, 30, -1, 4) names(x) = letters[1:10] > x a b c d e f g h i j 3 2 -3 1 0 5 10 30 -1 4 I
2009 Feb 02
1
survfit using quantiles to group age
I am using the package Design for survival analysis. I want to plot a simple Kaplan-Meier fit of survival vs. age, with age grouped as quantiles. I can do this: survplot(survfit(Surv(time,status) ~ cut(age,3), data=veteran) but I would like to do something like this: survplot(survfit(Surv(time,status) ~ quantile(age,3), data=veteran) #will not work ideally I would like to superimpose