Displaying 20 results from an estimated 10000 matches similar to: "Any package recommended for time series graphics in R?"
2012 Oct 01
2
Input and output of time series data - any function or packages that helps?
Hello,
I work with time series data. From time to time I run programs to
produce results that are in time series form (e.g., quarterly or monthly
data). After a few days I might need to access part of the results and to
run another program. Is there any function or package (like dataframe or
zoo?) that might help so that I don't need to copy the results manually to
a csv or xls file?
2012 Apr 11
2
What is a better way to deal with lag/difference and loops in time series using R?
Hello,
I am writing codes for time series computation but encountering some
problems
Given the quarterly data from 1983Q1 to 1984Q2
PI1<-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485,
-1.190061246, -0.553031799, 0.686874720, 0.953911035),
start=c(1983,1), frequency=4)
> PI1
Qtr1 Qtr2 Qtr3 Qtr4
1983 2.747365190 2.791594762
2012 Feb 17
4
How can I tabulate time series data (in RStudio or any other R editor)?
Hello,
I have a question on how to tabulate the time series data. I use
RStudio, but if can be done in any other R editor, it should work in
RStudio as well.
> a1<-11:22
> a1ts<-ts(a1, frequency=4, start=c(1978,1))
> a1ts Qtr1 Qtr2 Qtr3 Qtr4
1978 11 12 13 14
1979 15 16 17 18
1980 19 20 21 22
If I click the variable "a1ts" on the
2013 May 03
10
Why can't R understand if(num!=NA)?
I have a program, when I write
if(num!=NA)
it yields an error message.
However, if I write
if(is.na(num)==FALSE)
it works.
Why doesn't the first statement work?
Thanks,
Miao
[[alternative HTML version deleted]]
2012 Feb 16
2
How can we access element(s) of a time series object?
Hello,
Let us convert a vector to a time series object starting in 1978Q1:
FRW<-ts(FRW0, frequency=4, start=c(1978,1))
FRW[3:6] represents the data from 1978Q3 to 1979Q2. Could we access the
data by the time (1978Q3 to 1979Q2) instead of FRW[3:6]?
Thanks,
miao
[[alternative HTML version deleted]]
2013 Jun 11
2
How can we access an element in a structure
Hi,
I have a structure, which is the result of a function
How can I access the elements in the gradient?
> dput(test1)
structure(-1.17782911684913, gradient = structure(c(-0.0571065371783791,
-0.144708170683529), .Dim = 1:2, .Dimnames = list(NULL, c("x1",
"x2"))))
> test1[[1]]
[1] -1.177829
> test1
[1] -1.177829
attr(,"gradient")
x1
2012 Feb 21
1
Questions on Data reading using zoo package
Hello,
I try to handle the data using read.csv , zoo and aggregate functions.
The data contains NA values. After aggregating monthly data into quarterly
data, all data become NA. Is it because I don't properly aggregate the data
in the presence of NAs? What can I do?
Another problem is that the date in month is presented in Chinese (My OS
is in Chinese.) How can I set the default
2016 Apr 26
2
How to print the frequency table (produced by the command "table" to Excel
Hi,
How could we print the frequency table (produced by "table") to an Excel
file?
Is there an easy way to do so? Thanks,
Miao
> df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3])
> table(df[,c("y","z")])
z
y a b c
1 0 0 1
2 0 1 0
3 1 0 0
> test<-table(df[,c("y","z")])
> as.data.frame(test)
y z Freq
1 1 a
2012 Feb 21
2
Debugging using RStudio or any other R editor
Hello,
I am using RStudio and have trouble finding out the problematic line in
the presence of a bug. Could I view the line NUMBER which contains a bug?
Is there any R editor able to do it?
Thanks,
Miao
[[alternative HTML version deleted]]
2012 Jul 27
2
How can I access an element of a string?
Dear Daniel and Jorge,
Thank you very much and it does help.
If I have a string "ABCD", how can I access the second element of the
string "B"? Thanks,
Miao
2012/7/27 Daniel Nordlund <djnordlund@frontier.com>
> > -----Original Message-----
> > From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org]
> > On Behalf Of jpm miao
2016 Apr 26
0
How to print the frequency table (produced by the command "table" to Excel
Hi jpm miao,
You can get CSV files that can be imported into Excel like this:
library(prettyR)
sink("excel_table1.csv")
delim.table(table(df[,c("y","z")]))
sink()
sink("excel_table2.csv")
delim.table(as.data.frame(table(df[,c("y","z")])),label="")
sink()
sink("excel_table3.csv")
2012 Apr 12
4
Definition of "lag" is opposite in ts and xts objects!
Example:
Will ts objects be obsolete or modified?
> a [,1]
1983 Q1 2.747365190
1983 Q2 2.791594762
1983 Q3 -0.009953715
1983 Q4 -0.015059485
1984 Q1 -1.190061246
1984 Q2 -0.553031799
1984 Q3 0.686874720
1984 Q4 0.953911035> lag(a,4) [,1]
1983 Q1 NA
1983 Q2 NA
1983 Q3 NA
1983 Q4 NA
1984 Q1 2.747365190
1984 Q2
2013 Apr 10
1
Plot two separate curves in R Graphics and R Lattice package
Hi,
How can I plot two curves with distinct x and y vectors? I would like to
join one of them by regular lines and plot the other just by points (no
lines). Can it be done in regular R graphic tools, say "plot" function?
Can it be done in Lattice package, say "xyplot" function?
Thanks,
Miao
My data look like this: two curves with different vector size
x
2013 Apr 17
3
Transformation of a variable in a dataframe
HI,
I have a dataframe with two variable A, B. I transform the two variable
and name them as C, D and save it in a dataframe dfcd. However, I wonder
why can't I call them by dfcd$C and dfcd$D?
Thanks,
Miao
> A=c(1,2,3)
> B=c(4,6,7)
> dfab<-data.frame(A,B)
> C=dfab["A"]*2
> D=dfab["B"]*3
> dfcd<-data.frame(C,D)
> dfcd
A B
1 2 12
2 4 18
2012 Jul 31
2
How can I declare an empty zoo object?
Hi,
I let xzoo be an empty object:
> xzoo<-{}
and I have an existing zoo object x1zoo_f. I would like to combine
the two to make a new zoo object, and continue doing so in a loop,
which is not shown here. However, when I type
> xzoo<-cbind(xzoo, x1zoo_f)
An error message emerges
Error in zoo(structure(x, dim = dim(x)), index(x), ...) :
“x” : attempt to define
2013 Apr 08
2
How can I extract part of the data in a panel dataset?
Taking the Grunfeld data, which is built-in in R, for example,
(1)How can I construct a dataset (or dataframe) that consists of the data
of all firms in 1951?
(2)How can I calculate the average capital in each form over the period
1951-1954?
What I can imagine is to categorize the data by firm, and then select the
data between 1951 and 1954 for each firm, but how can I do it?
Thanks,
Miao
2012 Mar 22
1
Questions on plotting using zoo toolbox: (1) dual axes (2)legend
Hi,
I have three time series and I would like to plot them on the same graph
such that two of them share left y-axis and the third uses right y-axis.
rm(list=ls())
library(zoo)
x1 <- read.csv(file="120322DBCdata.csv", header=TRUE)
x1date<-as.yearqtr(1979)+seq(0,nrow(x1)-1)/4
x1zoo<-zoo(x1, x1date, frequency=4)
x1zoodata<-cbind(x1zoo$D4GDP, x1zoo$D4NE,
2013 May 03
2
Declare a set (list?) of many dataframes or matrices
Hi,
I would like to read several datasets and would like to create a set
(list? sequence?) of many empty dataframes. How could this be done? How
could I declare a set (list? sequence?) of many empty matrices?
Thanks,
Miao
[[alternative HTML version deleted]]
2012 Mar 12
3
A question on histogram - area much less than 1
Hello,
I have problem running the histogram function "hist". The area under the
histogram is much lower than 1. Could anyone tell me what the problem is?
Thanks,
(The total number of observation is 992 (close to 1000), so the
probability that 0<Y1<35 is approximately 0.277)
miao
rm(list=ls())
par(mfrow=c(1, 1))
Y <- cbind(matrix(35*0.5,1,277), matrix(35*1.5, 1, 146),
2013 Apr 30
2
Is there a function that print a string vertically (by adding "\n")?
Hi,
I'd like to print a string vertically. For example, I would like to print
"abcd" as "a\nb\nc\nd"
Is there a function in R such that
Input: "abcd"
Output: "a\nb\nc\nd"?
Thanks,
Miao
[[alternative HTML version deleted]]