[R] Use "append" in the function write.xlsx2 or write.xlsx (openxlsx package)

2016-05-02 Thread jpm miao
Hi, I am trying to print several dataset in several different sheets of the same xlsx file. I sometimes run the codes more than once, and I need to erase all things in the target file, and I do not use "append" in the first function call. However I want to write it in a loop. Is there a way to

[R] Extracting rows of a data.frame by "identical"

2016-05-02 Thread jpm miao
Is it possible? I am expecting the result to be the second row of the data frame ... d<-data.frame(a=1:3, b=3:5,c=9:11) > d a b c 1 1 3 9 2 2 4 10 3 3 5 11 > d[identical(d[c("b","c")],c(4,10)),] [1] a b c <0 rows> (or 0-length row.names) [[alternative HTML version deleted]]

[R] Can't rename a data frame column

2016-05-02 Thread jpm miao
Hi, Could someone suggest a way to rename a data frame column? For example, I want to rename the column beta, but I can't do it this way > d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9) > mm<-"beta" > rename(d, c(mm="two", "gamma"="three")) The following `from` values were not present in `x`:

Re: [R] How to print the frequency table (produced by the command "table" to Excel

2016-04-30 Thread jpm miao
Thanks. Could we print the row/column names, "alpha1" and "alpha2" to the csv file? 2016-04-30 17:06 GMT-07:00 Jim Lemon : > Hi jpm miao, > I think you can get what you want like this: > > alpha1<-sample(LETTERS[1:3],50,TRUE) > alpha2<-sample(LETTERS[

Re: [R] How to print the frequency table (produced by the command "table" to Excel

2016-04-30 Thread jpm miao
ered (See the attached csv file). 1. When I tried to print the above table to csv file, all elements on the same row are printed in one cell. 2. If I write "delim.table(alpha tab)", the table is distorted (see attached). Of course, I can adjust it manually but sometimes the number of files is

[R] How to print the frequency table (produced by the command "table" to Excel

2016-04-26 Thread jpm miao
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

[R] table , exclude - count the frequency in a data frame but exclude one value

2016-04-26 Thread jpm miao
Hi, I have a data frame with two variables x, y, both of which take values in the set {1,2,3}. I'd like to count the frequency by the command "table", but exclude the value "1" in variable x, but keep "1" in variable y. Is it possible? When I use "exclude", value 1 in both x and y are excluded

[R] Java memory error when reading a small xlsx file

2016-04-23 Thread jpm miao
=TRUE) detach("package:rJava", unload=TRUE) options(java.parameters = "-Xmx8000m") library(XLConnect) library(xlsx) ### but it did not work. I am on a Mac, with very new OS and very new R version. R version 3.2.4 (2016-03-10) Platform: x86_64-apple-darwin13.4

[R] Add a vertical arrow to a time series graph using ggplot and xts

2016-04-18 Thread jpm miao
s follows, but I got an error message at the last line "Error: Invalid input: date_trans works with objects of class Date only". Sometimes the error message occurs when I run the program, sometimes it does not occur until I call the plot "p1". How could I add a

[R] How to print the graphs in landscape/portrait orientation (revised)

2016-04-09 Thread jpm miao
Hi, I made a few graphs by ggplot. The following codes produce a pdf file with graphs, sometimes in landscape orientation, sometimes in portrait orientation. I am using both Mac and Windows PC. Question: how can I control the orientation of the pdf file? I try to add a line pdf(pap

[R] How to print the graphs in landscape/portrait orientation

2016-04-09 Thread jpm miao
Hi, I made a few graphs by ggplot. The following codes produce a pdf file with graphs in landscape orientation on my Windows PC, while they produce a pdf file with the same graphs, but in portrait orientation: *p2 <- lapply(1:(2*n), function(.x) xyz_outl[.x][[1]]) #a sequence of graphs made b

[R] readWorksheetFromFile error message: invalid 'envir' argument

2016-01-15 Thread jpm miao
rk, but sometimes it does not. When it does not run, restarting RStudio sometimes works. How can I fix the problem? Thanks, > date_col<-readWorksheetFromFile("dt-160FXO_many_xyz_data.xlsx", sheet=2, region="A1:A3137") Error in ls(envir = envir, all.names =

[R] How can we let "multiplot.R" return a plot?

2016-01-14 Thread jpm miao
_one_page_(ggplot2)/, and the code is as below. Any advice on returning a multi-ggplot would help! Thanks, Miao # Multiple plot function # # ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) # - cols: Number of columns in layout # - layout: A matrix specifying

[R] Could the function "addPlot.RTF {rtf}" add multiplots to Word?

2016-01-13 Thread jpm miao
lternative would help! Thanks!! Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/

[R] Is there any concise way to write a one-to-one mapping?

2015-09-14 Thread jpm miao
My code is: if(type=="none") type2<-"nc" if(type=="drift") type2<-"c" if(type=="trend") type2<-"ct" I am wondering if there's a concise way to write a mapping from type to type2, especially when the number of categories is high. Thanks! [[alternative HTML version deleted]]

[R] Make a Excel chart by R code

2015-04-14 Thread jpm miao
Hi, I understand that there're many great graphic packages in R (e.g., ggplot2) . Nevertheless, my office uses Excel extensively. Is there any package in R that produces Excel graphs by R codes? Thanks! [[alternative HTML version deleted]] _

[R] r2wd (Write R to Word) in Chinese

2015-03-19 Thread jpm miao
Hi, The package "r2wd" is good at writing MS Word document from R. Can Chinese be written into MS Word by this package or any other method from R? Are Chinese fonts (e.g., Kai 楷書) available in r2wd? Thanks! [[alternative HTML version deleted]]

[R] Which is better: Modifying an existing package or creating a new one?

2015-03-19 Thread jpm miao
create a new program. Which is a better way in terms of time consumption and code portability? If I move the codes to a new computer, which way will be easier? Any suggestion? Thanks, Miao [[alternative HTML version deleted]] __ R-help

[R] An easy question on package building/installation

2015-03-18 Thread jpm miao
Hi, I try to build a package myself on RStudio. The command "package.skeleton" is successfully run, but the command "build" is not. In my case, the username and the package name are both "abcd". Error message: > R CMD build abcd Error: unexpected symbol in "R CMD" > Could someone he

[R] Segmented (piecewise linear) regression/cointegration

2015-03-17 Thread jpm miao
Hi, If the relation between y and x is piecewise linear, the package "segmented" can be used to model it. It works pretty well. My situation is a little different: y and x are both I(1). Is there an R-package dealing with this situation? If not, is there an econometrics paper on this issue?

Re: [R] Extracting slots from an object (e.g.: object produced by unit root test function "urdfTest")

2015-03-12 Thread jpm miao
Sorry. Let me modify the question: Does there exist any unit root test function (with trend or intercept) where the p-value can be extracted? The function adf.test in tseries package does return the p-value, but there's no choice of trend or intercept. Thanks. 2015-03-13 10:49 GMT+08:00 jpm

Re: [R] Extracting slots from an object (e.g.: object produced by unit root test function "urdfTest")

2015-03-12 Thread jpm miao
summary(lc.df) 2015-03-13 1:23 GMT+08:00 David Winsemius : > > On Mar 12, 2015, at 1:04 AM, jpm miao wrote: > > > Hi, > > > > I run a statistical test function in the package "fUnitRoots" that > > returns a S4 object but I am wondering how to extrac

[R] Extracting slots from an object (e.g.: object produced by unit root test function "urdfTest")

2015-03-12 Thread jpm miao
Hi, I run a statistical test function in the package "fUnitRoots" that returns a S4 object but I am wondering how to extract the p-value, one of the output elements. The document of the function "urdfTest": . All tests return an object of class "fHTEST" with the following slots: @call ...

[R] Add an NA column to a zoo object

2014-10-22 Thread jpm miao
Hi , I have a zoo object with several rows fx, r3m, etc. I would like to create in the zoo object the lag of one column. One thing I can think of is to create the lag first and then merge it into the original zoo object, which is tedious. Can I add an NA column to the zoo object first and then p

Re: [R] Dealing with NAs in lm or gmm

2014-10-21 Thread jpm miao
Tukey > > > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens jpm miao > Verzonden: dinsdag 21 oktober 2014 10:29 > Aan: r-help > Onderwerp: [R] Dealing with NAs in lm or gmm > > Hi, > >My question is

[R] Dealing with NAs in lm or gmm

2014-10-21 Thread jpm miao
e is NULL, no action. Value na.exclude can be useful. Thanks! Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.or

[R] lag operator on a zoo object - code sharing

2014-10-15 Thread jpm miao
Hi, I could not find a nice lag operator on zoo object. Perhaps there is, but I just couldn't find it. Basically I want the operator to return the lagged zoo object (with one or more variables ) with the original date. For example, if I write lag(x, -3), then I got the lagged series, but the fir

[R] ggplot "scale_x_date" : to plot quarterly scale?

2014-10-14 Thread jpm miao
Hi, I am plotting time series by ggplot2, but I believe that my question applies to other plotting tool as well. I want to make my x-axis the quarterly scale, e.g: 2000Q1 2000Q2. However, scale_x_date and date_format("%m/%d") support all time formats BUT QUARTERs library(sca

[R] Find growth rate of a zoo (time series) object

2014-10-07 Thread jpm miao
Hi, Is there any way to find the growth rate of a quarterly/monthly time series? For example, I have a quarterly CPI level series, and I wonder how to find the CPI growth rate (inflation rate). Is there easier way to convert to another class and convert back? Thanks! > dput(dtz[1:16,"CPI"])

[R] Time series Regression with lags

2014-10-07 Thread jpm miao
Hi, I am working on zoo (time series) objects. Is there any way to do a time series regression with a lag period? E.g., Y(t) = b1*X1(t)+b2*X(t-1)+b3*X2(t) Is "dynlm" the default one to use? Anything else Thanks! [[alternative HTML version deleted]] __

[R] aggregating a zoo object (monthly data to quarterly data)

2014-10-06 Thread jpm miao
I tried to convert a monthly dataset to quarterly by averaging dt_mz<-zoo(dt_m, dt_m$date_m) dt_mz2q<-aggregate(dt_mz, as.yearqtr, FUN=mean) However, the resulting zoo object are just NAs How can I get a quarterly average dataset? Thanks! > dput(dt_mz) structure(c("Jan 1981", "Feb 1981", "Mar 1

Re: [R] "timeDate" package: Read dates from xls or txt

2014-09-29 Thread jpm miao
O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On September 29, 2014 2:47:01 AM PDT, jpm miao

Re: [R] Could someone recommend a package for time series?

2014-09-29 Thread jpm miao
Thanks Pascal! It certainly helps! 2014-09-29 17:10 GMT+08:00 Pascal Oettli : > Hi Miao, > > You certainly will find useful answers here : > http://cran.r-project.org/web/views/TimeSeries.html > > Regards, > Pascal Oettli > > On Mon, Sep 29, 2014 at 6:05

[R] "timeDate" package: Read dates from xls or txt

2014-09-29 Thread jpm miao
(e.g., I usually use XLConnect to read xls files) to the date? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

[R] Could someone recommend a package for time series?

2014-09-29 Thread jpm miao
t; maybe there're some updates (which I don't know) now. Could someone recommend a package or provide an example (or just the document, I can read it) for my purpose? Attached is an exemplary data set I talked about. Thanks, Miao __ R-

[R] NAG (NAGFWrapper) or any optimization package recommended?

2014-03-13 Thread jpm miao
Hi, Is there any optimization package in R recommended for general purposes (constrained, unconstrained, etc)? Has anyone used the function in NAGFWrapper package http://www.nag.co.uk/numeric/R/r-package Are the optimization functions therein available for free? Thanks, Miao

[R] Find the prediction or the fitted values for an lm model

2013-11-27 Thread jpm miao
Hi, I would like to fit my data with a 4th order polynomial. Now I have only 5 data point, I should have a polynomial that exactly pass the five point Then I would like to compute the "fitted" or "predict" value with a relatively large x dataset. How can I do it? BTW, I thought the mode

[R] Find the cutoff correlation value for Pearson correlation test

2013-11-14 Thread jpm miao
correlations between two time series, and I would like to add a horizontal line that marks the significance of the correlations. Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

[R] Test for exogeneity

2013-11-11 Thread jpm miao
us in that y1 impacts y2 contemporaneously but not the other way around. Given a bivariate dataset, is there any statistical test (in any R package or elsewhere) that helps to justify/test the exogeneity of y1 in the present context? Is there any reference available? Thanks, Miao [[a

[R] Lag selection in Unit Root Test

2013-08-21 Thread jpm miao
s gives lags =12. Could the function choose the lags from a range (say, 1-12) based on information criteria (AIC or BIC)? Thanks, Miao __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting g

[R] Problem when running an SVAR-AB model in vars package

2013-08-06 Thread jpm miao
Is "B" a reserve word in vars package? I tried to run an SVAR-AB model by SVAR function and find the IRF in vars package. The problem is that when B matrix is named by "B", an error message occurs. However, if the same matrix is named by "Bm", then things run smoothly. What's wrong? Is "B" a rese

[R] Compiling a C++ file in RStudio?

2013-08-06 Thread jpm miao
e says yes: http://learndataanalysis.com/you-can-now-source-c-file-rstudio Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] Reserve word "in" could not be used it as a "dimname"?

2013-07-10 Thread jpm miao
Just wonder why R does not remind me so when I use it as a dimname... 2013/7/11 Pascal Oettli > Hello, > > "in" is a reserved word. > > ?Reserved > > Hope this clarifies, > Pascal > > > > 2013/7/11 jpm miao > >> Hi, >> >>

[R] Reserve word "in" could not be used it as a "dimname"?

2013-07-10 Thread jpm miao
Hi, I have a matrix whose columns are named as "in" and "out". Then I coerce it to be a data.frame. However the system seems to forbid me from using the name "in", but I am not aware of it until I call it by the dollar sign $. Is there something R should remind me but it does not? Is there any

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
Hi, What do you mean by "Windows in a Windows console window"? Is it the black screen of DOS? I change the directory of the DOS window to D:\R\pkgtest D:\R\pkgtest\test1pkg and run the command R CMD build test1pkg under each of the two paths, and the error message rema

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
I ran it in a common window of R. It's said that I need to run it under DOS. I also open the command window of DOS C:\Documents and Settings\miao ,where miao is my username, and ran it, but it doesn't work either. An error message emerges. Miao 2013/6/20 Pascal Oettli > Hi, &g

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
tories ... Error in package.skeleton(list = c("f", "g", "d", "e"), name = "test1pkg", : directory 'D:/R/pkgtest/test1pkg' already exists > R CMD build test1pkg Error: unexpected symbol in "R CMD" Is there anything else I ne

[R] “arch.test” in “vars” package with multivariate.only = FALSE

2013-06-17 Thread jpm miao
regression, H_0: \theta_i = 0 for all i against H_1: H_0 is false, for all k? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

[R] Problems with R package building

2013-06-13 Thread jpm miao
and prompt window?). However it does not work in my DOS window either. Could someone tell me how to process the package building process? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://st

[R] How can we access an element in a structure

2013-06-10 Thread jpm miao
; test1[[1]] [1] -1.177829 > test1 [1] -1.177829 attr(,"gradient") x1 x2 [1,] -0.05710654 -0.1447082 > test1["gradient"] [1] NA Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-p

[R] Create a package with "package.skeleton"

2013-06-10 Thread jpm miao
as little time as possible editing the documentation. I almost do nothing on "man" and "namespace". (Is that ok?) What should I do next? How can I run "build" and "check" commands? Thanks Miao [[alternative HTML version deleted]] ___

[R] Could graph objects be stored in a "two-dimensional list"?

2013-05-23 Thread jpm miao
ction is easy to write, but just want to make sure whether it exists already) Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] convert a character string to a name

2013-05-23 Thread jpm miao
Hi, From time to time I need to do the aggregation. To illustrate, I present a toy example as below. In this example, the task is to aggregate x and y by z with the function mean. Could I call the aggregation function with x_test, where x_test=c("x","y")? Tha

[R] Find the indices of non-NA elements of a sequence

2013-05-16 Thread jpm miao
Hi, I have a sequence whose 1st, 3rd, 4th, 6th are non-NAs. How could I let R return 1,3,4,6, the indices? I know only how to find the non-NA elements. Thanks, Miao > test<-c(2,NA,6,8,NA,12) > test[is.na(test)==FALSE] [1] 2 6 8 12 [[alternative HTML versio

[R] How could I see the source code of functions in an R package?

2013-05-16 Thread jpm miao
Hi, How could I see the source code of functions in an R package? If we type ?function_name , we will see documentations of the function_name. If we type function_name, is what returns just the source code? Could we just save it in an .R file and modify as we want? However, it seems that

[R] How can I extract part of the data with a selection criterion?

2013-05-09 Thread jpm miao
Hi, As an example, how can I get the data such that field a of ab, ab["a"], equals 3? I expect the answer to be the union of 2 and 4, as Thanks, > a<-c(1,3,4,3,5,6,5) > b<-c(2,4,6,7,3,1,2) > ab<-data.frame(a,b) > ab a b 1 1 2 2 3 4 3 4 6 4 3 7 5 5 3 6 6 1 7 5 2 > ab[a==3] Error in `[.da

Re: [R] How can I find negative items from a vector with a short command?

2013-05-08 Thread jpm miao
Sorry. I just got it > f[f==4] [1] 4 2013/5/8 jpm miao > Thanks, but why does f[f=4] yield 16 instead of 4? > > > f > [1] -24 -8 16 -32 64 -128 > > f[f<0] > [1] -2 -8 -32 -128 > > f[f>0] > [1] 4 16 64 > > f[f=4] >

Re: [R] How can I find negative items from a vector with a short command?

2013-05-08 Thread jpm miao
Thanks, but why does f[f=4] yield 16 instead of 4? > f [1] -24 -8 16 -32 64 -128 > f[f<0] [1] -2 -8 -32 -128 > f[f>0] [1] 4 16 64 > f[f=4] [1] 16 2013/5/8 Jorge I Velez > f [ f < 0 ] > > > On Wed, May 8, 2013 at 11:54 AM, jpm miao wrote:

Re: [R] Calculates the mean/median from grouped data in R?

2013-05-07 Thread jpm miao
the median of the data with the assumption that all data points inside each interval are evenly distributed. Are there such functions in R? 70-80480-90590-1008100-1107110-1203 2013/5/8 David Winsemius > > On May 7, 2013, at 8:40 PM, jpm miao wrote: > > > Is there a function in R

[R] Calculates the mean/median from grouped data in R?

2013-05-07 Thread jpm miao
Is there a function in R that calculate the mean and median for a grouped data? For example, a survey shows the oil price outlook in the future. How can I calculate the mean/median? (Of course, I understand that the groups "below 80" and "above 110" must be defined more specifically) below 80 4

[R] How can I find negative items from a vector with a short command?

2013-05-07 Thread jpm miao
Hi, I have a vector f with some negative columns. I remember that there is an easy expression that can find out negative items. Can someone tell me how I can do it? It seems to be f[i such that f[i]<0 ...] Thanks, Miao > d<-1:7 > f<-(-2)^d > f [1] -24

[R] Merge two dataframe with "by", and problems with the common field

2013-05-06 Thread jpm miao
e see the example below. Thanks Miao > d1 a b c 1 1 4 5 2 2 5 6 3 3 6 7 > d2 d a f b 1 6 1 8 4 2 7 2 9 5 3 8 3 10 6 > d3<-merge(d1, d2, by="b") > d3 b a.x c d a.y f 1 4 1 5 6 1 8 2 5 2 6 7 2 9 3 6 3 7 8 3 10 > d3["a"] Error in

[R] How can I access the rowname of a data?

2013-05-06 Thread jpm miao
? How can I build a dataframe consisting of two columns, the company name (code) and the efficiency? as.data.frame(a) produce only a column with company names, where company names are not accessible. Thanks, Miao > a efficiency 4 0.26902196 5 0.30967213 6 0.33841116 7 0.36174

[R] Why can't R understand if(num!=NA)?

2013-05-03 Thread jpm miao
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]] __ R-help@r-projec

[R] Declare a set (list?) of many dataframes or matrices

2013-05-03 Thread jpm miao
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

Re: [R] Problems with reading data by readWorksheetFromFile of XLConnect Package

2013-05-02 Thread jpm miao
Hi Anthony, Thank you very much. It works very well. However, after this line > temp <- sapply( temp , as.numeric ) the data becomes a series of numbers instead of a matrix. Is there any way to keep it a matrix? Thanks, Miao > temp<-readWorksheetFromFile("130502

Re: [R] Stochastic Frontier: Finding the optimal scale/scale efficiency by "frontier" package

2013-05-02 Thread jpm miao
/crp4700/coelli_Intro_effic.pdf According to my friend working on panel data, the case where efficiency >1 is seldom/never encountered, but the book says the opposite. Thanks, Miao 2013/4/25 Arne Henningsen > Dear Miao > > On 25 April 2013 03:26, jpm miao wrote: > > I am tryi

[R] Problems with reading data by readWorksheetFromFile of XLConnect Package

2013-05-01 Thread jpm miao
. How can I read the datasheet as numbers? 2. How can I treat the notation "-" as (1) "NA" or (2) zero? Thanks, Miao > temp<-readWorksheetFromFile("130502temp.xlsx", sheet=1, header=FALSE, startRow=2, endRow= 11, startCol=2, endCol=5) > temp

[R] Extrafont package: Fonts are not successfully installed

2013-04-30 Thread jpm miao
New Romans, Arial Black. Error message: "Font family not found in Windows font database." 3. The plot could not show up at all. I use RStudio. I need to close RStudio and reopen it in order to see the plots produced by ggplot2 . Could someone provide an example of how Extrafo

[R] Is there a function that print a string vertically (by adding "\n")?

2013-04-29 Thread jpm miao
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]]

[R] Stochastic Frontier: Finding the optimal scale/scale efficiency by "frontier" package

2013-04-24 Thread jpm miao
t;1. How can I do it with frontier package? Is there any other SFA model/function in R recommended to find out the scale efficiency and optimal scale? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing l

[R] Questions on function "readNamedRegionFromFile" in XLConnect pacakge

2013-04-22 Thread jpm miao
my computation is right, AK is the 37th column. Then I need to tell the computer to read the 37th column, row 9 to row 18. Can I ask the function (any function in the package) to read the column by the header name (say, the name saved in AK1) instead of "37th"? Thanks, Miao

[R] How can I ask R to skip the title when reading the data?

2013-04-18 Thread jpm miao
School Grade Report Confidential Yes”, I can just change the xls to csv and read them via read.csv. How can I read the data in the presence of the title? How can I ask R to skip the title and just read the data? Thanks, Miao [[alternative HTML version deleted

[R] Transformation of a variable in a dataframe

2013-04-16 Thread jpm miao
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[&q

[R] Is it possible to create Dual y axes with ggplot2 package?

2013-04-15 Thread jpm miao
provided here http://onertipaday.blogspot.tw/2010/01/scatter-plot-with-4-axes-labels-and.html Is it possible to modify the code so that it produces ggplot2 style dual-axis graph? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
Hi David, Thanks. How can I make the graph in log scale? Thanks Miao 2013/4/11 David Winsemius > > On Apr 10, 2013, at 6:11 PM, jpm miao wrote: > > Thanks for your comments, David > > avg_cost_2012 and asset_2012 are numeric vectors of length 39 > > while x2 a

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
Thanks for your comments, David avg_cost_2012 and asset_2012 are numeric vectors of length 39 while x2 and y1 are longer vectors whose range is about the same as (avg_cost_2012, asset_2012) I also present the data by dput below. Is it clear? Thanks, Miao asset_2012 avg_cost_2012 1 3973730.0

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
ee the points "p" of "avg_cost_2012 ~ asset_2012", but do not see the line for y1 against x2. y1 and x1 are numeric vectors of the same size. How can I fix it? Thnaks Miao 2013/4/10 David Winsemius > > On Apr 9, 2013, at 8:21 PM, jpm miao wrote: > > Thank you

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread jpm miao
Thank you very much. Could it be done in Lattice package? Thanks, Miao 2013/4/10 Janesh Devkota > Hi, > > This should be fairly easy by using base R graphics. > > Lets suppose your first data is represented by (x1,y1) and second data is > represented by (x2,y2) > > Y

[R] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread jpm miao
function? Thanks, Miao My data look like this: two curves with different vector size x y 3973730 0.00322 2391576 0.003487 2840944 0.005145 2040943 0.006359 1982715 0.006253 1618162 0.00544 820082.3 0.004213 1658597 0.004883 1762794 0.006216 93439.5 0.004255 218481

[R] How can I extract part of the data in a panel dataset?

2013-04-08 Thread jpm miao
, and then select the data between 1951 and 1954 for each firm, but how can I do it? Thanks, Miao Grunfeld data: invest value capital firm year 317.6 3078.5 2.8 General Motors 1935 391.8 4661.7 52.6 General Motors 1936 410.6 5387.1 156.9 General Motors 1937 257.7 2792.2 209.2 General Motors

[R] Generating a bivariate joint t distribution in R

2013-04-02 Thread jpm miao
joint distribution (beta1, beta2), where both beta1 and beta2 follow t distribution. How could we generate a joint t distrubuition in R? Thanks Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https

[R] Change the Chinese/English fonts in the Lattice graphic package

2013-03-12 Thread jpm miao
s boldface, while 3 represents italics. Where should I add it? (2) The default Chinese character seems to be ²Ó©úÅé (Shi Ming Tee). How can I change it to Kai -Shu (·¢®Ñ)? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org

[R] About multivariate GARCH: DVEC and BEKK

2013-02-20 Thread jpm miao
t located on the official R site. This is the latest version I can find, where the programs were uploaded 2 years ago. https://github.com/vst/mgarch/downloads Are there later versions? Is there a manual on the functions? Thanks, Miao [[alterna

[R] Are there multivariate GARCH packages in R?

2013-02-18 Thread jpm miao
Hi , Are there any multivariate GARCH package (e.g., BEKK) in R? I do see a few "projects" constructing multivariate GARCH package, but wonder if there is anyone that is ready for use. Thanks, Miao [[alternative HTML versi

[R] Do we have GARCH-in-mean VAR in R?

2013-02-05 Thread jpm miao
Hi everyone, Do we have GARCH-in-mean VAR in R? Is there any GARCH package in R? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] How can I read the following complicated table

2012-12-13 Thread jpm miao
, but I just present a simpler case for ease of illustration. Is there any way to ask R to "read several number after you see the word 'Monday' and store somewhere", and read several number after you see the word 'Tuesday' and store somewhere"? Thanks, miao

[R] Can pgmm in the plm package include additional endogenous variables?

2012-11-09 Thread Ruiqing Miao
Dear R-Users, I am using pgmm in the plm package to estimate a dynamic models with panel data. Besides the lagged dependent variable, I also have some other endogenous variables. Does the pgmm have an argument that allows me to specify these endogenous variables and their instruments? I didn't

[R] A question on "xyplot" function in Lattice package

2012-11-07 Thread jpm miao
t I can't find a complete list of the choices. The info obtained from the query in R is limited. Could anyone tell me where I can find the complete description of the function, including all types of lines it offers? Thanks! Miao [[al

[R] Input and output of time series data - any function or packages that helps?

2012-09-30 Thread jpm miao
zoo?) that might help so that I don't need to copy the results manually to a csv or xls file? If the data are not time series (just indexed by 1, 2,3), is there any function that can help? Thanks, Miao [[alternative HTML version de

[R] Questions about the functions ar.ols and auto.arima when fitting an AR model

2012-09-27 Thread jpm miao
Could they both use the function predict to do forecasting? Is there any function that works better? temp1<-predict(m1, n.ahead=4) PI.fore[i,j]<-temp1$pred[4] Thanks Miao [[alternative HTML version deleted]] __ R

Re: [R] Is there a function that runs AR model with Schwarz Bayesian Information Criteria (BIC)?

2012-09-27 Thread jpm miao
Thanks. Which function I can use for forecasting if I use the function "auto.arima()"? Should I use the function "forecast" or "predict" or anything else? Thanks, Miao 2012/9/27 Jose Iparraguirre > You'll find this in the forecast package, function a

[R] Is there a function that runs AR model with Schwarz Bayesian Information Criteria (BIC)?

2012-09-27 Thread jpm miao
Hello, Is there a function in R by which one can run AR model with Bayesian Information Criteria (BIC)? To my knowledge, functions ar and ar.ols could select the order only by AIC. Thanks, Miao [[alternative HTML version deleted]] __ R

[R] Adding legends on plots using Lattice package

2012-09-17 Thread jpm miao
quot;, header=TRUE) xts<-ts(data1[,2:9],frequency = 4, start = c(1983, 1)) xyplot(xts, screen=list("a","a","b","b","c","c","d","d"), layout=c(2,2), scales=list(x="same",y="same")) Miao

[R] How can I find the principal components and run regression/forecasting using dynlm

2012-08-27 Thread jpm miao
Hello, I would like to write a program that compute the principal components of a set of data and then 1. Run the dependent variable against the principal components (lagged value) 2. Do prediction , following Stock and Watson (1999) "Forecasting Inflation". All data are time series.

[R] Accessing the (first or more) principal component with princomp or prcomp

2012-08-22 Thread jpm miao
will the results be the same? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html a

Re: [R] How should one handle "NA" properly in a .csv dataset?

2012-08-22 Thread jpm miao
Hi, I find the problem. Some of the numbers like "1357" are presented as "1,357". After deleting the comma, everything is ok. Thank you for your attention! Miao 2012/8/22 jpm miao > Hi, > >I am reading several .csv file of time series. Some values of the

[R] How should one handle "NA" properly in a .csv dataset?

2012-08-22 Thread jpm miao
ot;NA", but they can't be properly read. When I check the difference between the two types of "NA", I find: Those can be read are outputed as "NA". Those can't be read (which I change from the blank) are outputed as "". C

[R] Symbolic computation in R-solving system of equations

2012-08-15 Thread jpm miao
or any other package can do it. I do not find the solution in Ryacas. Can it find a symbolic solution to a linear system? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] Zoo object problem: Find the column name of a univariate zoo object

2012-08-09 Thread jpm miao
Hi Michael, This is my problem. Could you find out how I can find the column name of the zoo object "xzoo"? I am expecting "EUR". Thanks, Miao > x<-read.csv("A_FX_EUR_Q.csv", header=TRUE)> x[1:4,]TIME EUR 1 198001 1.41112 2 198002 1.39108

  1   2   >