Displaying 20 results from an estimated 1000 matches similar to: "Creating new data frame using loop"
2011 Jan 18
2
Barplot and line x-axis positions
Hello all,
Hoping that there is a fairly simple solution to my query...
I'm trying to overlay a line plot of some data onto a barplot of different data. The y-axes are different for each set of data but the x-axes are the same (1:12, corresponding with 12 months of observations). The problem I'm having is that the centre of the bars and the points on line don't match up, which is
2006 May 18
2
matrix transformation into 3 columns II.
Dear R-users
Sorry for posting the previous message too soon before I have finished it.
I have matrix (mprecip) with headers:
> dim(mprecip)
[1] 6268 170
> mprecip
date GilzeRijen Eindhoven Volkel ZuidLimburg Arcen Ubachsberg
1 01/01/1978 NA 0.0 NA 0.1 NA NA
2 01/02/1978 NA 0.0 NA 0.0 NA NA
3
2010 May 18
2
Function that is giving me a headache- any help appreciated (automatic read )
note: whole function is below- I am sure I am doing something silly.
when I use it like USGS(input="precipitation") it is choking on the
precip.1 <- subset(DF, precipitation!="NA")
b <- ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip <- precip.1
DF.precip$precipitation <- b$.data
part, but runs fine outside of the function:
days=7
2018 Apr 18
3
How to replace numeric value in the column contains Text (Factor)?
Hi R user,
Would you mind to help me on how I can change a value in a specific column
and row in a big table? but the column of the table is a factor (not
numeric).
Here is an example. I want to change dat[4:5,3]<-"20" but it generated NA>
do you have any suggestions for me?
dat<-structure(list(Sites = structure(1:5, .Label = c("Site1", "Site2",
2012 Oct 04
3
R combining vectors into a data frame but without a continuous common variable
Hello,
I have two different files which I'd like to combine to make one data frame
but I've no idea how to do it! The first file has two columns; one is the
date, the following is a binary code for debris flow events. Then my other
file has also two columns; the date and then precipitation data.
The thing is, is that the two date columns don't all contain the same dates.
The binary
2011 Feb 17
3
summing 15 minute precip data to daily
Hi all,
i'm sure there is an easy way to do this, but i'm stumped, so any help would
be appreciated.
i have a single column of data for precipitation every 15 minutes over a
year. i want to sum the precip to daily data.
so the first 96 records = the first day, the second 96 records = the second
day, and so on....
is there a way to write a for loop that would sum the data to daily, and
2018 Apr 18
0
How to replace numeric value in the column contains Text (Factor)?
The simplest would be to convert precip to character and then back to a factor if you really want it to be a factor. This will also remove the levels that no longer exist.
str(dat)
# 'data.frame': 5 obs. of 3 variables:
# $ Sites : Factor w/ 5 levels "Site1","Site2",..: 1 2 3 4 5
# $ temp : num 14 15 12 12.5 17
# $ precip: Factor w/ 5 levels
2005 Nov 15
1
combination xyplot and barchart?
Dear R community,
I am having trouble determining how to create the graph I want
utilizing my relatively limited knowledge of R. So far I have been
using the lattice library to create most of what I need.
The dataset (enviro) consists of 2 variables (Temp and Precip) for each
Day of a 2-yr period (Year). I wish to display Temp and Precip along
the y axis plotted by Day on the x axis to allow
2006 Jan 16
1
label of second y-axis in xyplot (lattice)
Dear group,
First I provide you with an example, I found in the newsgroup. Then I'd like to explain my problem to you by means of the output.
enviro <-
data.frame(Year = rep(2001:2002, each = 365),
Day = rep(1:365, 2),
Precip = pmax(0, rnorm(365 * 2)),
Temp = 2 + 0.2 * rnorm(365 * 2))
xyplot(Precip + Temp ~ Day | Year,
2010 Apr 15
1
Alignment of x-axis labels
Dear all,
I'm having trouble getting the correct spacing between x-axis labels on a barplot. This is the command I'm using to generate the plot:
temp <- barplot(precip, beside=TRUE, xaxt="n", las=1, xpd=FALSE, col="grey28", ylim=c(0, max(precip)))
Here is the structure of temp:
> str(temp)
?num [1:96, 1] 0.7 1.9 3.1 4.3 5.5 6.7 7.9 9.1 10.3 11.5 ...
And here
2010 Oct 19
1
Problems with a specific calculate.
Hello friends of R,
My name is Toni, i'm 25 and I'm working on the Meteorological Investigation team from Balearic Islands.
I had contact to you because I have a problem:
I done a file for every day since 1912 about precipitation. That file has the following structure:
> str(Ast)
Loading required package: sp
Formal class 'SpatialPixelsDataFrame' [package "sp"]
2024 Nov 06
1
Using multiple dat files
"It seems therefore that there is no other way than read in individually >
100 weather tables using read.tables., right? Using file.choose() doesn't
change the work."
Yes. With that many files, file.choose() does not make sense. However, I
still do not understand what is the problem with using lapply() on the
character vector of file names with read.table() as you did in your
2011 Dec 09
3
ggplot with geom_tile
Dear R-users,
I am trying to make a plot with ggplot-geom_tile(), but cannot remove some unwanted (white) lines through my plot.
Below a reproducible example:
#####
library(ggplot2)
tot=as.data.frame(rep(seq(-50,50,5),each=21))
names(tot)="precip"
temp=rep(seq(-5,5,0.5),21)
tot$temp=temp
disc=array(dim=c(21,21))
for(i in 1:21){
for(y in 1:21){
temp<-
2011 Mar 13
4
readMat - how to retrieve the variables
Hello
I have a matlab MAT file that contains one single variable: a. The
structure of a is as follows:
a.river1.flow (flow values)
a.river1.date_flow (date)
a.river1.precip (precipitation values)
a.river1.date_precip
a.river2.flow
a.river2.date_flow
a.river2.precip
a.river2.date_precip
I have used readMat to load the variable a in R, however I have no idea how
readMat translates a. I managed
2009 Jul 12
1
variance explained by each predictor in GAM
Hi,
I am using mgcv:gam and have developed a model with 5 smoothed predictors
and one factor.
gam1 <- gam(log.sp~ s(Spr.precip,bs="ts") + s(Win.precip,bs="ts") + s(
Spr.Tmin,bs="ts") + s(P.sum.Tmin,bs="ts") + s( Win.Tmax,bs="ts")
+factor(site),data=dat3)
The total deviance explained = 70.4%.
I would like to extract the variance explained
2005 Nov 07
2
how to export density_function output?
Dear all,
quite a naive question: I have a data frame and I computed "the kernel
density estimate" with density on each column.
Now I'd like to export in a txt file the density function output for each
column, but, when if I use write.table, I get a message "Error in
as.data.frame.default(x[[i]], optional = TRUE) : can't coerce class
"density" into a
2009 Jul 23
1
Creating a loop to read 3D dataset
Dear all,
I have in my possession a netcdf from which I want to extract some data files. I have used the "ncdf" package to read the netcdf file and used the "get.var.ncdf" function to identify the variable i wish to use. The data is in the form of a time-series of geographical data points that relate to climatology variables. As such I have a large data frame,
2013 Apr 18
1
Arranging two different types of ggplot2 plots with axes lined up
Hi all,
I want to arrange two ggplot2 plots on the same page with their x-axes
lined up - even though one is a boxplot and the other is a line plot. Is
there a simple way to do this? I know I could do this using facetting if
they were both the same type of plot (for example, if they were both
boxplots), but I haven't been able to figure it out for two different types
of plots.
Below is my
2007 Sep 10
1
overlay lattice histograms with goodness-of-fit pdfs
Hello,
I am new to R exploratory data analysis and plotting. Is anyone aware of a way
to overlay a set of conditional histograms with conditional PDFs? Below, I
generate a lattice plot of precipitation histograms based on different months
and stations, given a subset of the dataset:
histogram(~ data | month * station,
data = sta.stack[sta.stack[,"type"]=="precip" &
2024 Nov 06
3
Using multiple dat files
Dear community
To import multiple .dat weather files I am using list.files().
I intend to use the R package ?ClimInd? to calculate different agroclimatic indicators.
Question: Is there another solution to import multiple .dat files so that I can select elements from the list, e.g. one specific weather file (example AAR_DailyWeather)?
# Import multiple .dat files weather data
filelist <-