[R] Reading large data matrix in R

Sarah Goslee sarah.goslee at gmail.com
Mon Jan 12 19:35:12 CET 2015


I'm not at all clear on what you want your plots to look like, but I
would recommend reading the help for xyplot and trying out the
examples. In general, you need to pass xyplot() a formula that
describes what you want your plots to contain, and then a data
argument with the data for doing so.

?xyplot is very long, but do take a look. Then if you can't get your
code working, a detailed description of what you're trying to achieve
would be useful.

Sarah

On Mon, Jan 12, 2015 at 6:17 AM, Madhavan BL <blmadhavan at gmail.com> wrote:
> Hello,
>
> While I could read my data through of read.table(), I was unable to get the
> simple line plots and horizon plot using my code below.  I get the
> following error messages:
>
>> xyplot(wdj, scales = list(y= "same"))Error in UseMethod("xyplot") :
>   no applicable method for 'xyplot' applied to an object of class
> "c('matrix', 'double', 'numeric')"> horizonplot(wdj, layout = c(1,12),
> colorkey = TRUE)Error in UseMethod("xyplot") :
>   no applicable method for 'xyplot' applied to an object of class
> "c('matrix', 'double', 'numeric')"
>
> I tried to check my data type by typeof(wdj) which indicates that my
> data is "double". Can anyone help me where I am going wrong? I also
> attach my data file for your convenience along with the code I am
> using below.
>
>
> Below is my R-code for plotting Horizon plot for wavelet details at
> different averaging scales
>
> # Clear out the workspace
> rm(list=ls())
>
> # store the current directory
> initial.dir<-getwd()
>
> # load the necessary libraries
> require(lattice)
> require(latticeExtra)
>
> # load the dataset
> infile <- "pyr43_rsds_wdj_20130413.txt"
> datasets <- ts(read.table(infile, quote="\"", na.strings="NaN"))
>
> # Remove rows with NaN values
> datasets <- datasets[complete.cases(datasets), ]
> time <- datasets[,1]  # Time in UTC hours
> ws0 <- datasets[,2]  # raw irradiance signal at 1 second resolution
> wdj <- datasets[,3:14]  # wavelet details at different averaging scales
>
> # Column names of the dataset
> # colnames(datasets) <-
>  c("Time","1s","5s","10s","20s","40s","1m20s","2m40s","5m20s","10m40s","21m20s","42m40s","1h25m20s","2h50m40s")
> colnames(wdj) <-
> c("5s","10s","20s","40s","1m20s","2m40s","5m20s","10m40s","21m20s","42m40s","1h25m20s","2h50m40s")
>
> # Simple line plot
> xyplot(wdj, scales = list(y= "same"))
>
> # panel with different origin and scale
> horizonplot(wdj, layout = c(1,12), colorkey = TRUE)
>
>
> Thanking you in advance,
> With regards,
> Madhavan
>
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list