[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

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 <drjimle...@gmail.com>: > Hi jpm miao, > I think you can get what you want like this: > > alpha1<-sample(LETTERS[1:3],50,TRUE) > a

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

2016-04-30 Thread jpm miao
table(alphatab) > sink() > ?delim.xtab 2016-04-26 16:14 GMT-07:00 Jim Lemon <drjimle...@gmail.com>: > 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

[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 0 3 1 0 0 > test<-table(df[,c("y","z")]) >

[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

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

2016-04-23 Thread jpm miao
Hi, I tried to read a (small) xlsx file by "readWorksheetFromFile" function of "XLConnect" package and "read.xlsx" function in "xlsx" package, but I got this error message: Error: OutOfMemoryError (Java): Java heap space I tried to follow the solution on the web

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

2016-04-18 Thread jpm miao
Hi, I am trying to add a vertical arrow (from top to bottom or from bottom to up) to a time series plot using ggplot2 and xts. It seems that the vertical line command "geom_vline" does not work for this purpose (Correct me if I am wrong). I try the command "geom_segment" as follows, but I got

[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

[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

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

2016-01-15 Thread jpm miao
Hi, I try to read a large xlsx file from by the function "readWorksheetFromFile" in "XLConnect" package. Sometimes it works, but sometimes it gives an error message. When it does not work and I try to run the program line by line (in RStudio), then it would sometimes work, but sometimes it

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

2016-01-14 Thread jpm miao
Hi, The function "ggplot" does plot and return a plot. For example, we can write: y = ggplot(.. .) Then y is a plot. How can we modify the multiplot function so that it can also return a plot? Multiplot.R is here:

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

2016-01-13 Thread jpm miao
Hi, I am outputting a large number of graphs (made by ggplot2) to a Word file. The function "addPlot" in the package "rtf" does help output the graphs sequentially in one column; can it be modified so that it outputs graphs in more than one columns? (I try R2wd package, but it does not

[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] Which is better: Modifying an existing package or creating a new one?

2015-03-19 Thread jpm miao
Hi, Given that I frequently use A, B, C, D, E packages. In each of the 5 packages, I intend to modify one of the functions. Two ways: 1st: Modify A, B, C, D, E to A', B', C', D', E' Then I will use library(A') . library(E') instead of A, B, C, D, E. or Just keep the names A,

[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] 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 help me to

[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?

[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 .

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

2015-03-12 Thread jpm miao
) 2015-03-13 1:23 GMT+08:00 David Winsemius dwinsem...@comcast.net: 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 extract the p-value, one of the output elements

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 miao

[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

[R] Dealing with NAs in lm or gmm

2014-10-21 Thread jpm miao
Hi, My question is about NAs in the function gmm, but I believe that the same issues occur in the case of lm. I try to estimate a model by gmm function (GMM, generalized method of moments). Each of the variables has 94 rows, but the resulting fitted model has only 89 rows. Then the

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

2014-10-21 Thread jpm miao
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens jpm miao

[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

[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

[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] 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] 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 1981,

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

2014-09-29 Thread jpm miao
Hi, I've not used R for about one year and don't know well about the updates on the time series-related package. My primary job is to do economic/financial time series data analysis - annual, monthly, daily, etc. I usually read data by the package XLConnect, which can read xls or xlsx files

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

2014-09-29 Thread jpm miao
Hi, timeDate package create a date vector like this: Dates - c(1989-09-28,2001-01-15,2004-08-30,1990-02-09) I have a date whose size is large. Could this package read the dates from xls or txt files? Could we convert the read vector (e.g., I usually use XLConnect to read xls files) to

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 kri...@ymail.com: 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 PM, jpm miao miao...@gmail.com

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

2014-09-29 Thread jpm miao
#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On September 29, 2014 2:47:01 AM PDT, jpm miao miao...@gmail.com wrote: Hi, timeDate package create a date vector like this: Dates - c

[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 model

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

2013-11-14 Thread jpm miao
Hi, I find a few Pearson correlation test functions like fBasics::correlationTest or stats::cor.test which give the p-value of the test result. Is there a function that calculate the cutoff correlation value for a specific p-value , e.g., p = 0.05? I have a plot for the cross

[R] Test for exogeneity

2013-11-11 Thread jpm miao
Hi, I am building a bivariate SVAR model y_1t=c_1+Ã_1 (1,1) y_(1,t-1)+Ã_1 (1,2) y_(2,t-1)+Ã_2 (1,1) y_(1,t-2)+Ã_2 (1,2) y_(2,t-2)+å_1t b y_1t+ y_2t=c_2+Ã_1 (2,1) y_(1,t-1)+Ã_1 (2,2) y_(2,t-1)+Ã_2 (2,1) y_(1,t-2)+Ã_2 (1,2) y_(2,t-2)+å_2t Now y1 is relatively exogenous in that y1

[R] Lag selection in Unit Root Test

2013-08-21 Thread jpm miao
Hi, I attempt to conduct the unit root test with the two functions unitrootTest(x, lags = 1, type = c(nc, c, ct), title = NULL, description = NULL) adfTest(x, lags = 1, type = c(nc, c, ct), title = NULL, description = NULL) According to the document, lagsis the maximum number of

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

2013-08-06 Thread jpm miao
Hi, I am wondering if C++ programs could be compiled in RStudio. I search on the web, and I find many yes's and no's. It looks like Rcpp can do it (or partially?). I just wonder if it can replace the C++ IDE, e.g., Eclipse or Visual Studio since RStudio is much easier to use. One says yes:

[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 reserve

[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] 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 kri...@ymail.com Hello, in is a reserved word. ?Reserved Hope this clarifies, Pascal 2013/7/11 jpm miao miao...@gmail.com Hi, I have a matrix whose columns are named as in and out

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
, at 7:18, jpm miao miao...@gmail.com wrote: Hi, I try to build a toy package by running the following codes in an R program require(stats) f - function(x,y) x+y g - function(x,y) x-y d - data.frame(a=1, b=2) e - rnorm(1000) package.skeleton(list=c(f,g,d,e), name=test1pkg, path

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
, Did you run R CMD build test1pkg in a command prompt window? Regards, Pascal On 20/06/13 17:01, jpm miao wrote: Hi, Following your advice, I install R tools from http://cran.r-project.org/bin/**windows/Rtools/http://cran.r-project.org/bin/windows/Rtools/ Rtools215.exe http://cran.r

Re: [R] Problems with R package building

2013-06-20 Thread jpm miao
/6/20 Berend Hasselman b...@xs4all.nl On 20-06-2013, at 10:01, jpm miao miao...@gmail.com wrote: Hi, Following your advice, I install R tools from http://cran.r-project.org/bin/windows/Rtools/ Rtools215.exe http://cran.r-project.org/bin/windows/Rtools/Rtools215.exe Files

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

2013-06-17 Thread jpm miao
“arch.test” in “vars” package with multivariate.only = FALSE The function arch.test(x, lags.single = 16, lags.multi = 5, multivariate.only = FALSE) produces the univariate and multivariate parts of the ARCH test By_t = C+A_1 y_{t-1}+….. A_n y_{t-n}+\epsilon (homoskedastic VAR) And then

[R] Problems with R package building

2013-06-14 Thread jpm miao
Hi, I try to build a toy package by running the following codes in an R program require(stats) f - function(x,y) x+y g - function(x,y) x-y d - data.frame(a=1, b=2) e - rnorm(1000) package.skeleton(list=c(f,g,d,e), name=test1pkg, path=D:/R/pkgtest) Then the program runs smoothly Creating

[R] Create a package with package.skeleton

2013-06-10 Thread jpm miao
Hi, I am trying to build a package with package.skeleton function. I already have the function quadprod2.R in the current folder. After running the program, library(frontier) source(quadprod2.R) package.skeleton(name=sfa_ext) package.skeleton(name=sfa_ext) Creating directories ...

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

2013-06-10 Thread jpm miao
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

[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)? Thanks Miao

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

2013-05-23 Thread jpm miao
Hi, I have a few graph objects created by some graphic package (say, ggplot2, which I use frequently). Because of the existent relation between the graphs, I'd like to index them in two dimensions as p[1,1], p[1,2], p[2,1], p[2,2] for convenience. To my knowledge, the only data type capable

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

2013-05-17 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 version deleted]]

[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

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

2013-05-08 Thread jpm miao
and 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 dwinsem...@comcast.net On May 7, 2013, at 8:40 PM, jpm miao wrote: Is there a function

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[f0] [1] -2 -8 -32 -128 f[f0] [1] 4 16 64 f[f=4] [1] 16 2013/5/8 Jorge I Velez jorgeivanve...@gmail.com f [ f 0 ] On Wed, May 8, 2013 at 11:54 AM, jpm miao miao...@gmail.com wrote: Hi

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 miao...@gmail.com Thanks, but why does f[f=4] yield 16 instead of 4? f [1] -24 -8 16 -32 64 -128 f[f0] [1] -2 -8 -32 -128 f[f0] [1] 4 16 64 f[f=4] [1] 16 2013/5/8 Jorge I Velez jorgeivanve

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

2013-05-07 Thread jpm miao
Hi, From time to time I merge two dataframes with possibly a common field. Then the common field is no longer present,but what are present fieldname.x and fieldname.y. How can I fix the problem so that I can still call by the orignal fieldname? If you don't understand my problem, please see

[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 -8 16 -32 64 -128

[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 access the rowname of a data?

2013-05-06 Thread jpm miao
Hi, Below is the output from an R package. The first column (4, 5, 6, 7, which is unnamed) is the company name (code), while the second column efficiency is the performance of each company, which is the primary output result. How can I access the first column, rowname, 4, 5, 6, 7, 8, 9, 11?

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

2013-05-03 Thread jpm miao
) # convert all NA fields to zeroes if you prefer temp[ is.na( temp ) ] - 0 On Wed, May 1, 2013 at 11:55 PM, jpm miao miao...@gmail.com wrote: Hi, Attached are two datasheet to be read. My raw data 130502temp.xlsx contains numbers with ' symbols, and they can't be read as numbers

[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]]

[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-project.org

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 arne.henning...@gmail.com Dear Miao On 25 April 2013 03:26, jpm miao miao...@gmail.com

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

2013-05-01 Thread jpm miao
Hi, Attached are two datasheet to be read. My raw data 130502temp.xlsx contains numbers with ' symbols, and they can't be read as numbers. Even if I copy and paste as numbers to form a new file 130502temp_number1.xlsx, they could not be read smoothly. 1. How can I read the datasheet as

[R] Extrafont package: Fonts are not successfully installed

2013-04-30 Thread jpm miao
Hi, I am using Extrafont package to install more fonts for my graphs. My primary graphic tool is ggplot2. I seem to have problem installing the package, but could not pinpoint where it is. I try to follow the instruction here: https://github.com/wch/extrafont I guess (but am not sure)

[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
Hi, I am trying to find out the scale efficiency and optimal scale of banks by stochastic frontier analysis given the panel data of bank. I am free to choose any model of stochastic frontier analysis. The only approach I know to work with R is to estimate a translog production function by

[R] Questions on function readNamedRegionFromFile in XLConnect pacakge

2013-04-23 Thread jpm miao
Hi, I have two questions on the function readNamedRegionFromFile in XLConnect pacakge. 1. In the documentation, # multiregion xlsx file from demoFiles subfolder of package XLConnect demoExcelFile - system.file(demoFiles/multiregion.xlsx, package = XLConnect)

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

2013-04-18 Thread jpm miao
I have many xls grade report sheets with the same format XXX High School Grade Report Confidential Yes Math English Science John 90 85 90 Mary 75 88 93 …… Since the reports are prepared on a regular basis, I have many reports with identical format. Without the title “XXX High

[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[A]*2 D=dfab[B]*3

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

2013-04-15 Thread jpm miao
Hi, Is it possible to create Dual y axes with ggplot2 package? If so, is there any sample codes that reaches (or partially) this goal? The author of the package, Dr Hadley Wickham, seem to discourage the dual axes, but some remedies were provided by other users (If I am wrong, please

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

2013-04-10 Thread jpm miao
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 dwinsem...@comcast.net On Apr 9, 2013, at 8:21 PM, jpm miao wrote: Thank you very much. Could it be done in Lattice package

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

2013-04-10 Thread jpm miao
, 4365158.32240167, 4466835.92150963, 4570881.89614875, 4677351.41287198, 4786300.92322638, 4897788.19368447, 5011872.33627272), .Dim = c(201L, 2L), .Dimnames = list(NULL, c(y1, x2))) 2013/4/11 David Winsemius dwinsem...@comcast.net On Apr 10, 2013, at 12:44 AM, jpm miao wrote: Hi David, Many

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 dwinsem...@comcast.net 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 and y1

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

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

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

2013-04-09 Thread jpm miao
use the following command. plot(x1,y1,type=l) points(x2,y2) Hope it helps. On Tue, Apr 9, 2013 at 8:24 PM, jpm miao miao...@gmail.com wrote: 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

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

2013-04-08 Thread jpm miao
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,

[R] Generating a bivariate joint t distribution in R

2013-04-03 Thread jpm miao
Hi, I conduct a panel data estimation and obtain estimators for two of the coefficients beta1 and beta2. R tells me the mean and covariance of the distribution of (beta1, beta2). Now I would like to find the distribution of the quotient beta1/beta2, and one way to do it is to simulate via the

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

2013-03-12 Thread jpm miao
Hi, I am graphing with the following command in the Lattice and LatticeExtra package xyplot(xts,lty=c(1,2),col=c(blue,red),type=c(l,g),par.settings = list(layout.heights = list(panel = c(2, 2))), aspect=xy,xlab=,ylab=%, key=key1,screen=list(a,a,b,b,c,c,d,d), layout=c(2,2),

[R] About multivariate GARCH: DVEC and BEKK

2013-02-20 Thread jpm miao
Dear All, I attempted to fit a DVEC and a BEKK multivariate GARCH model, but am wondering which package to use. 1. I tried to use rmgarch package in R, but I couldn't find the subroutines for DVEC and BEKK. 2. I tried to find rmgarch package of R, which is not located on the official R

[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 version deleted]]

[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
Hello, I have a table (in a txt file) which look like this: Monday 12 78 89 Tuesday 34 44 67 Wednesday 78 98 2 Thursday 34 55 4 Then the table repeats Monday , Tuesday, ... followed by several numbers My goal is to read values after the table. My problem is a little more complicated,

[R] A question on xyplot function in Lattice package

2012-11-07 Thread jpm miao
Hi, I am using xylot function in Lattice package. I find it excellently written, but I don't know how to find resources on this function. One thing I would like to change is the line type. To my knowledge, type =l means a regular line, type g means broken lines, but I can't find a complete

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

2012-09-30 Thread jpm miao
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

[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]] __

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

2012-09-27 Thread jpm miao
population, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jpm miao Sent: 27 September 2012 09:43 To: r-help

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

2012-09-27 Thread jpm miao
Hi, I am trying to fit an AR model, maximum order =4, order selection criterion is aic. I wonder why these two give different results: m1-ar.ols(x, aic=TRUE, method=ols, order.max=4) m1-auto.arima(x,d=0, D=0, max.p=4, max.P=0, max.q=0, max.Q=0, ic=aic) Could they both use the

[R] Adding legends on plots using Lattice package

2012-09-17 Thread jpm miao
To dear Dr Sarkar and anyone that knows about Lattice package, I make 4 graphs by Lattice package. Each of the graphs has two time series. All the series are plotted in plain lines by default, and I would like one series to be in plain line and the other to be in dotted line in each graph. How

[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] How should one handle NA properly in a .csv dataset?

2012-08-22 Thread jpm miao
Hi, I am reading several .csv file of time series. Some values of the time series are unavailable. Some of the unavailable series are marked NA, and some are just blank. The NA value can be read, but the blank cannot be read. Then I change the change the blank to NA, but they can't be properly

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 miao...@gmail.com Hi, I am reading several .csv file of time series. Some values of the time series

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

2012-08-22 Thread jpm miao
Hi , To my knowledge, there're two functions that can do principal component analysis, princomp and prcomp. I don't really know the difference; the only thing I know is that when the sample size number of variable, only prcomp will work. Could someone tell me the difference or where I can

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

2012-08-15 Thread jpm miao
Hi, To my knowledge, Ryacas can do symbolic computation in R, like Mathematica or Maple. I wonder if it (or any other R package) can solve symbolically a system of equations? I have a system of four equations in four variables (non-linear, but not very hard to solve) and wonder if Ryacas

[R] Zoo object problem: problem when I attempt to create a zoo object of only one column

2012-08-09 Thread jpm miao
Hi, Part of my program is to calculate the number of time series in a zoo object. It works well if it has more than one time series, but it fails if it has only one. How can I access the number of column (i.e. the number of time series) when I have only one column? Why is the number of an

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

2012-08-09 Thread jpm miao
names of the zoo objects? In case of more than one time series, the function colnames works, but not for the univariate time series. Thanks, Miao 2012/8/9 Achim Zeileis achim.zeil...@uibk.ac.at On Thu, 9 Aug 2012, jpm miao wrote: Hi, Part of my program is to calculate the number

  1   2   >