Displaying 20 results from an estimated 800 matches similar to: "data frame subsets?"
2008 Oct 30
3
Save a function existing library
Hello all,
I am fairly new to R and I have created a function that I use quit
frequently. I was wondering if there is away to save this function in
an existing library so I can call it by using the function name once the
library is loaded?
Thanks,
Doug
--
---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice:
2009 Dec 01
3
paste name in for loop?
Hello,
I am trying to create subsets of grouped data (by area size), and use
the area size as part of the output name. The code below works for area
(xout) 1 and 50, the other files are given NA for an area.
A simple example:
xout <- c(1,5,10,25,50,100)
for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }
[1] "Areal_Ppt_1sqmi.txt"
2010 Feb 04
3
Legend symbol?
Hello,
I am creating a plot/image using different data and a couple fit lines
(see attached image). In the legend, I want the Default and Exponential
symbol to be a line. I am using the pch command, I tried to use "-" to
represent a line but does not work so I currently have set as a "1".
Any thoughts or suggestions would be greatly appreciated.
Below are the commands
2010 Jan 05
3
R matching lat/lon pairs from two datasets?
Hello,
I am trying to match lat/lon from one dataset with the lat/lon from a
second dataset and use that rows data for calculations. I am using
match, but this is finding the first match and not comparing the pair,
how can I determine if the lat/lon are the same? See example below. Is
there a better way to determine to a matching pair of lat/lon values?
Example Datasets:
> data2
2009 Oct 15
2
Data frame search and remove questions
Hello,
I have a couple questions about removing rows from a data frame and
creating a new data frame with the removed values. I provided an
example data frame (d) below.
Questions:
1) How can I search for "-999.000" and remove the entire row from data
frame "d"? (all -999 values will be in sd_diff)
2) Can I create a new data frame "d.new" that only contains the
2008 May 20
3
R for loop question
Hello,
I am trying to assign a variable name (x1,x2,x3...) in a loop statement
that is based on a counter (counter is based on the number of hours
within the datafile). The x1,x2 data will later be called for plotting
the data. Below is a clip of the for loop I am using, any suggestions?
k = 1
for (i in 1:length(stats$hour)) {
"x(i)" = dataset[k,(3:15)]
k = k+1
}
Thanks,
2010 Jan 20
2
Plot frame border to start at zero?
Hello,
I am creating plots of hourly precipitation and accumulated
precipitation (on different axis, see attached image). I was wondering
how can I have the plot frame (black border) start at zero, it looks
like it is plotted less than zero?
The code I use to create the png files is below:
CairoPNG(PNG_file,width=1000, height=600, pointsize=14, bg="white")
opar <-
2009 Oct 22
1
Cairo package, png files within for loop are black?
Hello,
I am generating .png images using the Cairo package in a for loop
(looping on the number of zones, number of zones equals the number of
plots to create based on different zone data). When I run the R
script the .png files are created but they are all black? If I comment
out the for loop and force my zones to equal one the png file is created
correctly? Is there an issue with
2003 Apr 04
2
Bug in %in% (match)
Hi,
Am I hitting some limit in match? Consider the following example:
> tst<-seq(100,125,by=.2)%in%seq(0,800,by=.1)
> sum(tst)
[1] 76
> seq(100,125,by=.2)
[1] 100.0 100.2 100.4 100.6 100.8 101.0 101.2 101.4 101.6 101.8 102.0
102.2
[13] 102.4 102.6 102.8 103.0 103.2 103.4 103.6 103.8 104.0 104.2 104.4
104.6
[25] 104.8 105.0 105.2 105.4 105.6 105.8 106.0 106.2 106.4 106.6 106.8
2003 Apr 04
2
Bug in %in% (match)
Hi,
Am I hitting some limit in match? Consider the following example:
> tst<-seq(100,125,by=.2)%in%seq(0,800,by=.1)
> sum(tst)
[1] 76
> seq(100,125,by=.2)
[1] 100.0 100.2 100.4 100.6 100.8 101.0 101.2 101.4 101.6 101.8 102.0
102.2
[13] 102.4 102.6 102.8 103.0 103.2 103.4 103.6 103.8 104.0 104.2 104.4
104.6
[25] 104.8 105.0 105.2 105.4 105.6 105.8 106.0 106.2 106.4 106.6 106.8
2010 Jun 23
2
Unique Data Frame Name?
Hello,
I am trying to create a data frame with a unique name, based on indexing
of for loop. I was wondering if there is a way to do this, I keep
running into errors when I try to do this. Below is a brief example, I
am trying to get two data frames (name1 and name2).
Any suggestions are appreciated.
Thanks,
Doug
# Example
for (i in 1:2) {
x=c(1,2,3,4)
y=c(10,20,30,40)
2010 Jun 28
3
data frame row statistics (mean)?
Hello,
I am trying to calculate the mean value of each row in a data frame (d),
I am having troubles and getting errors using the code I have written.
Below is a brief example of the code, any thought or suggestions would
be great.
Thank you for your time,
Doug
# Example Code:
d <- data.frame(st1=c(1,2,3,4), st2=c(2,5,6,7), st3=c(5,5,NA,7),
st4=c(6,5,7,8))
avg <-
2009 Mar 24
3
Display Equation on plot
Hello,
I am using the lm to fit a linear model to data, I was wondering if
there is a way to display the equation on a plot using the extracted lm
coefficients? I am using the plot() function to create the plot/.png.
Example:
lm_mod <- lm(data1~data2)
intercept = 48.54
slope = 0.4856
I want to display equation on a plot as y=0.4856x+48.54
Any thoughts or suggestions are appreciated.
2009 Sep 01
1
Read multiple files into dataframe?
Hello,
I am fairly new to R programming and am stuck with the following problem.
I am trying to read in multiple files (see attached file or at end of
email), the files all have the same general header information and
different precipitation (avgppt) and area (areasqmi) values. Some times
the number of records are different in the files.
I want to read in all files (.stdsummary), and create
2010 Jun 14
1
Times series data file?
Hello,
I currently splitting a file into individual files (time series each
separated into one file), the file I read in skips the first four lines
and extracts the data columns I need. I was wondering if there is a way
for R to automatically scan and separate the files based on the head
information?
The header delineates the observation with a 254 space time space day
space month space
2013 Jan 29
2
Netcdf and Raster Package Questions, Need .asc File for GIS
Hello R-Group,
I am new working with netcdf files and the raster package in R.I am
trying to read in a netcdf file using the package "ncdf".I am able to
get the lat, lon and parameter I need and can plot using
fill.contour.Ultimately, I am trying to create a .asc file to reafd into
GIS.I am using the package "raster" to read the parameter.When I read in
with
2009 Oct 27
1
New vector based on if/else statement within for loop?
Hello,
I am trying to create a new vector (w) that is based on comparing two
vectors (P and Z). The compaison is simple (I created a for loop that
reassigns w based on if statement), all Z values >= 24 and P values <=1,
w=88 else w=77. I am not getting the correct results for w, see
example code below. Any thoughts or suggestions on the correct method.
Thank you,
Doug
P <-
2009 Nov 16
1
lmomco package and confidence limits?
Hello,
I am using the lmomco package (lmom.ub and pargev) to compute the GEV
parameters (location, scale, and shape), which are used to estimate
return values. I was wondering how/if I can calculate upper and lower
confidence (CI_u, CI_l) intervals for each return frequency using the
GEV parameters to fill-in the table below?
Xi (location) = 35.396
Alpha (scale) = 1.726
Kappa (shape) =
2009 Jun 09
1
Cairo Package Installation
I am trying to install the Cairo package on a linux machine, the Cairo
package did not install correctly (could not find cairo.h), I am new to
R and linux any help on the installation would be great. Below are
output from trying to install the Cairo package, thought this might help.
> install.packages("Cairo")
Warning in install.packages("Cairo") :
argument
2011 Nov 01
3
factor level issue after subsetting
Dear list,
I cannot figure out why, after sub-setting my data, that particular item
which I don't want to plot is still in the newly created subset (please
see example below). R somehow remembers what was in the original data
set. A work around is exporting and importing the new subset. Then it's
all fine; but I don't like this idea and was wondering what am I missing
here?
Thanks!