[R] Simple x,y Plot
arun
smartpink111 at yahoo.com
Sun Jul 29 18:41:09 CEST 2012
Hi,
As there is not much information like str() or the data, it is difficult to comment.
But, try this (considering your x and y are factors):
x<-c("1","4","7","9","10","15")
y<-c("3","5","8","6","5","14")
dat1<-data.frame(x,y)
str(dat1)
'data.frame': 6 obs. of 2 variables:
$ x: Factor w/ 6 levels "1","10","15",..: 1 4 5 6 2 3
$ y: Factor w/ 5 levels "14","3","5","6",..: 2 3 5 4 3 1
dat2<-dat1
dat2$x<-as.numeric(as.character(dat2$x) )
is.numeric(dat2$x)
#[1] TRUE
dat2$y<-as.numeric(as.character(dat2$y))
is.numeric(dat2$y)
#[1] TRUE
#Now try plot
x1<-dat2[,1]
y1<-dat2[,2]
plot(x1,y1)
Hope this helps.
A.K.
----- Original Message -----
From: sappy <robert.wittkopf at gmx.de>
To: r-help at r-project.org
Cc:
Sent: Sunday, July 29, 2012 11:18 AM
Subject: [R] Simple x,y Plot
Dear Community,
i have read in a table with two column from a *txt-File. What i get is a
data-frame wit two column.
After that i allocate this 2 column to x and y. Plotting this, i obtain a
picture that looks like a bar plot (something like a grid).
Is that because x and y is in factor-formatted? A conversion with
"asnumeric" doesnt work. I get a vector with "NA".
Here is my code:
daten<-read.table("C:/Users/Robert/Desktop/regen.txt", header=FALSE,
colClasses=c("real","real"))
x<-daten[,1]
y<-daten[,2]
plot(x,y)
Greetings
--
View this message in context: http://r.789695.n4.nabble.com/Simple-x-y-Plot-tp4638262.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
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.
More information about the R-help
mailing list