Displaying 20 results from an estimated 8000 matches similar to: "Averaging 'blocks' of data"
2010 Sep 09
3
Alignment of lines within barplot bars
Dear all,
I have a barplot upon which I hope to superimpose horizontal lines extending across the width of each bar. I am able to partly achieve this through the following set of commands:
positions <- barplot(bar_values, col="grey")
par(new=TRUE)
plot(positions, horiz_values, col="red", pch="_", ylim=c(min(bar_values), max(bar_values)))
...however this results
2008 Aug 02
2
Iterative Averages
Dear all,
I have a data frame of 2160 rows and 4320 columns, which I hope to condense to a smaller dataset by finding averages of 6 by 6 blocks of values (to produce a data frame of 360 rows by 720 columns).
How would I go about finding the mean of a 6 x 6 block, then find the mean of the next adjacent 6 x 6 block, and so on, until the whole data frame has been covered?
One slight twist is that
2008 Sep 05
2
Use of colour in plots
Dear all,
I have 3 datasets all of which share the same longitude and latitude values, which I'm looking to plot onto a scattergraph. The third dataset has values which can only be either '1' or '2'. So to incorporate all three datasets onto two axes, I'm wondering if I can plot dataset1 and dataset2 as normal, but then use colour to determine whether these points are
2009 Aug 17
3
Replacing NA values in one column of a data.frame
Dear all,
I'm trying to replace NA values with -9999 in one column of a data frame. I've tried using is.na and the testdata[testdata$onecolumn==NA] <- 9999 approach, but whilst neither generate errors, neither result in -9999s appearing - the NAs remain there!
I'd be grateful for any advice on what I'm doing wrong or any other suitable approaches.
Many thanks,
Steve
2009 May 04
4
Producing a legend successfullly
Dear all,
I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using:
legend(80,1150, c("Simulation",
2009 May 18
8
Simple plotting errors
Dear R Users,
I have 12 data frames, each of 12 rows and 2 columns.
e.g. FeketeJAN
MEAN SUM_
AMAZON 144.4997874 68348.4
NILE 5.4701955 1394.9
CONGO 71.3670036 21196.0
MISSISSIPPI 18.9273250 6511.0
AMUR 1.8426874 466.2
PARANA 58.3835497 13486.6
YENISEI 1.4668313 592.6
OB 1.4239179 559.6
LENA 0.9342164
2010 Feb 09
2
Resampling a grid to coarsen its resolution
Dear all,
I have a grid (data frame) dataset at 0.5 x 0.5 degrees spatial resolution (720 columns x 360 rows; regular spacing) and wish to coarsen this to a resolution of 2.5 x 2.5 degrees. A simple calculation which takes the mean of a block of points to form the regridded values would do the trick. Values which should be excluded from the calculation are -9999 (unless all points within a block
2011 Nov 15
1
averaging between rows with repeated data
*The situation (or an example at least!)*
example<-data.frame(rep(letters[1:10]))
colnames(example)[1]<-("Letters")
example$numb1<-rnorm(10,1,1)
example$numb2<-rnorm(10,1,1)
example$numb3<-rnorm(10,1,1)
2009 Oct 09
4
Trendline for a subset of data
Dear all,
I am using abline(lm ...) to insert a linear trendline through a portion of my data (e.g. dataset[,36:45]). However, I am finding that whilst the trendline is correctly displayed and representative of the data portion I've chosen, the line continues to run beyond this data segment and continues until it intersects the vertical axes at each side of the plot.
How do I display the
2010 Jan 25
4
R Output and ArcGIS
Dear all,
I've been using R on a Mac to process some data for export to ArcMap GIS (which only runs on Windows). ArcMap seems to require tab-delimited data (my data are in 3 columns), so I've been using the sep="\t" argument. However, this resulted in strange end-of-line characters when displayed on a PC. I looked in the write.table help file to find that eol="\r\n"
2009 Mar 25
4
Manual sort in a for loop
Dear all,
I am trying to manually re-sort rows in a number of tables. The rows aren't sorted on any particular values but are simply ordered by user choice (as shown by the row numbers in the code). I have been able to carry out each re-arrangement without the use of the 'for' loop, but cannot seem to successfully execute the statements when incorporated into the loop. The code I have
2009 Aug 14
4
Assigning values based on a separate reference (lookup) table
Dear R Users,
I have a data frame of 360 rows by 720 columns (259200 values). For each value in this grid I am hoping to apply an equation to, to generate a new grid. One of the parts of the equation (called 'p') relies on reading from a separate reference table. This is Table 4 at: http://www.fao.org/docrep/s2022e/s2022e07.htm#3.1.3%20blaney%20criddle%20method (scroll down a little).
2010 Sep 14
1
Model averaging with (and without) interaction terms
I?ve used logistic regression to create models to assess the effect of
3 variables on the presence or absence of a species, including the
interaction terms between variables and model averaging using MuMI:
model.avg
The top models (delta<4) include several models with interaction terms
and some models without; model weights are quite low for all models
(<0.25). My problem is that the models
2009 Aug 17
3
Reshape package: Casting data to form a grid
Dear R Users,
I'm trying to use the 'cast' function in the 'reshape' package to convert column-format data to gridded-format data. A sample of my dataset is as follows:
head(finalframe)
Latitude Longitude Temperature OrigLat p-value Blaney
1 -90 -38.75 NA -87.75 17.10167 NA
2 -90 135.75 NA -87.75 17.10167 NA
3 -90 80.25
2009 Mar 26
4
Reading in files with variable parts to names
Dear all,
I'm trying to read in a whole directory of files which have two variable parts to the file name: year and month. E.g. comp198604.asc represents April of 1986 - 'comp' is fixed in each case. Years range between 1986 to 1995 and months are between 1 and 12.
Just to be clear, there are 12 files associated with each year: e.g. comp198601, comp198602, ... comp198612 through to
2009 May 04
2
Reversing axis label order
Dear R Users,
I am executing the following command to produce a line graph:
matplot(aggregate_1986[,1], aggregate_1986[,2:3], type="l", col=2:3)
On the x-axis I have values of Latitude (in column 1) ranging from -60 to +80 (left to right on the x-axis). However, I wish to have these values shown in reverse on the x-axis, going from +80 to -60 (ie. North to South in terms of Latitude).
2009 May 02
2
Problems producing a simple plot
Dear R Users,
I have a data frame of the nature:
> head(aggregate_1986)
Latitude Mean Annual Simulated Runoff per 1? Latitudinal Band
1 -55 574.09287
2 -54 247.23078
3 -53 103.40756
4 -52 86.99991
5
2009 Jan 12
3
Working with duplicated rows
Dear all,
I have a dataframe of 3 columns, consisting of 'longitude', 'latitude'
and a corresponding 'value'. Where identical 'longitude' and 'latitude'
pairs occur more than once, I want their corresponding 'value' to be
summed and the 'pair' to only appear once.
For example:
long lat value
10 20 5
6 2 3
2009 Oct 15
4
Subset returning unexpected result
Dear all,
I am attempting to subset a data frame based on a range of latitude values. I want to extract the values of 'interception' where latitude ranges between 50 and 60. I am doing this using the following code, yet it doesn't return the results I expected:
> test <- subset(int1901, Latitude>=50 & Latitude <60, select=c(Latitude, Interception))
> head(test)
2009 Mar 23
2
Looping of read.table and assignment
Dear all,
I am trying to read in and assign data from 50 tables in an automated fashion. I have the following code, which I created with the help of textbooks and the internet, but it only seems to read in the final data file over and over again. For example, when I type:> table_1951 I get the same values in the table as when I type> table_2000 despite the values in the source tables