Re: [R] Classification
Thanks to both of you. Problem's solved. Greatly appreciated. :] Chris Chris Li wrote: Hi all, I have got a dataset like the following: 3 5 7 3 9 7 i.e. random numbers with some repeats. I want R to classify them for me. E.g. every row that has a value of 3 will be asigned a value of 1, and every row that has a value will be asigned a value of 2 etc. I want R to return the following, using the example above: 1 2 3 1 4 3 Thanks in advance. Chris -- View this message in context: http://old.nabble.com/Classification-tp26429330p26454103.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] Classification
Hi all, I have got a dataset like the following: 3 5 7 3 9 7 i.e. random numbers with some repeats. I want R to classify them for me. E.g. every row that has a value of 3 will be asigned a value of 1, and every row that has a value will be asigned a value of 2 etc. I want R to return the following, using the example above: 1 2 3 1 4 3 Thanks in advance. Chris -- View this message in context: http://old.nabble.com/Classification-tp26429330p26429330.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] Minimum and blanks
Thanks Joris and Peter. Sorry for not giving enough details. I have tried your suggestions and the problem is solved. Thank you. :) JorisMeys wrote: The minimum of a character vector is returned according to the unicode or ascii code values, but I guess that's not what Chris is looking for. Chris, please always try to provide a minimal working example of code to see what is wrong. Something goes wrong with the input in your example. As Peter rightfully pointed out, your vector is considered a character vector. So you need to : 1) replace with NA e.g. x - ifelse(x=='',NA,x) Better to do something like that when reading in the code. 2) use the argument na.rm : min (x, na.rm=T) kind regards Joris On Thu, Oct 1, 2009 at 8:36 AM, Peter Ehlers ehl...@ucalgary.ca wrote: Chris, What is your definition of the minimum of a *character* vector? -Peter Ehlers Chris Li wrote: Hi all, I want to calculate the minimum of a column which contains blanks. R returns as the minimum, which is not I want. Is there a way to overcome it? Thanks in advance. Chris __ 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@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. -- View this message in context: http://www.nabble.com/Minimum-and-blanks-tp25692189p25707736.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] Minimum and blanks
Hi all, I want to calculate the minimum of a column which contains blanks. R returns as the minimum, which is not I want. Is there a way to overcome it? Thanks in advance. Chris -- View this message in context: http://www.nabble.com/Minimum-and-blanks-tp25692189p25692189.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] Statistical analysis
Hi all, I have got two datasets, one of them is rainfall data and the other one is groundwater level data. I would like to see whether there is a correlation between these two datasets and if there is, to what extent they are correlated. My stats background is limited, therefore any advice on which command I should use in R would be greatly appreciated. Thanks in advance. Chris -- View this message in context: http://www.nabble.com/Statistical-analysis-tp25531331p25531331.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] Sorting
Hello, Say I have a dataset as followed: Category Value b1 b2 a7 a1 Then, if I: levels(Category) It will return: [a], [b] But I want to keep the original order, i.e.: [b], [a] Is it possible to do it in R? Thanks in advance! Chris -- View this message in context: http://www.nabble.com/Sorting-tp25531007p25531007.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] Rounding to the nearest 5
Hi all, I want to round my values to the nearest 5. For example, if I have a value of 11, I want R to round it to 10. I have been searching for this command on the web and in the help file, but I couldn't find anything useful. Any help would be greatly appreciated. Many thanks, Chris -- View this message in context: http://www.nabble.com/Rounding-to-the-nearest-5-tp25463367p25463367.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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] How to calculate min of a dataset that contains empty column
Hi all, I have got a dataset like the following: a b c 1 5 2 3 7 I am taking the minimum of each column and use it as the minimum of the y-axis of my graphs. My scripts (simplified version) are like the following: f-array f[1]=a f[2]=b f[3]=c for i in 1:3 name=f[i] ymin-min(dataset$f[i]) plot(x,y,ylim=c(ymin,100)) The script stops at b, because the min function returns inf value. What can I do to overcome it? Many thanks, Chris -- View this message in context: http://www.nabble.com/How-to-calculate-min-of-a-dataset-that-contains-empty-column-tp25463449p25463449.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] Exporting Numerous Graphs
Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.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] X-axis range
Hi all, I would like to change the x-axis of my graphs from year 1998 to 2008 with an interval of 5 (i.e. 1998, 2003, 2008). Any help would be greatly appreciated. http://www.nabble.com/file/p25447219/model_hydrographs.txt model_hydrographs.txt http://www.nabble.com/file/p25447219/bore_sample.txt bore_sample.txt http://www.nabble.com/file/p25447219/46871a%2Bcalibration%2Bscript.R 46871a+calibration+script.R Cheers, Chris -- View this message in context: http://www.nabble.com/X-axis-range-tp25447219p25447219.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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] X-axis range
Thanks Peter. I have tried your approach, and it does not work. I guess it is because the format of the x-axis (and its associated data) has the format of date while numbers like 1998, 2003 etc. are treated as numeric (i.e. not the date format). Thank you for your time anyway. :) Cheers, Chris Peter Alspach-2 wrote: Tena koe Chris ?axis e.g., plot(yourX, yourY, xlim=c(1998,2008), xaxt='n') axis(1, c(1998,2003,2008)) HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Chris Li Sent: Tuesday, 15 September 2009 3:22 p.m. To: r-help@r-project.org Subject: [R] X-axis range Hi all, I would like to change the x-axis of my graphs from year 1998 to 2008 with an interval of 5 (i.e. 1998, 2003, 2008). Any help would be greatly appreciated. http://www.nabble.com/file/p25447219/model_hydrographs.txt model_hydrographs.txt http://www.nabble.com/file/p25447219/bore_sample.txt bore_sample.txt http://www.nabble.com/file/p25447219/46871a%2Bcalibration%2Bscript.R 46871a+calibration+script.R Cheers, Chris -- View this message in context: http://www.nabble.com/X-axis-range-tp25447219p25447219.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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@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. -- View this message in context: http://www.nabble.com/X-axis-range-tp25447219p25447800.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] Question about Factors
Hi all, I am new to R and I have got a question in regards to factors. Say I have a simple dataset like the following: Name Time Value a 1:00 1.25 a 2:00 1.26 b 1:00 1.29 b 2:00 1.28 c 1:00 1.21 c 1:30 1.20 c 2:00 1.23 I want to write a script that automatically plot value against time for a, b and c. Because I have got more than 1 datasets, therefore the name of the next dataset may consist d, e, h and g. So I will need a script that can detect the changes in Name automatically. Thank you very much for your time. Chris -- View this message in context: http://www.nabble.com/Question-about-Factors-tp25428665p25428665.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] Grid lines
Hi everyone. I am new to R. It will be greatly appreciated if someone can help me with the following questions. Here's the graph I have just produced. http://www.nabble.com/file/p24732839/calibration.jpeg (1) How can I put the legend on top of the grid lines? (2) How can I match the grid lines with the x-axis ticks? (3) How can I change the x-axis format from e.g. Mar, Apr...etc to 1-3-2009,1-4-2009...etc? Many thanks! :-) Chris -- View this message in context: http://www.nabble.com/Grid-lines-tp24732839p24732839.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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] Grid lines
Thanks for the reply guys. Below are the script and data files. http://www.nabble.com/file/p24734049/HEAD_calibration.R HEAD_calibration.R http://www.nabble.com/file/p24734049/6527-1052 6527-1052 http://www.nabble.com/file/p24734049/6527-1054 6527-1054 http://www.nabble.com/file/p24734049/MAR3 MAR3 Once again, thank you for your help, greatly appreciated!! Chris Chris Li wrote: Hi everyone. I am new to R. It will be greatly appreciated if someone can help me with the following questions. Here's the graph I have just produced. http://www.nabble.com/file/p24732839/calibration.jpeg (1) How can I put the legend on top of the grid lines? (2) How can I match the grid lines with the x-axis ticks? (3) How can I change the x-axis format from e.g. Mar, Apr...etc to 1-3-2009,1-4-2009...etc? Many thanks! :-) Chris -- View this message in context: http://www.nabble.com/Grid-lines-tp24732839p24734049.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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.