[R] How to set read.table variables to vectors?
jim holtman
jholtman at gmail.com
Wed Oct 29 12:47:26 CET 2008
'xin' is an element of a dataframe and you must explicity reference it
as such. See the Intro to R.
plot(mydata$xin, mydata$yin)
On Wed, Oct 29, 2008 at 4:29 AM, Leif Peterson <peterson.leif at ieee.org> wrote:
> The summary stats for the xin and yin variables below are correct. However,
> if I use plot(xin,yin), an exception is thrown saying that "object xin is
> not found."
>
> Also, it is apparent that I can't successfully replace the x and y vectors
> with values from xin and yin.
>
> The four plots on one panel are showing but the range of x and y is only
> [0,1], and therefore, it seems like an integer vs. real issue. Please help.
>
> Thanks,
>
> LP
>
>
>
>>
>> mydata<-read.table("C:/refvecs_iters_5.csv", header=TRUE, sep=",",
> na.strings="NA", dec=".", strip.white=TRUE, row.names=1)
>>
>> x <- runif(1000)
>> y <- runif(1000)
>>
>> summary(mydata)
> iter xin yin
> Min. : 0 Min. : 0.01792 Min. : 0.03055
> 1st Qu.: 5 1st Qu.: 3.10674 1st Qu.: 3.13284
> Median :10 Median : 5.46899 Median : 5.43446
> Mean :10 Mean : 5.43360 Mean : 5.39696
> 3rd Qu.:15 3rd Qu.: 7.70127 3rd Qu.: 7.70780
> Max. :20 Max. :10.00000 Max. :10.00000
>>
>> plot(xin,yin)
> Error in plot(xin, yin) : object "xin" not found
>>
>> split.screen(c(2,2))
> [1] 1 2 3 4
>>
>> for (k in 0:3){
> +
> + screen(k+1)
> + cnt <- 0
> + #grp<- iter * 5
> + for (i in 1:5000 ) {
> + if (iter<-k*5) {
> + cnt = cnt + 1
> + x[cnt] <- myx[i]
> + y[cnt] <- myy[i]
> + }
> + }
> + #p = cbind(x=rnorm(300), y=rnorm(300))
> + #p = cbind(x, y)
> + #tt = delaunayn(p)
> + #trimesh(tt,p,axis=TRUE,box=TRUE)
> + plot(myx,myy)
> + }
>>
>>
>
>
> [[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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list