[R] Matrices

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Aug 10 19:57:28 CEST 2009


On Mon, 2009-08-10 at 13:41 -0400, mmv.listservs wrote:
> I should give an example

Thanks for that - I just two seconds ago sent a reply to the list
complaining because you didn't provide one. However, the code below
doesn't work.

> 
> for(p in 1:100)
> {
>     str <- paste("Task", p, sep=" ")
>     task_name[p] <- str
> }

We don't have task_name so this bit fails

> 
> ## first set the random seed so we get the same results
> set.seed(123)
> ## now produce some dummy data
> dummy <- data.frame(A = sample(LETTERS[1:4], 100, replace = TRUE),
>                    B = sample(c("T","F"), 100, replace = TRUE),
>                    C = rnorm(100))
> 
> dummy <- cbind(dummy, task_name)

As does this bit

> 
> names(dummy)
> 
> plot(dummy$A, dummy$task_name)

So we don't get the plot I think you wanted us to get here.

If my reply (winging its way to you as we speak) doesn't solve the
problem, then work on your example so that it works in a clean R
session. If you start a new R session and paste in your code/example,
you'll see if it runs OK or not.

HTH

G

> 
> if you look at the plot you see the task names are printed but cut off.
> 
> if I change the plot command using as.numeric I get task names with numbers.
> It is still hard to interpret which number the task is referring too?
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list