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