[R] PCA and gglot2

2013-07-10 Thread ashz
Hi,

I was trying as well as looking for an answer without success (a bit strange
since it should be an easy problem) and therefore I will appreciate you
help:

My simple script is:
# Loadings data of 5 columns and 100 rows of data
data1<-read.csv("C:/…/MyPCA.csv")
pairs(data1[,1:4])
pca1 <- princomp(data1[,1:4], score=TRUE, cor=TRUE)
biplot(pca1)

The biplot present the data points as numbers. How can I present the data
point in color (depends on their group-column 5). I was thinking about doing
it using ggplot2 but I can not succeed. Any idea how to do it?

Thanks 



--
View this message in context: 
http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] PCA and gglot2

2013-07-10 Thread ashz
Hi,

Thanks. Fig 4 in the link you provided is what I am looking for.

I still do not know how to implement my data1 and pca1 in the script you
provided as I think it is only a part of a full script.
"
data1<-read.csv("C:/…/MyPCA.csv")
pca1 <- princomp(data1[,1:4], score=TRUE, cor=TRUE) 
"

Am I right, how can I implement my data.frames?

Thanks again



--
View this message in context: 
http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225p4671237.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] PCA and gglot2

2013-07-10 Thread ashz
Dear John,

Thanks for the help.

I did some minor modifications to your script as I had some problems:
... 
pca = PCA(data[,1:4], scale.unit=T, graph=F)
dat1  <-  data.frame(pca$scores)  # creates the data.frame
dat1$items  <-  rownames(data$group) # adds item names
ggplot(dat1, aes(pca$ind$coord[,1], pca$ind$coord[,2], colour = dat1$item))
+ geom_point() + theme(legend.position="none")

I still do not get separation by color by group (column 5 of csv file) as
the  dat1 is empty (data frame with 0 columns and 0 rows).

Any reason why?

Thanks again.



--
View this message in context: 
http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225p4671253.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] PCA and gglot2

2013-07-10 Thread ashz
Hi,

Thanks to ssefick for the ggbiplot tip.

It works fine so I submit a general script thats works for future users.

library(ggbiplot)
data<-read.csv("C:/…/MyPCA.csv") 
data1<-data[,1:4] 
my.pca <- prcomp(data1, scale. = TRUE)
my.class<- data$Group  
g <- ggbiplot(my.pca, obs.scale = 1, var.scale = 1,groups = my.class,
ellipse = TRUE, circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', 
   legend.position = 'top')
print(g)

BTW
Installation:
library(devtools)
install_github("ggbiplot", "vqv")

you will need to instal before Rtools
(http://cran.r-project.org/bin/windows/Rtools/)

Thanks a lot for the help.




--
View this message in context: 
http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225p4671258.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] What is “Proportion of trace” in lda (MASS)

2013-08-14 Thread ashz
Hi,
 
Is the lda function (R MASS package)  “Proportion of trace” is similar to
“proportion of variance explained”in the case of PCA?

How can I store the LD1 and LD2 in two separate variables?

Thanks





--
View this message in context: 
http://r.789695.n4.nabble.com/What-is-Proportion-of-trace-in-lda-MASS-tp4673696.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] GUI tools for R

2013-08-16 Thread ashz
Hi,

I wish to build a GUI for my R script, what are the best and easiest tools
to use and which ones as good documentation or books?

Thanks





--
View this message in context: 
http://r.789695.n4.nabble.com/GUI-tools-for-R-tp4673925.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Image Gray Level Co-occurrence Matrix in R

2013-06-26 Thread ashz
Hi, 
  
I've been looking for Image Processing packages without success. I am mainly
interested in image Gray Level Co-occurrence Matrix (GLCM) parameters like
Contrast, Correlation, Energy, Homogeneity. 

Is there a package that can do it? Any ideas, comments, etc are welcome.

Thanks.




--
View this message in context: 
http://r.789695.n4.nabble.com/Image-Gray-Level-Co-occurrence-Matrix-in-R-tp4670401.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Mark each group centroid in a linear discriminant analysis plot

2013-11-10 Thread ashz
Hi,

How can I calculate and mark each group centroid in a linear discriminant
analysis plot (using ggplot2)? 


Script:
## originate from
http://r.789695.n4.nabble.com/LDA-and-confidence-ellipse-td4671308.html
require(MASS)
require(ggplot2)
iris.lda<-lda(Species ~ Sepal.Length + Sepal.Width + Petal.Length +
Petal.Width,  data = iris)
LD1<-predict(iris.lda)$x[,1]
LD2<-predict(iris.lda)$x[,2]
ggplot(iris, aes(x=LD1, y=LD2, col=iris$Species) ) + geom_point( size = 4,
aes(color = iris$Species))+theme_bw()   




--
View this message in context: 
http://r.789695.n4.nabble.com/Mark-each-group-centroid-in-a-linear-discriminant-analysis-plot-tp4680159.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Scatterplot matrix - Pearson linear correlation and Density Ellipse

2010-09-30 Thread ashz

Hi,

I have modified a known script to generate a  scatterplot matrix:
 
panel.cor = function(x, y, digits=2, prefix="Rho=", cex.cor)
{
usr = par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r = abs(cor(x, y, use="pairwise.complete.obs", method = "pearson"))
txt = format(c(r, 0.123456789), digits=digits)[1]
txt = paste(prefix, txt, sep="")
if(missing(cex.cor)) cex.cor = 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor)
}

pairs(ap[8:11], lower.panel=panel.smooth, upper.panel=panel.cor)

My question is how I can change the lower.panel to show both the pearson
linear correlation and Density Ellipse?

Thanks a lot.
As Hz

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-matrix-Pearson-linear-correlation-and-Density-Ellipse-tp2763552p2763552.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Scatterplot matrix - Pearson linear correlation and Density Ellipse

2010-10-03 Thread ashz

Hi,

I used the pairs.panels() in pkg:psych and it is helpful. It saves time.

but if I use this line: 
pairs.panels(cfcap[8:11],  scale = FALSE, lm=TRUE,ellipses=TRUE, digits = 2
)

The results are:
- The upper.panel does not show the pearson r but the lm data. Furthermore,
can I use the pairwise.complete.obs method for the upper.panel. Can it be
fixed?
- Can I remove the histograms?
- Can I control the eliipse alpha?
 
Thanks a lot.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-matrix-Pearson-linear-correlation-and-Density-Ellipse-tp2763552p2953521.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Scatterplot matrix - Pearson linear correlation and Density Ellipse

2010-10-04 Thread ashz

Thanks a lot for the answer
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-matrix-Pearson-linear-correlation-and-Density-Ellipse-tp2763552p2953909.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Scatterplot matrix - Pearson linear correlation and Density Ellipse

2010-10-04 Thread ashz

Hi,

strangely, when I run this script:

panel.cor = function(x, y, digits=2, prefix="r=", cex.cor)
{
usr = par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r = abs(cor(x, y, use="pairwise.complete.obs", method = "pearson"))
txt = format(c(r, 0.123456789), digits=digits)[1]
txt = paste(prefix, txt, sep="")
if(missing(cex.cor)) cex.cor = 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor)
}

 pairs(cap[8:11], lower.panel=panel.lm, upper.panel=panel.cor, cex=2)


I get linear regression and density ellipse, why?

Is it possible to add also the data point?

Thanks a lot

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-matrix-Pearson-linear-correlation-and-Density-Ellipse-tp2763552p2954416.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Xlsx and R -read problem

2010-10-16 Thread ashz

Hi,

I have an excel 2007 file located in C:\know and called try.xlsx.

Whan I try to read it I get this error: 
 
> file <- system.file("know", "try.xlsx", package = "xlsx")
> res <- read.xlsx(file, 2)  # read the second sheet
Error in .jnew("java/io/FileInputStream", file) : 
  java.io.FileNotFoundException: 

Can someone tell me what is the problem? and how to solve it.

Cheers,
Ashz

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Xlsx-and-R-read-problem-tp2998304p2998304.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Sine function fitting

2010-10-18 Thread ashz

Hi,

Is there a package to perform a sine function fitting to XY data?

Thx,
Ashz

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Sine-function-fitting-tp3000156p3000156.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] points(x,y), mean and standard deviation

2010-10-19 Thread ashz

Hi,

I have a data set with 3 rows (X=date, Y1=arithmetic mean and Y2=standard
deviation). How can I create a graph(e.g., points) which will show the
+-stdev as well (similar to excel).

Thanks 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/points-x-y-mean-and-standard-deviation-tp3001683p3001683.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] points(x,y), mean and standard deviation

2010-10-19 Thread ashz

Hi,

Thanks for the tip.

I run this script:
means.cl <- c(82, 79, 110, 136,103)
stderr.cl <- c(8.1,9.2,7.4,1.6,7.6)
plotCI(x = means.cl , uiw =  stderr.cl, pch=24)

But how can I connect the mean triangles with a line?

Thanks

-- 
View this message in context: 
http://r.789695.n4.nabble.com/points-x-y-mean-and-standard-deviation-tp3001683p3002173.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] ggplot - unwanted sorted X values

2010-10-27 Thread ashz

Hi,

I have this script:

dat <- data.frame(X = halistat$Date,Y1 = halistat$avg,Y2 = halistat$stdev)
ggplot(data = dat, aes(x = X, y = Y1, ymin = Y1 - Y2, ymax = Y1 + Y2)) +
  geom_point() + # points at the means
  geom_line() + # if you want lines between pints
  geom_errorbar() # error bars, Y1 - Y2 and Y1 + Y2


halistat$Date values:
29/1/10
21/2/10
30/3/10
30/4/10
30/5/10


In the resulted plot the X values are sorted, how can I cancel it?

Thanks. 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/ggplot-unwanted-sorted-X-values-tp3015099p3015099.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] ggplot output

2010-11-04 Thread ashz

Dear All, 

I have this script:

dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev =
hstat$C.stdev)
ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - C_stdev, ymax =
C_avg + C_stdev)) +
  geom_point() +
  geom_line() +
  geom_errorbar()
  
dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev =
hstat$K.stdev)
ggplot(data = dat, aes(x = Month, y = K_avg, ymin = K_avg - K_stdev, ymax =
K_avg + K_stdev)) +
  geom_point() +
  geom_line() +
  geom_errorbar()
  
dat <- data.frame(Month = hstat$Date,S_avg = hstat$S.avg,S_stdev =
hstat$S.stdev)
ggplot(data = dat, aes(x = Month, y = S_avg, ymin = S_avg - S_stdev, ymax =
S_avg + S_stdev)) +
  geom_point() +
  geom_line() +
  geom_errorbar()

Running the script generates 3 separate graphs, how can I output them next
to each other?  

Thanks

-- 
View this message in context: 
http://r.789695.n4.nabble.com/ggplot-output-tp3027026p3027026.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot output

2010-11-04 Thread ashz

Dear Thierry,

Your solution looks very elgant but I can not find a proper example.

Can you provide me one?

Thx

-- 
View this message in context: 
http://r.789695.n4.nabble.com/ggplot-output-tp3027026p3027108.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Matrix Plot and linear regression

2010-08-11 Thread ashz

Hi,

Is it possible to do a Matrix Plot and in the cell perform a linear
regression also adding to the cell the r2 and the equation. If so, how?

Thanks,
As hz
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-Plot-and-linear-regression-tp2321613p2321613.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Automated plot and linear regression line/data

2010-08-17 Thread ashz

Hi,

I have an excel sheet (already imported to R) with multiple columns and I am
looking for a way in R that will allow me to generate a plot for every
possible pair and its linear regression line/data.
 
Any tip/idea/script how do to so.

Thanks,
As hz

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Automated-plot-and-linear-regression-line-data-tp2328027p2328027.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Automated plot and linear regression line/data

2010-08-17 Thread ashz

Hi,

I presume the easy way is using plot and lm.

Thx,
As hz
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Automated-plot-and-linear-regression-line-data-tp2328027p2328372.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Linear regression equation and coefficient matrix

2010-08-18 Thread ashz

Hi, 

I have 20*60 data matrix (with some NAs) and I wish to perfom a  Pearson
correlation coefficient matrix as well as simple linear regression equation
and coefficient of determination (R2) for every possible combination. Any
tip/idea/library/script how do to so. 

Thanks, 
As hz 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-regression-equation-and-coefficient-matrix-tp2329804p2329804.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Linear regression equation and coefficient matrix

2010-08-18 Thread ashz

Hi,

Thanks, the cor() works.

Regarding the simple linear regression equation (mainly, the slope
parameter) and r2. I think I was not writing it well. I need to do it just
for the columns. If I have a, b, c, d columns I wish to compute the relation
of there data,  e.g., between a-b, a-c, a-d, b-a, b-c, b-d, etc. 

I hope it is clear now and an help will be great.

Thanks.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-regression-equation-and-coefficient-matrix-tp2329804p2329948.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Correlograms and linear regression

2010-08-19 Thread ashz

Dear all,

I generated a Correlograms and used the panel.ellipse (confidence ellipse
and smoothed line) option. Is there a way to get instead of the smoothed
line the linear regression?

Thanks,
As hz



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Correlograms-and-linear-regression-tp2331071p2331071.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Linear regression equation and coefficient matrix

2010-08-19 Thread ashz

Dear Greg,

Thanks for the tip. As I am new in R can you please provide me a script how
do to so. It will help my learning process.

Thanks,
Asher
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-regression-equation-and-coefficient-matrix-tp2329804p2330867.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Scatterplot question

2010-08-27 Thread ashz

Hi,

I have two XY datasets (e.g., longitude  and concentrations) who share the
same X scale. How can I make a simple scatterplot which will combine them
both with different colors for the two Y groups? (plot and xyplot solutions
are fine with me).

Thanks in advance.

Cheers 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-question-tp2341456p2341456.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] lattice to ggplot2 conversion help

2011-08-22 Thread ashz
Hi,

I am interested in ggplot2 and I found this lattice code very interesting
(http://addictedtor.free.fr/graphiques/graphcode.php?graph=48).

Code:
library(lattice) 
lattice.options(default.theme = canonical.theme(color = FALSE)) 


tmp <-
expand.grid(geology = c("Sand","Clay","Silt","Rock"), 
species = c("ArisDiff", "BracSera", "CynDact",
"ElioMuti", "EragCurS", "EragPseu"),
dist = seq(1,9,1) ) 

tmp$height <- rnorm(216) 


sp <- list(superpose.symbol = list(pch = 1:6, cex = 1.2), 
   superpose.line = list(col = "grey", lty = 1)) 

# print is needed when you source() the file
print(xyplot(height ~ dist | geology, data = tmp, 
   groups = species,
   layout = c(2,2), 
   panel = function(x, y, type, ...) {
 panel.superpose(x, y, type="l", ...)
 lpoints(x, y, pch=16, col="white", cex=2) 
 panel.superpose(x, y, type="p",...)
   },
   par.settings = sp, 
   auto.key = list(columns = 2, lines = TRUE))) 



I will be very happy if someone can please explain me how to do it in
ggplot2 as it will be great help.

Cheers,
Ashz


--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-to-ggplot2-conversion-help-tp3760001p3760001.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Time series and ggplot2

2011-08-22 Thread ashz
Hi,

I made a time-series plot using ggplot. All the points are shown in the
graph but unfortunately it does not display all the months in the graph
X-axis text/labels but only one month per year. 

Furthermore, the data contain some NA as not all the month as Y values. 

Therefore, how can I display all the months in the X axis text/labels?
how can I display only January, April, July and October the months in the X
axis text/labels?

Thanks,
Ashz

PS
axis.text.x  = theme_text(angle=90)
and
scale_x_date(format = "%b-%Y")


--
View this message in context: 
http://r.789695.n4.nabble.com/Time-series-and-ggplot2-tp3761434p3761434.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] NA in last row while reading xlsx file

2011-08-23 Thread ashz
Hi,

I am using this script to read a xlsx file to a data frame:
library(xlsx) 
File <- file.path("d:", "car ", "car95-99.xlsx")
B_car <- read.xlsx(File, "raw_data")
Car2x <- data.frame(month = B_car$Date,Ch = B_car$Ch.des,
lat=B_car$Latitude)

The last row in the data.frame is always NA, how can I remove it?

Thx.


--
View this message in context: 
http://r.789695.n4.nabble.com/NA-in-last-row-while-reading-xlsx-file-tp3762119p3762119.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Scatter plots, linear regression in ggplot2

2011-08-24 Thread ashz
Hi,

Based on some modification that I did to the R Cookbook Graphs Scatterplots
code, link:http://wiki.stdout.org/rcookbook/Graphs/Scatterplots%20(ggplot2)
 
I have some questions and I will appreciate a help:
-   How do I change the legend title?
-   How can I change the for each linear regression its color and linetype?
-   How can I add for both the linear regression lines their equations and
Rseq inside or below the plot?

Code:  
set.seed(955)
df <- data.frame(cond = rep(c('A', 'B'), each=10),
 xvar = 1:20 + rnorm(20,sd=3),
 yvar = 1:20 + rnorm(20,sd=3))
 
ggplot(df, aes(x=xvar, y=yvar, shape=cond)) +
scale_shape_manual(values=c(1,2))  +
geom_smooth(method = "lm", se=FALSE) +
 theme_bw()+
 geom_point(size = 5)+
 opts(title = "Xvar vs. Yvar",
  plot.title = theme_text(face="bold", size=16), 
  axis.text.x  = theme_text(angle=90),
  axis.title.x = theme_text(face="bold", size=12),
  axis.title.y = theme_text(face="bold", size=12, angle=90),
  panel.grid.major = theme_blank(), # switch off major gridlines
  panel.grid.minor = theme_blank()   
  ) 

Thanks a lot in advance


--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plots-linear-regression-in-ggplot2-tp3765080p3765080.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Howto convert Linear Regression data to text

2011-08-24 Thread ashz
Dear all,

How can I covert lm data to text in the form of "y=ax+b, r2" and how do I
calculate R-squared(r2)?

Thanks. 
 
Code:
x=18:29
y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5)
res=lm(y~x)

--
View this message in context: 
http://r.789695.n4.nabble.com/Howto-convert-Linear-Regression-data-to-text-tp3766230p3766230.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] ggplot2-grid/viewport and PNG

2011-09-05 Thread ashz
Dear All,

The following code save my graphs as pdf:
pdf("j:/mix.pdf", width = 18, height = 16) 
 grid.newpage() 
 pushViewport(viewport(layout = grid.layout(3,1))) 
 vplayout <- function(x, y) 
 viewport(layout.pos.row = x, layout.pos.col = y) 
 print(Aplot, vp = vplayout(1, 1)) 
 print(Bplot, vp = vplayout(2, 1)) 
 print(Cplot, vp = vplayout(3, 1))
dev.off()

How can I save it in PNG and maintain the same graph structure?

Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-grid-viewport-and-PNG-tp3790866p3790866.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Simple R graph question

2011-07-08 Thread ashz
Dear All,

I have several objects (imported from excel via using “xlsx”) with the field
names: Month/Year, X, Y1, Y2, Y3.

What is the best library/way to generate a graph which will be consist of
multiple plots (Month/Year) that each contain the X, Y1, Y2, Y3 dataset.

Thanks a lot.

Cheers,
Asher




--
View this message in context: 
http://r.789695.n4.nabble.com/Simple-R-graph-question-tp3653493p3653493.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Simple R graph question

2011-07-08 Thread ashz
Dear jholtman,

Thanks for the reply & sorry for the been unclear before. 

My desire graph is to have multiply plots showing Y1,Y2,Y3 with the same X, 
were each plot is month-year (e.g., 5-2001, 6-2001, etc). It ill be great if
each Y can have a different line and point style.
 
The Lattice graphic
(http://addictedtor.free.fr/graphiques/graphcode.php?graph=48) looks similar
to what I want but the script looks complex for me.

Thanks in advance.


--
View this message in context: 
http://r.789695.n4.nabble.com/Simple-R-graph-question-tp3653493p3655142.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Fitting a Harmonic Function to Time Series Data

2011-10-13 Thread ashz
Dear All,

I have some time series data where X=month and Y=nutrient concentration (I
can have several concentration data for one month). Is there a way to fit
for it an Harmonic Function. Is there a package, script,etc which I can use?

Thx
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-a-Harmonic-Function-to-Time-Series-Data-tp3901266p3901266.html
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.