[R] Plot error in package lme4

2011-07-02 Thread Sara Krause
Hi,

I am new to R and not fantastic at statistics so it may well be that I am
doing something silly but I can't figure out what it is and hoping that
somebody can help.

I am running package lme4, and trying to get a Residuals vs. Fitted graph.
 When I try to plot, I receive an error.

Error in as.double(y) :
  cannot coerce type 'S4' to vector of type 'double'


Here is the code I am using

library(lme4)

m1-lmer(y~trt*time*loc_block*Season+(1|ID), data=d)

plot(m1,add.smooth=F,which=1)


Error in as.double(y) :
  cannot coerce type 'S4' to vector of type 'double'


I searched the forums for some answers but haven't found anything
useful.  Any insight into what I am doing wrong and how to fix it.


Sara

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


Re: [R] Plot error in package lme4

2011-07-02 Thread Ben Bolker
Sara Krause skkrause at gmail.com writes:

 
 Hi,
 
 I am new to R and not fantastic at statistics so it may well be that I am
 doing something silly but I can't figure out what it is and hoping that
 somebody can help.
 
 I am running package lme4, and trying to get a Residuals vs. Fitted graph.
  When I try to plot, I receive an error.
 
 Error in as.double(y) :
   cannot coerce type 'S4' to vector of type 'double'
 
 Here is the code I am using
 
 library(lme4)
 
 m1-lmer(y~trt*time*loc_block*Season+(1|ID), data=d)
 
 plot(m1,add.smooth=F,which=1)
 
 Error in as.double(y) :
   cannot coerce type 'S4' to vector of type 'double'
 
 I searched the forums for some answers but haven't found anything
 useful.  Any insight into what I am doing wrong and how to fix it.
 
 Sara

   The standard diagnostics which you have seen in 'lm' are not
implemented for 'lme4'.   You have to do it yourself, but it's
not *too* hard:

library(lme4)

## from ?lmer
fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
f - fitted(fm1)
r - residuals(fm1)
plot(f,r)
sm - loess(r~f)
v - seq(min(f),max(f),length=101)
lines(v,predict(sm,data.frame(f=v)),col=2)

Further questions about lme4 should probably go to the
r-sig-mixed-models mailing list.

__
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] Plot error bars on skyline plot

2011-06-21 Thread Andra-Lia Tolbus
Hi,

   I have generated a skyline plot of a tree in newick format using ape.

   How can I plot the error bars for this graph?

   I only have the the tree data.

un-8.1:0, 20.1:0):0, 6.1:3):123, (35.1:0, (22.1:0, (43.1:1, 
29.1:0):0):0):4, 25.1:6):0, ((42.1:0, 21.1:0):3, (39.1:0, 2.1:0):3):1):8, 
(3.1:0, 7.1:0):8):48, (15.1:0, 14.1:0):0, 11.1:0):0, 37.1:0):0, ((16.1:1, 
30.1:0):0, 13.1:0):1):58, ((31.1:1, 19.1:0):18, 28.1:33):22):14):75):39, 
((26.1:6, 17.1:8):60, (((41.1:0, 1.1:3):0, (9.1:0, 27.1:0):1):2, (5.1:0, 
10.1:0):3):1, (38.1:1, (4.1:1, (24.1:0, 18.1:0):2):0):0):16, 36.1:19):8, 
(32.1:0, 33.1:1):29):33, (40.1:18, ((23.1:0, 12.1:1):3, 34.1:2):16):42):1):82);
t-read.tree(text=un)

# following example from ape  package

cl1 - collapsed.intervals(ci,0)
cl2 - collapsed.intervals(ci,0.0119)
sk1 - skyline(cl1) # from collapsed intervals
sk1 - skyline(ci) # from coalescent intervals
sk1 - skyline(tree.hiv) # from tree

sk2 - skyline(cl2) # from collapsed intervals
sk2 - skyline(ci, 0.0119) # from coalescent intervals
sk2 - skyline(tree, 0.0119) # from tree


plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 2011, 
col=c(grey(.8),1))
lines(sk2, show.years=TRUE, subst.rate=0.0023, present.year = 2011)
legend(.15,500, c(classic, generalized), col=c(grey(.8),1),lty=1

Thanks!


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


[R] plot error bars on skyline plot

2011-06-20 Thread Andra Tolbus
Hi,

   I have generated a skyline plot of a tree in newick format using ape.
   How can I plot the error bars for this graph?
   I only have the the tree data.

un-8.1:0, 20.1:0):0, 6.1:3):123, (35.1:0, (22.1:0, (43.1:1,
29.1:0):0):0):4, 25.1:6):0, ((42.1:0, 21.1:0):3, (39.1:0, 2.1:0):3):1):8,
(3.1:0, 7.1:0):8):48, (15.1:0, 14.1:0):0, 11.1:0):0, 37.1:0):0,
((16.1:1, 30.1:0):0, 13.1:0):1):58, ((31.1:1, 19.1:0):18,
28.1:33):22):14):75):39, ((26.1:6, 17.1:8):60, (((41.1:0, 1.1:3):0,
(9.1:0, 27.1:0):1):2, (5.1:0, 10.1:0):3):1, (38.1:1, (4.1:1, (24.1:0,
18.1:0):2):0):0):16, 36.1:19):8, (32.1:0, 33.1:1):29):33, (40.1:18,
((23.1:0, 12.1:1):3, 34.1:2):16):42):1):82);
t-read.tree(text=un)

# following example from ape  package

cl1 - collapsed.intervals(ci,0)
cl2 - collapsed.intervals(ci,0.0119)
sk1 - skyline(cl1) # from collapsed intervals
sk1 - skyline(ci) # from coalescent intervals
sk1 - skyline(tree.hiv) # from tree

sk2 - skyline(cl2) # from collapsed intervals
sk2 - skyline(ci, 0.0119) # from coalescent intervals
sk2 - skyline(tree, 0.0119) # from tree


plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 2011,
col=c(grey(.8),1))
lines(sk2, show.years=TRUE, subst.rate=0.0023, present.year = 2011)
legend(.15,500, c(classic, generalized), col=c(grey(.8),1),lty=1

Thanks!

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


[R] Plot error

2010-07-17 Thread James Platt

Hi guys,

I am a newbie to R, so apologies in advance.

I created this simple table in excel, saved in tab delimited .txt:

name value_1 value_2
1 bill   14
2 ben  2   2
3 jane 3   1


test -read.table(\path\to\file, sep=\t, header=TRUE)

x -c(seq[value_1])
y -c(seq[value_2])

plot(x,y)

and i get this error

Error in xy.coords(x, y, xlabel, ylabel, log) :
  (list) object cannot be coerced to type 'double'

What does this mean and how do i fix it?

Thanks for the help, James

__
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] Plot error

2010-07-17 Thread Ista Zahn
Hi James,

On Sat, Jul 17, 2010 at 2:50 PM, James Platt james-pl...@hotmail.co.uk wrote:
 Hi guys,

 I am a newbie to R, so apologies in advance.

 I created this simple table in excel, saved in tab delimited .txt:

 name value_1 value_2
 1 bill       1            4
 2 ben      2           2
 3 jane     3           1


test -read.table(\path\to\file, sep=\t, header=TRUE)

x -c(seq[value_1])
y -c(seq[value_2])

You lost me here. What is seq[value_1] supposed to do? Please fix
your example.


plot(x,y)

 and i get this error

 Error in xy.coords(x, y, xlabel, ylabel, log) :
  (list) object cannot be coerced to type 'double'

 What does this mean and how do i fix it?

 Thanks for the help, James

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] Plot error

2010-07-17 Thread Joshua Wiley
Hi James,

I believe the issue has to do with the values you assigned to 'x' and
'y'.  You call the function c() on seq[value_1], but you assigned
your data not to 'seq' but to 'test'.  You need to use the variable
name that you assigned your data to (as a side note seq() is a
function, so you should probably avoid using that as name to store
data anyways).  Also you have data in a variable 'test' that has both
rows and columns, so the preferred way to access it is
variablename[rowname/number , columnname/number].  In your case that
would be test[ , value_1].  I left the space before the comma blank
to indicate include all rows.  It does technically work in this case
to simply write test[value_1] but this is prone to error in other
situations.  This is my best guess as to what you want to do:

#Read in Data
#(just to make sure were on the same page)
test - structure(list(name = structure(c(2L, 1L, 3L),
.Label = c(ben, bill, jane), class = factor),
value_1 = 1:3, value_2 = c(4L, 2L, 1L)),
.Names = c(name, value_1, value_2),
class = data.frame, row.names = c(NA, -3L))

test # print so we can look at it

#Assign columns to variables 'x' and 'y'
x - test[ , value_1]
y - test[ , value_2]

#plot
plot(x, y)

#Or using data directly
plot(test[ , value_1], test[ , value_2])

Cheers,

Josh

On Sat, Jul 17, 2010 at 7:50 AM, James Platt james-pl...@hotmail.co.uk wrote:
 Hi guys,

 I am a newbie to R, so apologies in advance.

 I created this simple table in excel, saved in tab delimited .txt:

 name value_1 value_2
 1 bill       1            4
 2 ben      2           2
 3 jane     3           1


test -read.table(\path\to\file, sep=\t, header=TRUE)

x -c(seq[value_1])
y -c(seq[value_2])

plot(x,y)

 and i get this error

 Error in xy.coords(x, y, xlabel, ylabel, log) :
  (list) object cannot be coerced to type 'double'

 What does this mean and how do i fix it?

 Thanks for the help, James

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Plot error

2010-07-17 Thread James Platt

Hi both,

Sorry my mistake I was trying to make a graph from another file I  
called seq, I decided to use test as an example, but mixed up the two.


I have got this to work now thanks.

after doing this:


#Assign columns to variables 'x' and 'y'
x - test[ , value_1]
y - test[ , value_2]

#plot
plot(x, y)


cheers,

James

On 17 Jul 2010, at 16:07, Joshua Wiley wrote:


Hi James,

I believe the issue has to do with the values you assigned to 'x' and
'y'.  You call the function c() on seq[value_1], but you assigned
your data not to 'seq' but to 'test'.  You need to use the variable
name that you assigned your data to (as a side note seq() is a
function, so you should probably avoid using that as name to store
data anyways).  Also you have data in a variable 'test' that has both
rows and columns, so the preferred way to access it is
variablename[rowname/number , columnname/number].  In your case that
would be test[ , value_1].  I left the space before the comma blank
to indicate include all rows.  It does technically work in this case
to simply write test[value_1] but this is prone to error in other
situations.  This is my best guess as to what you want to do:

#Read in Data
#(just to make sure were on the same page)
test - structure(list(name = structure(c(2L, 1L, 3L),
.Label = c(ben, bill, jane), class = factor),
value_1 = 1:3, value_2 = c(4L, 2L, 1L)),
.Names = c(name, value_1, value_2),
class = data.frame, row.names = c(NA, -3L))

test # print so we can look at it

#Assign columns to variables 'x' and 'y'
x - test[ , value_1]
y - test[ , value_2]

#plot
plot(x, y)

#Or using data directly
plot(test[ , value_1], test[ , value_2])

Cheers,

Josh

On Sat, Jul 17, 2010 at 7:50 AM, James Platt james-pl...@hotmail.co.uk 
 wrote:

Hi guys,

I am a newbie to R, so apologies in advance.

I created this simple table in excel, saved in tab delimited .txt:

name value_1 value_2
1 bill   14
2 ben  2   2
3 jane 3   1



test -read.table(\path\to\file, sep=\t, header=TRUE)



x -c(seq[value_1])
y -c(seq[value_2])



plot(x,y)


and i get this error

Error in xy.coords(x, y, xlabel, ylabel, log) :
 (list) object cannot be coerced to type 'double'

What does this mean and how do i fix it?

Thanks for the help, James

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





--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Plot error

2010-07-17 Thread James Platt
The other question I have:

Is there any way to link the data point on the graph to the name of a  
row

i.e in my table:

name value_1 value_2
bill   14
ben  2   2
jane 3   1

I click on the data point at 2,2 and it would read out ben

thanks again.

James

On 17 Jul 2010, at 16:43, James Platt wrote:

 Hi both,

 Sorry my mistake I was trying to make a graph from another file I  
 called seq, I decided to use test as an example, but mixed up the two.

 I have got this to work now thanks.

 after doing this:

 #Assign columns to variables 'x' and 'y'
 x - test[ , value_1]
 y - test[ , value_2]

 #plot
 plot(x, y)

 cheers,

 James

 On 17 Jul 2010, at 16:07, Joshua Wiley wrote:

 Hi James,

 I believe the issue has to do with the values you assigned to 'x' and
 'y'.  You call the function c() on seq[value_1], but you assigned
 your data not to 'seq' but to 'test'.  You need to use the variable
 name that you assigned your data to (as a side note seq() is a
 function, so you should probably avoid using that as name to store
 data anyways).  Also you have data in a variable 'test' that has both
 rows and columns, so the preferred way to access it is
 variablename[rowname/number , columnname/number].  In your case that
 would be test[ , value_1].  I left the space before the comma blank
 to indicate include all rows.  It does technically work in this case
 to simply write test[value_1] but this is prone to error in other
 situations.  This is my best guess as to what you want to do:

 #Read in Data
 #(just to make sure were on the same page)
 test - structure(list(name = structure(c(2L, 1L, 3L),
 .Label = c(ben, bill, jane), class = factor),
 value_1 = 1:3, value_2 = c(4L, 2L, 1L)),
 .Names = c(name, value_1, value_2),
 class = data.frame, row.names = c(NA, -3L))

 test # print so we can look at it

 #Assign columns to variables 'x' and 'y'
 x - test[ , value_1]
 y - test[ , value_2]

 #plot
 plot(x, y)

 #Or using data directly
 plot(test[ , value_1], test[ , value_2])

 Cheers,

 Josh

 On Sat, Jul 17, 2010 at 7:50 AM, James Platt james-pl...@hotmail.co.uk 
  wrote:
 Hi guys,

 I am a newbie to R, so apologies in advance.

 I created this simple table in excel, saved in tab delimited .txt:

 name value_1 value_2
 1 bill   14
 2 ben  2   2
 3 jane 3   1


 test -read.table(\path\to\file, sep=\t, header=TRUE)

 x -c(seq[value_1])
 y -c(seq[value_2])

 plot(x,y)

 and i get this error

 Error in xy.coords(x, y, xlabel, ylabel, log) :
 (list) object cannot be coerced to type 'double'

 What does this mean and how do i fix it?

 Thanks for the help, James

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




 -- 
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.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.



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


[R] plot error

2010-05-13 Thread Mohsen Jafarikia
Hello All:

I am having the following error message when I increase the resolution
(res=30 to res=350) of my graph:

Error in plot.xy(xy, type, ...) : ignoring SIGPIPE signal
Calls: plot - plot.default - plot.xy
Execution halted

Here is the code:

ofn - MAY11.png
bitmap(ofn, type = png256, width = 21, height = 30, pointsize = 30, bg =
white,res=350)   If I change res=350 to res=30, everything is
fine.
par(cex.main=1.2,cex.lab=1.8,cex.axis=1.4)


Does anybody have any comment please?

Many thanks,
Mohsen

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


Re: [R] plot error

2010-05-13 Thread Uwe Ligges



On 13.05.2010 16:49, Mohsen Jafarikia wrote:

Hello All:

I am having the following error message when I increase the resolution
(res=30 to res=350) of my graph:

Error in plot.xy(xy, type, ...) : ignoring SIGPIPE signal
Calls: plot -  plot.default -  plot.xy
Execution halted

Here is the code:

ofn- MAY11.png
bitmap(ofn, type = png256, width = 21, height = 30, pointsize = 30, bg =
white,res=350)  If I change res=350 to res=30, everything is
fine.
par(cex.main=1.2,cex.lab=1.8,cex.axis=1.4)


Does anybody have any comment please?


Does not happen for me. This may be a ghostscript issue rather than an R 
issue, though.


Hard to say since we do not know:
your R version, OS, ghostscript version etc.



Uwe Ligges




Many thanks,
Mohsen

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


__
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] plot error

2010-05-12 Thread Mohsen Jafarikia
Hello All:

I am having the following error message when I increase the resolution
(res=30 to res=350) of my graph:

Error in plot.xy(xy, type, ...) : ignoring SIGPIPE signal
Calls: plot - plot.default - plot.xy
Execution halted

Here is the code:

ofn - MAY11.png
bitmap(ofn, type = png256, width = 21, height = 30, pointsize = 30, bg =
white,res=350)   If I change res=350 to res=30, everything is
fine.
par(cex.main=1.2,cex.lab=1.8,cex.axis=1.4)
par(mfrow = c(6,3))

for(C in 1:18)
{
.

Does anybody have any comment please?

Many thanks,
Mohsen

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


Re: [R] plot error -- figure margins too large

2009-09-29 Thread Uwe Ligges



Ping-Hsun Hsieh wrote:

Hi,

I am trying to plot my dataset, consisting of one column with numeric values 
and one column with group IDs.
The set is similar to the following df.

df - NULL
for ( i in 1:20)
{
  tmp1 - runif(1000,0,5)
  tmp2 - cbind(tmp1,i)
  df - rbind(df,tmp2)
}


Now I would like to plot the numeric column, stratified by the group IDs, in a 
single figure.
First, I partitioned the frame into a 1x20 array. Then I plot the numeric 
values of each group in a sub-plot.
Note that only should the left most y-axis be shown, and the x-axis is only the 
group numbers.
Also the margin between two sub-frame should be fairly small so it looks like 
only one figure, rather than 20 figures.

The following codes were used to achieve my goal, but I got an error saying 
figure margins too large.

cols - sample(rainbow(20))
par(mfrow=c(1,20))
for ( i in 1:20)
{
  tmp - subset(df, df[,2]==i)
  if(i!=1)
  {
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
mtext(i, line=1,side=1)
  }
  else{
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
axis(2,at=0:5)
mtext(i, line=1,side=1)
}
}

I also tried to set the margins by modifying the _par_ command: 
par(mfrow=c(1,20),mar=(4,2,4,0.05))
Still, received the same error.



The error depens on the space of your device. If your device is larger, 
it might work. For a smaller device I'd try



df - matrix(c(runif(2,0,5), rep(1:20, each=1000)), ncol=2)
cols - sample(rainbow(20))
par(mfrow=c(1,20), oma=c(5,5,4,1), mar=rep(0, 4))
# nor margins (mar) for a single figure, but outer margins (oma)
for ( i in 1:20)
{
  tmp - subset(df, df[,2]==i)
  if(i!=1)
  {

plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5), 
ylab=)

mtext(i, line=1,side=1)
  }
  else{
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
axis(2,at=0:5)
mtext(i, line=1,side=1)
}
}



or even better go with lattice that does the job for you.





The other experiment:
While I was using the following codes, it almost showed what I would like, but 
the figure ended with only the last sub-plot. The only difference between the 
two is I was attempting to add a main-label in the figure.



To add a main label, use the code above and add:


title(Multiple figures in a plot, outer=TRUE)


Uwe Ligges




cols - sample(rainbow(20))
par(mfrow=c(1,20),mar=c(4,0.05,3,0.05))
plot.new()
mtext(Multiple figures in a plot,line=1,at=13)
for ( i in 1:20)
{
  tmp - subset(df, df[,2]==i)
  if(i!=1)
  {
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
mtext(i, line=1,side=1)
  }
  else{

plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,mar=c(4,4,3,0.05),ylim=c(0,5))
axis(2,at=0:5)
mtext(i, line=1,side=1)
}
}


Any suggestions and advices are welcome.

Thanks,
Mike

__
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-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] plot error -- figure margins too large

2009-09-29 Thread Ping-Hsun Hsieh
Thanks, Uwe.
You code does what I would like to have!

Best,
Mike

-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Tuesday, September 29, 2009 1:36 AM
To: Ping-Hsun Hsieh
Cc: r-help@r-project.org
Subject: Re: [R] plot error -- figure margins too large



Ping-Hsun Hsieh wrote:
 Hi,
 
 I am trying to plot my dataset, consisting of one column with numeric values 
 and one column with group IDs.
 The set is similar to the following df.
 
 df - NULL
 for ( i in 1:20)
 {
   tmp1 - runif(1000,0,5)
   tmp2 - cbind(tmp1,i)
   df - rbind(df,tmp2)
 }
 
 
 Now I would like to plot the numeric column, stratified by the group IDs, in 
 a single figure.
 First, I partitioned the frame into a 1x20 array. Then I plot the numeric 
 values of each group in a sub-plot.
 Note that only should the left most y-axis be shown, and the x-axis is only 
 the group numbers.
 Also the margin between two sub-frame should be fairly small so it looks like 
 only one figure, rather than 20 figures.
 
 The following codes were used to achieve my goal, but I got an error saying 
 figure margins too large.
 
 cols - sample(rainbow(20))
 par(mfrow=c(1,20))
 for ( i in 1:20)
 {
   tmp - subset(df, df[,2]==i)
   if(i!=1)
   {
 plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
 mtext(i, line=1,side=1)
   }
   else{
 plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
 axis(2,at=0:5)
 mtext(i, line=1,side=1)
 }
 }
 
 I also tried to set the margins by modifying the _par_ command: 
 par(mfrow=c(1,20),mar=(4,2,4,0.05))
 Still, received the same error.


The error depens on the space of your device. If your device is larger, 
it might work. For a smaller device I'd try


df - matrix(c(runif(2,0,5), rep(1:20, each=1000)), ncol=2)
cols - sample(rainbow(20))
par(mfrow=c(1,20), oma=c(5,5,4,1), mar=rep(0, 4))
# nor margins (mar) for a single figure, but outer margins (oma)
for ( i in 1:20)
{
   tmp - subset(df, df[,2]==i)
   if(i!=1)
   {
 
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5), 
ylab=)
 mtext(i, line=1,side=1)
   }
   else{
 plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
 axis(2,at=0:5)
 mtext(i, line=1,side=1)
 }
}



or even better go with lattice that does the job for you.



 
 The other experiment:
 While I was using the following codes, it almost showed what I would like, 
 but the figure ended with only the last sub-plot. The only difference between 
 the two is I was attempting to add a main-label in the figure.


To add a main label, use the code above and add:


title(Multiple figures in a plot, outer=TRUE)


Uwe Ligges



 cols - sample(rainbow(20))
 par(mfrow=c(1,20),mar=c(4,0.05,3,0.05))
 plot.new()
 mtext(Multiple figures in a plot,line=1,at=13)
 for ( i in 1:20)
 {
   tmp - subset(df, df[,2]==i)
   if(i!=1)
   {
 plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
 mtext(i, line=1,side=1)
   }
   else{
 
 plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,mar=c(4,4,3,0.05),ylim=c(0,5))
 axis(2,at=0:5)
 mtext(i, line=1,side=1)
 }
 }
 
 
 Any suggestions and advices are welcome.
 
 Thanks,
 Mike
 
 __
 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-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] plot error -- figure margins too large

2009-09-28 Thread Ping-Hsun Hsieh
Hi,

I am trying to plot my dataset, consisting of one column with numeric values 
and one column with group IDs.
The set is similar to the following df.

df - NULL
for ( i in 1:20)
{
  tmp1 - runif(1000,0,5)
  tmp2 - cbind(tmp1,i)
  df - rbind(df,tmp2)
}


Now I would like to plot the numeric column, stratified by the group IDs, in a 
single figure.
First, I partitioned the frame into a 1x20 array. Then I plot the numeric 
values of each group in a sub-plot.
Note that only should the left most y-axis be shown, and the x-axis is only the 
group numbers.
Also the margin between two sub-frame should be fairly small so it looks like 
only one figure, rather than 20 figures.

The following codes were used to achieve my goal, but I got an error saying 
figure margins too large.

cols - sample(rainbow(20))
par(mfrow=c(1,20))
for ( i in 1:20)
{
  tmp - subset(df, df[,2]==i)
  if(i!=1)
  {
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
mtext(i, line=1,side=1)
  }
  else{
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
axis(2,at=0:5)
mtext(i, line=1,side=1)
}
}

I also tried to set the margins by modifying the _par_ command: 
par(mfrow=c(1,20),mar=(4,2,4,0.05))
Still, received the same error.


The other experiment:
While I was using the following codes, it almost showed what I would like, but 
the figure ended with only the last sub-plot. The only difference between the 
two is I was attempting to add a main-label in the figure.

cols - sample(rainbow(20))
par(mfrow=c(1,20),mar=c(4,0.05,3,0.05))
plot.new()
mtext(Multiple figures in a plot,line=1,at=13)
for ( i in 1:20)
{
  tmp - subset(df, df[,2]==i)
  if(i!=1)
  {
plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,ylim=c(0,5))
mtext(i, line=1,side=1)
  }
  else{

plot(df[,1],axes=F,col=cols[i],frame.plot=F,xlab=NA,pch=19,mar=c(4,4,3,0.05),ylim=c(0,5))
axis(2,at=0:5)
mtext(i, line=1,side=1)
}
}


Any suggestions and advices are welcome.

Thanks,
Mike

__
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] Plot error

2009-06-01 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 28.05.2009 16:21:01:

  I want to plot data such that the 3 time points(a,b,c) lie on the 
X-axis 
 and
  the values of these times points are on Y-axis for n samples 
(e.g.100).
  
  So, I have an object x, dim 100 4, it is a dataframe (when checked the
  class)
  x = 
  name   a   b  c
  10.11  1.11   0.86
  2   .  .   .
  3   .  .   .
  .
  .
  .
  100
  
  so when i say:
  
   plot(1:3, x[,2:4], type=l) - I get the error below
  
  Error in xy.coords(x, y, xlabel, ylabel, log) : 
 (list) object cannot be coerced to type 'double'
  
  However if I do:
   plot(1:3, x[1,2:4], type=l) -- It works for the 1st row, and 
 each
   individual row BUT NOT ALL ROWS
  
  Please could someone explain what is happening here?
  
  I wonder if I need to use 'lines' for the remaining, BUT I have 
another
  dataset y with same dimensions as x, which I want to plot on the same
  graph/plot to see the difference between x and y.
 
 Your data looks like this:
 x - data.frame(name=sample(letters, 10), a=runif(10), b=rnorm(10), 
 c=rlnorm(10))
 
 The problem is that the subset x[,2:4] is also a data frame, not a 
matrix.
 class(x[,2:4])  #[1] data.frame
 
 The simplest thing is probably to use lines, as you say.
 row - seq_len(nrow(x))
 xx - x[,2:4]
 plot(row, xx$a, ylim=range(xx), type=l)
 lines(row, xx$b, col=blue)
 lines(row, xx$c, col=green)

Maybe also matplot is worth try

matplot(1:3,t(x[,2:4]))

regards
Petr





 
 Regards,
 Richie.
 
 Mathematical Sciences Unit
 HSL
 
 
 
 ATTENTION:
 
 This message contains privileged and confidential 
inform...{{dropped:20}}
 
 __
 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-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] Plot error

2009-05-28 Thread NatsS

Hello,

I am an R amateur.

I want to plot data such that the 3 time points(a,b,c) lie on the X-axis and
the values of these times points are on Y-axis for n samples (e.g.100).

So, I have an object x, dim 100 4, it is a dataframe (when checked the
class)
x = 
name   a   b  c
10.11  1.11   0.86
2   .  .   .
3   .  .   .
.
.
.
100

so when i say:

 plot(1:3, x[,2:4], type=l) - I get the error below

Error in xy.coords(x, y, xlabel, ylabel, log) : 
   (list) object cannot be coerced to type 'double'

However if I do:
 plot(1:3, x[1,2:4], type=l) -- It works for the 1st row, and each
 individual row BUT NOT ALL ROWS

Please could someone explain what is happening here?

I wonder if I need to use 'lines' for the remaining, BUT I have another
dataset y with same dimensions as x, which I want to plot on the same
graph/plot to see the difference between x and y.

Thanks,
NS
-- 
View this message in context: 
http://www.nabble.com/Plot-error-tp23761408p23761408.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] Plot error

2009-05-28 Thread Richard . Cotton
 I want to plot data such that the 3 time points(a,b,c) lie on the X-axis 
and
 the values of these times points are on Y-axis for n samples (e.g.100).
 
 So, I have an object x, dim 100 4, it is a dataframe (when checked the
 class)
 x = 
 name   a   b  c
 10.11  1.11   0.86
 2   .  .   .
 3   .  .   .
 .
 .
 .
 100
 
 so when i say:
 
  plot(1:3, x[,2:4], type=l) - I get the error below
 
 Error in xy.coords(x, y, xlabel, ylabel, log) : 
(list) object cannot be coerced to type 'double'
 
 However if I do:
  plot(1:3, x[1,2:4], type=l) -- It works for the 1st row, and 
each
  individual row BUT NOT ALL ROWS
 
 Please could someone explain what is happening here?
 
 I wonder if I need to use 'lines' for the remaining, BUT I have another
 dataset y with same dimensions as x, which I want to plot on the same
 graph/plot to see the difference between x and y.

Your data looks like this:
x - data.frame(name=sample(letters, 10), a=runif(10), b=rnorm(10), 
c=rlnorm(10))

The problem is that the subset x[,2:4] is also a data frame, not a matrix.
class(x[,2:4])  #[1] data.frame

The simplest thing is probably to use lines, as you say.
row - seq_len(nrow(x))
xx - x[,2:4]
plot(row, xx$a, ylim=range(xx), type=l)
lines(row, xx$b, col=blue)
lines(row, xx$c, col=green)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
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] plot error

2008-09-23 Thread glaporta

HI there,

why these lines of code are correct
plot(count~spray, data = InsectSprays)
plot(InsectSprays$count)

but this return an error:
plot(count, data = InsectSprays);

data method is not implemented in plot?!
Thanx, Gianandrea
-- 
View this message in context: 
http://www.nabble.com/plot-error-tp19624873p19624873.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] plot error

2008-09-23 Thread Barry Rowlingson
2008/9/23 glaporta [EMAIL PROTECTED]:

 HI there,

 why these lines of code are correct
 plot(count~spray, data = InsectSprays)
 plot(InsectSprays$count)

 but this return an error:
 plot(count, data = InsectSprays);

 data method is not implemented in plot?!

 The 'plot' function, like many functions in R, does different things
depending on what its first parameter is...

 For plot(count~spray, data=InsectSprays) the first parameter is a
formula, so what is really called is 'plot.formula'. This gets the
names from the formula (count~spray) finds them in the 'data'
parameter and does a plot.

 For plot(InsectSprays$count) you've taken the 'count' vector out of
the data frame, so the ordinary plot function is called.

 If you do plot(count, data=InsectSprays), then 'count' here is just a
bare word, so R looks up 'count' as an object, but doesn't find it (as
long as there's no 'count' object in your workspace).

 You can do plot(~count, data=InsectSprays), but you get a slightly
different plot than plot(count$InsectSprays). Compare and contrast the
following:

  is=data.frame(count=runif(10),spray=runif(10))
  plot(count,data=is)
 Error in plot(count, data = is) : object count not found
  plot(~count,data=is)
  plot(count~1,data=is)
  plot(is$count)

Barry

__
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] Plot error

2008-01-04 Thread pedrosmarques

Hi all,

I'm trying to plot an svm model and I'm the following error:

 plot(model, data= dados[,-1], formula=formula(dados[,2]~dados[,3]),svSymbol = 
 1, dataSymbol = 2, symbolPalette = rainbow(4),color.palette = terrain.colors)
Error in terms.default(x) : no terms component

Anyone knows how to solve this???

Best regards,

Pedro Marques

__
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] Plot error

2008-01-04 Thread Richard . Cotton
 I'm trying to plot an svm model and I'm the following error:
 
  plot(model, data= dados[,-1], formula=formula(dados[,2]~dados[,
 3]),svSymbol = 1, dataSymbol = 2, symbolPalette = rainbow(4),color.
 palette = terrain.colors)
 Error in terms.default(x) : no terms component
 
 Anyone knows how to solve this???

Asking the same question over and over again doesn't make it easier for us 
to help you.  Also, it is good form to point out which package you are 
using (I presume this is svm in package e1071).

Please can you provide a reproducible example?  (We don't have access to 
the dados data.)
In the meantime, try typing traceback() after you get the error to see 
where the problem is.  Or, even better, install the debug package and step 
through your code using mtrace.

Regards,
Richie.

Mathematical Sciences Unit
HSL




ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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