[R] Random data
Hi, how can I produce random data which lies around a straight line with angle 45 degree. Similar to this image: http://zoonek2.free.fr/UNIX/48_R/g134.png Cheers -- View this message in context: http://old.nabble.com/Random-data-tp26513822p26513822.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cor.test(x,y)
Hi, I am not sure which test is applied to the data if you use cor.test(x, y) ? Is it an unpaired t-Test? Regards -- View this message in context: http://www.nabble.com/cor.test%28x%2Cy%29-tp22492993p22492993.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Save image as metafile
Hi, how can I save an image as a metafile? I know within windows you can do a right click and then 'save image as metafile' but I use Mac OS X...I know as well that mac users have a right click as well, but it does not work. Is there a command in R for saving images as metafiles? Regards, mentor -- View this message in context: http://www.nabble.com/Save-image-as-metafile-tp20894737p20894737.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merge character strings
Hi, how can I do the following in R?: vec <- c("a", "b", "c") magic. print(str) "abc" or even better: "(a,b,c)"? Cheers -- View this message in context: http://www.nabble.com/merge-character-strings-tp20790116p20790116.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] par(ask=TRUE) and devAskNewPage(ask=TRUE) not working
Hi, First, I do some calculation, then a plot. Add some lines and texts to the plot. Second, do some further calculation, then a plot. Add again some lines and texts to the plot. Third, do some further calculation, then Fourth, . After a plot is complete (means the plot itself, lines and texts) I would like to click 'enter' to see the next complete plot (again the plot itself, lines and texts) and so on. par(ask=TRUE) and devAskNewPage(ask=TRUE) is not working, unfortunately? Any Ideas? Regards -- View this message in context: http://www.nabble.com/par%28ask%3DTRUE%29-and-devAskNewPage%28ask%3DTRUE%29-not-working-tp20718320p20718320.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with matplot
Hi, two days ago I have asked the list if there is a better way to plot a matrix using the following plot command: plot(matrix[1,], type="l") for (i in 2:dim(matrix)[1]) { lines(matrix[i,], type="l") } I have been told to use the matplot function, but unfortunately I matplot does not plot my matrix as I would like the matrix to be plotted... Each row in the matrix should be plotted as a time series plot. The columns should reflect the "time" The matrix looks like this: [,1] [,2] [,3] [,4] [,5] [,6] [1,] 10.795525 17.742121 -1.668664 7.410594 10.229107 -0.7402613 [2,] 9.335885 10.472469 9.503561 9.815167 16.073518 21.1387238 [3,] 16.818605 5.354479 10.921837 5.202947 4.730314 2.3975041 [4,] 9.773960 10.081033 3.538419 16.913288 10.623028 7.8052165 [5,] 8.473132 13.775806 3.739209 15.224250 6.339220 7.3409747 I tried this with matplot: m <- matrix(rnorm(30, 10, 5), ncol=6) time <- matrix(rep(1:6,5), nrow=5, byrow=TRUE) matplot(time, m, type="l", col="black") Any help would be appreciate! Thanks! -- View this message in context: http://www.nabble.com/Help-with-matplot-tp20481662p20481662.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Surface plotting
Hi, I would like to plot a matrix which comprises 3 columns. So first column should be the x-axis. Second the y-axis and the third one should be the z-axis. I know that I can plot such data using the scatterplot3d, but I would like to have a surface plot like you can do with wireframe and persp. But both, persp and wireframe, want to have x and y as descending data, at least persp. I am not sure but wireframe is actually doing excatly the same. So is there a way to plot each of the three columns on a different axis and having a surface? Cheers! -- View this message in context: http://www.nabble.com/Surface-plotting-tp20481173p20481173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot matrix
Hi, I would like to plot the rows of a matrix. Is there a better way as doing it in the following way?: plot(matrix[1,], type="l") for (i in 2:dim(matrix)[1]) { lines(matrix[i,], type="l") } Cheers -- View this message in context: http://www.nabble.com/Plot-matrix-tp20438584p20438584.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re order matrix columns
Hi, found a quite simple solution: test a b c d e [1,] 1 11 21 31 41 [2,] 2 12 22 32 42 [3,] 3 13 23 33 43 [4,] 4 14 24 34 44 [5,] 5 15 25 35 45 list <- c("b", "c", "a", "e", "d") test[,list] mentor_ wrote: > > Hi, > > I have found the following thread to reorder a data.frame. > I would like to do same regarding a matrix: > > https://stat.ethz.ch/pipermail/r-help/2008-February/154138.html > > I achieved this with a for loop and cbind but I think using 'is.element' > is much more > appropriate. Can anyone help? > > Cheers > -- View this message in context: http://www.nabble.com/Reorder-matrix-columns-tp20428678p20428869.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re order matrix columns
Hi, I have found the following thread to reorder a data.frame. I would like to do same regarding a matrix: https://stat.ethz.ch/pipermail/r-help/2008-February/154138.html I achieved this with a for loop and cbind but I think using 'is.element' is much more appropriate. Can anyone help? Cheers -- View this message in context: http://www.nabble.com/Reorder-matrix-columns-tp20428678p20428678.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Delete rows from matrix having at least one zero value
Hi, I have a further question about matrix manipulation. Imagine the following two matrices: > test [,1] [,2] [,3] [,4] [1,]1064 [2,]2575 [3,]3686 [4,]4000 > matrix(is.element(test,0), ncol=4) [,1] [,2] [,3] [,4] [1,] FALSE TRUE FALSE FALSE [2,] FALSE FALSE FALSE FALSE [3,] FALSE FALSE FALSE FALSE [4,] FALSE TRUE TRUE TRUE How can I apply the TRUE FALSE matrix to the 'test' matrix so that all rows having at least one zero value will be thrown out. So after applying the TRUE FALSE matrix the test matrix shoud look like the following: [,1] [,2] [,3] [,4] [1,]2575 [2,]3686 Cheers -- View this message in context: http://www.nabble.com/Delete-rows-from-matrix-having-at-least-one-zero-value-tp20405964p20405964.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Delete rows from matrix having at least one zero value
Have found a solution: matrix[rowSums(matrix == 0) == 0, ] mentor_ wrote: > > Hi, > > I have a further question about matrix manipulation. > > Imagine the following two matrices: >> test > [,1] [,2] [,3] [,4] > [1,]1064 > [2,]2575 > [3,]3686 > [4,]4000 > >> matrix(is.element(test,0), ncol=4) > [,1] [,2] [,3] [,4] > [1,] FALSE TRUE FALSE FALSE > [2,] FALSE FALSE FALSE FALSE > [3,] FALSE FALSE FALSE FALSE > [4,] FALSE TRUE TRUE TRUE > > How can I apply the TRUE FALSE matrix to the 'test' matrix so that all > rows > having at least one zero value will be thrown out. > > So after applying the TRUE FALSE matrix the test matrix shoud look like > the following: > [,1] [,2] [,3] [,4] > [1,]2575 > [2,]3686 > > Cheers > -- View this message in context: http://www.nabble.com/Delete-rows-from-matrix-having-at-least-one-zero-value-tp20405964p20406333.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Select specific rows of a matrix
Hi, if I have a large matrix e.g. with the dimensions of 1000 rows and 10 columns. How can I select rows comprising one or more values between a specific range of two values? So e.g. a row has one or more values between the range of 100 - 120. Cheers -- View this message in context: http://www.nabble.com/Select-specific-rows-of-a-matrix-tp20398347p20398347.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re move specific rows from a matrix
Hi, imagine the following two matrix: Matrix A: a b c 1 2 3 4 5 6 7 8 9 Matrix B: a 4 7 I would like to remove those rows from matrix A which are present in both matrices. So after removing the corresponding rows the matrix A should look like this: Matrix A: a b c 1 2 3 Thanks in advance! -- View this message in context: http://www.nabble.com/Remove-specific-rows-from-a-matrix-tp20379566p20379566.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Space between bars in barplot
Hi, thanks again for your help. I played around with your suggestions to change the appearance of my graph, but there is still a problem I could not fix. The vector, which I want to plot, contains 60 entries. After 3 bars I want to have a large gap between the next 3 bars. But what always happens is, that R took at the beginning just 2 bars and then always 3 bars ending up with one bar at the end. So I have created a new vector v <- c(0,0,vectorToPrint) plotting this vector with the following command: barplot(v, space=rep(c(0,0,2)) ). It works but getting always some warning messages. Instead of 0,0 I tried as well NA, NA but same result. So is there a way to achieve that without warning messages? Cheers, Mentor -- View this message in context: http://www.nabble.com/Space-between-bars-in-barplot-tp19878227p19919930.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Overlay Plots
Hi, I have three vectors and I would like to plot them in one window. So R should overlay them in the quartz. I achieved this by plotting the first vector: plot(v1) and add the other two with points(v2) and points(v3). Is there another way to achieve the same result? Cheers -- View this message in context: http://www.nabble.com/Overlay-Plots-tp19918234p19918234.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Thank you very much for all your possible solutions!
I also managed to get the right result but within a for loop ;) So I really appreciate your solutions! Thanks a lot! -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19882769.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using grep
Hi, I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B with (201, 204, 209). Now I would like to get the position in vector A matches with the entries in vector B So what I want to have is the following result: [1] 2 5 10 I tried the following: grep(B, A) grep(c(B), A) A <- as.character(A) B <- as.character(B) grep(B, A) grep(c(B), A) and several other combinations. But nothing is giving me the right result?! Does anyone know why? Cheers, Mentor -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19881017.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Space between bars in barplot
Hi, with the "space" parameter it is possible to change the gap / distance between the bars, but is it also possible to change the "space" after each 6th bar? So for example you have bars from 1 to 6 then a large gap and then the next six bars from 7 to 12 Thanks a lot! -- View this message in context: http://www.nabble.com/Space-between-bars-in-barplot-tp19878227p19878227.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.