[R] Reading large data matrix in R

Bert Gunter gunter.berton at gene.com
Mon Jan 12 19:29:28 CET 2015


You really need to read ?xyplot and probaby also an R tutorial such as

cran.r-project.org/doc/manuals/R-intro.pdf

(which also ships with R) to learn about S3 methods.

R is a language that requires an investment in time and effort to
learn. If you are unwilling to make that investment, use other
software.


Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Mon, Jan 12, 2015 at 3: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
>
>
> ---------------------------------------------------------
>
> Bomidi Lakshmi Madhavan, Ph.D
> Remote Sensing of Atmospheric Processes
> Leibniz Institute for Tropospheric Research (TROPOS)
> Permoserstraße 15, D-04318 Leipzig, Germany
> Phone: +49 (0)341 2717-7187 (Office), +49 (0)1578 8467548 (Mobile)
> E-Mail: *madhavan.bomidi at tropos.de <madhavan at tropos.de>, **blmadhavan at gmail.com
> <blmadhavan at gmail.com>*
> Skype ID: *blmadhavan*, Web: *http://sat.tropos.de
> <https://mail.tropos.de/owa/redir.aspx?C=b471dab8af5b46d99137a92f561b4753&URL=http%3a%2f%2fwww.tropos.de>*
>
>
> On Fri, Jan 9, 2015 at 11:23 PM, David Winsemius <dwinsemius at comcast.net>
> wrote:
>
>>
>> On Jan 9, 2015, at 6:44 AM, Madhavan BL wrote:
>>
>> > Dear All,
>> >
>> > Greetings. I am a new user of R programming.
>> >
>> > I have a large ASCII data file with 14 columns and 45000 rows. I tried to
>> > load the file using read.table(), scan(), etc. functions, but failed to
>> > load the data file properly. Missing values in my data are denoted by
>> > "NaN". I also want to exclude these lines. I don't have a column header
>> but
>> > I would like to include the labels in plotting.
>>
>> What these "labels" you are referring to?
>>
>> > All the data is in floats.
>> >
>> > Can anyone give me some short examples to open my file?
>>
>> The default settings for `read.table` assume that there is no header row
>> and that `NA` is the missing value indicator. See ?read.table for more on
>> the default settings. If you have `NaN` as missing value you need to
>> include an na.strings="NaN" argument in the `read.table` call.
>>
>> You would need to post process results to exclude rows. There is no
>> interval skipping mechanism that I know about.
>>
>> `scan` assumes all lines have the same structure so answering the question
>> about "labels" would be necessary for any advice about its use here.
>>
>>
>> >
>> > Look forward for your support,
>> >
>> > Thanking you in advance,
>> > Regards,
>> > Madhavan
>>
>> >       [[alternative HTML version deleted]]
>>
>> I suggest you investigate how to configure your mail-client to respond in
>> plain text.
>>
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>>
>> David Winsemius
>> Alameda, CA, USA
>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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