[R] Assign name to a name
I would like to know how I can assign a name to a name. I have a dataset that has different years in it. I am writing scripts using R and I would like to give a month a generic name and then use the generic name to do different analysis. The reason for the generic name would be so that I only have to change one thing if I wanted to change the year. For example. Year1 = 1999 datayear <- subset(dataset, Year = Year1) I would want to subset for whatever year is in "Year1". I am not sure if R does this but it would be great if it does. Is there also anyway for R to ask the user for the variable in the console without going into the script and then use whatever the user puts in. Thanks for the help. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Barchart legend position
I am using barchart to make charts for some data with a lot more functions and labels and such in the command. barchart(Freq ~ factor(HH), data = dataset1, group= year) So I have my data grouped by year and I get a legend at the top of graph, which is great cause I need the legend for the different years but it is a weird spot. So how can I manipulate the legend, ie. Move it, shrink it, do anything with it. I have searched the help archives and found nothing, and I have looked up the legend section in ?barchart but that has not helped or I am doing something wrong. Any help is greatly appreciated. Jacquie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Replace number with month
Hi all I have a multiple datasets that look like this MM Freq 1 30 2 35 3 54 4 33 5 27 6 13 7 25 8 29 9 40 10 32 11 36 12 23 I am plotting this using barchart (there is probably something better but it gives me the results I want) and I would like the x-axis to have the names of the months instead of the month numbers. So I have searched and searched and I am not sure if I have to change it before I graph it or if I can somehow change it in barchart. Any help is most appreciated. Jacquie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] How to group a count
Here is my data. I tried table but it doesn't do what I want it to do when it graphs. I want a count of the types (R for one graph and A for another) by hour grouped by year. Hope that helps. ID,,MM,DD,HH,MM,Type YEG,2002,01,01,01,24,A YEG,2002,01,01,02,40,R YEG,2002,01,01,05,39,R YEG,2002,01,01,09,17,A -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: May 15, 2007 3:46 PM To: Spilak,Jacqueline [Edm] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] How to group a count On 5/15/07, Spilak,Jacqueline [Edm] <[EMAIL PROTECTED]> wrote: > Hello R users > I have a dataset that has different types of records with different > dates and times pertaining to each. I would like to have a bar graph > of a count of the types(ie. The number of types) of recods by hour > grouped by year. So the count of the types would be the y axis, the > hour on the x axis and then grouped by year for easy comparison. I > think that I have to use barchart however I don't know how to get > barchart to do a count and not graph values. I think you want to use table or xtabs to get a frequency table, and use barchart on the result. Hard to say more without an example. -Deepayan __ R-help@stat.math.ethz.ch 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] Barplot by two variables
Thanks for your solution, it worked perfectly, it was exactly what I wanted. I do have two more questions and hope you can help. I have another analysis exactly like the last one except it is done by month instead of year. When I graph it using barchart it makes the months go in alphabetical order. Is there anyway to change it so that the months go in the correct order (jan, feb, march, etc,). And how do I change the colors of the bars in the graph, they are weird colors and I want to change them. Thanks so much for your help. -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: May 10, 2007 4:58 PM To: Spilak,Jacqueline [Edm] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Barplot by two variables On 5/10/07, Spilak,Jacqueline [Edm] <[EMAIL PROTECTED]> wrote: > Hi all > I have a bit of a problem. I want to make a barplot of some data. My > data is of a score that is separated by year and by a limit (above 3 > and below 3 to calculate the score). > YearLimit HSS > 1999ALT 0.675 > 1999VFR 0.521 > 2000ALT 0.264 > 2000VFR 0.295 > > I would like to have a barplot with year on the x axis and HSS on the > y axis and the two limits as two different colors to show the difference. > Using (dataset$HSS, col=c("green","purple")) I get some of the plot > but I don't know how to get labels on the bottom for each year and I > can't get a legend for my barplot. Not really sure what I am doing > wrong but any help would be much appreciated. Here's one solution using the lattice package: library(lattice) barchart(HSS ~ factor(Year), data = dataset, origin = 0, groups = Limit, auto.key = TRUE) -Deepayan __ R-help@stat.math.ethz.ch 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 group a count
Hello R users I have a dataset that has different types of records with different dates and times pertaining to each. I would like to have a bar graph of a count of the types(ie. The number of types) of recods by hour grouped by year. So the count of the types would be the y axis, the hour on the x axis and then grouped by year for easy comparison. I think that I have to use barchart however I don't know how to get barchart to do a count and not graph values. Thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Barplot by two variables
Hi all I have a bit of a problem. I want to make a barplot of some data. My data is of a score that is separated by year and by a limit (above 3 and below 3 to calculate the score). YearLimit HSS 1999ALT 0.675 1999VFR 0.521 2000ALT 0.264 2000VFR 0.295 I would like to have a barplot with year on the x axis and HSS on the y axis and the two limits as two different colors to show the difference. Using (dataset$HSS, col=c("green","purple")) I get some of the plot but I don't know how to get labels on the bottom for each year and I can't get a legend for my barplot. Not really sure what I am doing wrong but any help would be much appreciated. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Sum of specific column
I have a data set that I have imported (not sure if that makes a difference) and I would like to calculate the sum of only specific columns. I have tried >colSums(dataset, by=list(dataset$col5), dims=1) and I get an error of unused arguments I have also tried >aggregate(dataset, by=list(dataset$col5), sum) and I get the error that sum is not meaningful for factors. I want to only calculate the sum for specific columns because some of the columns have words in them and I have not been able to find anything else that would help or why these errors are occuring. Jacquie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Looping through series of names
Hi I am very new to R and have not able to find the answer to my question in the manual or any other post. I have a dataset that has various different sites names with data relating to each site. The data is in one dataset. I want to loop through the different site names and perform my test on each site. The sites are named not numbers for example "YYC". How do I do this. I hope I was clear enough. Thanks for the help [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.