Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:13:57+00:00 2026-06-04T17:13:57+00:00

Consider the following: temp <- array(sample(1:100,12), dim=c(365,12)) Depth <- as.vector(seq(1,12,by=1)) time <- seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),

  • 0

Consider the following:

temp <- array(sample(1:100,12), dim=c(365,12))
Depth <- as.vector(seq(1,12,by=1))
time <- seq(from=as.Date("2011-01-01"), to=as.Date("2011-12-31"), by=1)

Data <- data.frame(Time = time, Temp = as.matrix(temp))
colnames(Data) <- c("Datetime", paste(Depth,"m",sep = "")) 

Don’t take into account the 3 lines used in generating the data.frame as they are merely used to generate a similar example I am currently working with. The data.frame i.e. ‘Data’ consists of a Date-time vector and corresponding temperature measurements recorded at different depths where the depth of each measurement is given as the column names.

From this I would like to generate a filled contour plot of the temperature profile. So, I want to place the DateTime vector as the x values, the col headings as the y values and the temp as the z values. How would I go about achieving this?

I have only just converted from matlab to R so apologies for what is probably a very simple problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:13:59+00:00Added an answer on June 4, 2026 at 5:13 pm

    Lattice makes this pretty easy is you have the data in the right structure (long and thin not wide and short – you have it in the latter at the moment)

    First get the data into the required format using some simple data manipulations

    ## make the colnames numeric-ish
    names(Data)[-1] <- sub("m", "", names(Data)[-1])
    ## stack the data
    Data2 <- data.frame(Time = rep(Data$Datetime, times = ncol(Data)-1),
                        stack(Data[, -1]))
    names(Data2)[-1] <- c("Temperature", "Depth")
    ## make Depth numeric
    Data2 <- transform(Data2, Depth = as.numeric(as.character(Depth)))
    

    This gives us:

    > head(Data2)
            Time Temperature Depth
    1 2011-01-01          84     1
    2 2011-01-02          19     1
    3 2011-01-03          25     1
    4 2011-01-04          21     1
    5 2011-01-05           1     1
    6 2011-01-06          26     1
    

    Load lattice and plot the data using the contourplot() function:

    require(lattice)
    contourplot(Temperature ~ Time * Depth, data = Data2)
    

    For this example data set, it might help to use

    contourplot(Temperature ~ Time * Depth, data = Data2, labels = FALSE,
                region = TRUE)
    

    because the contours are essentially formed around tiny chunks of data.

    See the ?contourplot page for more on the various options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following: set.seed(1) RandData <- rnorm(100,sd=20) Locations <- rep(c('England','Wales'),each=50) today <- Sys.Date() dseq
Consider following tables: How to skip and take groups from the table? Tried using
Consider following example: #include <iostream> #include <functional> #include <algorithm> #include <vector> #include <boost/bind.hpp> const
Consider following example. #include <iostream> #include <algorithm> #include <vector> #include <boost/bind.hpp> void func(int e,
Consider the following table: create table temp ( name int, a int, b int
Consider the following code: SET @SQL1 = 'SELECT * INTO #temp WHERE ...' exec(@SQL1)
Consider the following code snippet in Java. I know that the statement temp[index] =
I am using DBContext API from EF 4.1. Consider following entity model (A, B,
Let's first consider the following expressions in Java. Integer temp = new Integer(1); System.out.println(temp.equals(1));
Consider following two examples: Example 1: <xs:import namespace=http://example.com/ns schemaLocation=test.xsd/> Example2: <sample:Data Test=true xsi:schemaLocation=http://example.com/test.xsd> How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.