How to apply striped style to a table, two rows at a time [duplicate] - css

This question already has answers here:
How to create zebra stripes on html table without using javascript and even/odd classes generation?
(5 answers)
Closed 2 days ago.
Consider this table:
<table>
<tbody>
<tr><td>First data row</td></tr>
<tr><td>Actions of the first row</td></tr>
<tr><td>Second data row</td></tr>
<tr><td>Actions of the second data row</td></tr>
<tr><td>Third data row</td></tr>
<tr><td>Actions of the third data row</td></tr>
<tr><td>Fourth data row</td></tr>
<tr><td>Actions of the fourth data row</td></tr>
</tbody>
</table>
Odd and even rows here does not work.
Is there a technique that I can apply style on the two rows that are connected to each other?

You can use nth-child formulas to do what you want
tbody > tr:nth-child(4n-3) {
background-color: red;
}
tbody > tr:nth-child(4n-2) {
background-color: red;
}
<table>
<tbody>
<tr><td>First data row</td></tr>
<tr><td>Actions of the first row</td></tr>
<tr><td>Second data row</td></tr>
<tr><td>Actions of the second data row</td></tr>
<tr><td>Third data row</td></tr>
<tr><td>Actions of the third data row</td></tr>
<tr><td>Fourth data row</td></tr>
<tr><td>Actions of the fourth data row</td></tr>
</tbody>
</table>

Related

Time-Based Clustering of Multidimensional Data

I'm trying to do clustering of a large number of people based on the pattern of their hours worked across a week. This is an example of the data I'm working with:
table, th, td {
border: 1px solid black;
}
<table>
<tr>
<th>Name</th>
<th>Monday (00:00 to 07:59)</th>
<th>Monday (08:00 to 15:59)</th>
<th>Monday (16:00 to 23:59)</th>
</tr>
<tr>
<td>Guy1</td>
<td>3</td>
<td>5.5</td>
<td>0.5</td>
</tr>
<tr>
<td>Guy2</td>
<td>0</td>
<td>7</td>
<td>2</td>
</tr>
<tr>
<td>Guy3</td>
<td>4</td>
<td>4</td>
<td>1</td>
</tr>
</table>
I want to find clusters based on the pattern of their work hours. The actual data set I'm working with has over 10000 rows (distinct individuals) and has 42 columns (intervals of hours). I am using R-Studio.
I want to see "profiles" of different individuals, which will be based on the similarity of the pattern of work hours in the week. For example, maybe one person's work hours are focused on 9am to 6pm on weekdays, showing that he belongs to the cluster of employees with regular schedules, while another's work hours are focused in the nighttime, indicating that the person works the night shift.
Note that I am an intern who hasn't graduated yet, and I just learned R today. This is also my first StackOverflow question, so pardon me for sounding ignorant or uninformed.
You may want to have a look at the theory of clustering, first.
For exemple looking at that post. And then follow up on some R code.
The reason is because clustering is often very dependent on your data and what you want to achieve. There is often no perfect solution, so you have to assess yourself if what you have done is good enough or not.
You can do some research on k-means and hierarchical clustering, there is plenty of ressources on internet. My favorite being the R help that you can find in the help tab of Rstudio.
Look for hclust or kmeans to get exemple of how these functions works.
You can also have a look at hts which allow to create cluster of time series. That may solve the issue you can have when creating a matrix distance of 10k * 10k.

R data transformation, aggregation [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm trying to transform the following data frame from:
<table border = 1>
<tr>
<td>id</td>
<td>code</td>
<td>status</td>
</tr>
<tr>
<td>123</td>
<td>041</td>
<td>C</td>
</tr>
<tr>
<td>123</td>
<td>056</td>
<td>NC</td>
</tr>
<tr>
<td>123</td>
<td>036</td>
<td>NC</td>
</tr>
<tr>
<td>456</td>
<td>075</td>
<td>C</td>
</tr>
<tr>
<td>456</td>
<td>059</td>
<td>C</td>
</tr>
<tr>
<td>456</td>
<td>039</td>
<td>NC</td>
</tr>
<tr>
<td>456</td>
<td>021</td>
<td>NC</td>
</tr>
</table>
to like as follows: (in a way i'm trying to pivot my results on the Status field, however given that the code is string, I want to concatenate the codes that fall under that status.
<table border=1>
<tr>
<td>id</td>
<td>c</td>
<td>nc</td>
</tr>
<tr>
<td>123</td>
<td>041</td>
<td>056;036</td>
</tr>
<tr>
<td>456</td>
<td>075;059</td>
<td>039;021</td>
</tr>
</table>
I have tried to use reshape/reshape2 as well, however, I'm not getting success. Can anyone suggest any methods that can assist
was able to figure it out.
using dyplr package.
group_by, summarise and mutate commands
Thank you!

Page Not Breaking Using NetSuite BFO PDF Report Implementation

I'm trying to modify an exist XML template for use with NetSuite's BFO PDF report generator implementation. The basic structure is a table with two rows and two columns, wherein the first row does a column merge. In the second row, one column is populated with data, the other with images. The images are small, and display fits within the first page. However, the data column has a varying amount of information provided, and some of the information provided it HTML formatted (for example an unordered list). The problem is that sometimes there is a lot of data and it runs off of the page without a page break. In some cases I'm able to restructure the data or perform some magic tricks to either reduce the size or break off a chunk add force a second page. In cases like an unordered list, though, I can't do anything with it.
I've tried forcing TBODY tags around TR tags, tried forcing the page-break-inside attribute. Nothing seems to work. For example, this is what I get with a long list:
You can see how the contents overlap the page footer.
And this is what I have for the table row in question:
<tbody page-break-inside="auto">
<tr style="border-top:4px solid; padding-bottom:10px;" page-break-inside="auto">
The content is also encapsulated within a DIV tag:
<div id="itemDetails" style="min-width: 0px; max-width:545px;">
With this particular example, there are two content fields on the sourced record containing unordered lists in HTML format, and neither have any kind of styling applied. Here's the smaller source chunk (which happens to be cut off the bottom of the displayed page):
<ul>
<li>All the Advantages of Altivar 31 Drive</li>
<li>Excellent Resistance to Harsh Environments (50° C)</li>
<li>Coated Cards as Standard (IEC 60721-3-3 Classes 3c2 and 3s2)</li>
<li>Excellent Resistance to Power Supply and Motor Interference</li>
<li>0.25 HP to 20 HP</li>
<li>Single-Phase 200 V to 240 V, Three-Phase 200 V to 240 V, Three-Phase 380 V to 500 V, Three-Phase 525 V to 600 V</li>
<li>Integrated Class 2 Emc Filter for Radiated and Conducted Emissions</li>
<li>Din Rail Mounting</li>
</ul>
Any suggestions on what may help to get this data to page break? I feel like there's an obvious solution I'm not thinking of.
After trying for the past week to get the same issue resolved, I decided to do page breaks when listing information if the information in the list is longer than what will fit on a single page. OP's comment pointed me in this direction - you need to use/omit nested elements to pull it off.
I'm using a div with page-break-inside: avoid; if the length of the data I'm going to display is less than what fits on a single page. Otherwise I omit the div and just use the table - this allows the table rows to break onto multiple pages.
For the following example, my main data object is searchResults. It contains a property of valueArr, which is the array of hashes I need to display in the printout. I have styleObj.maxCoilsPerPage set to 30 for one type of this printout; you'll need to change this to the number of lines that can fit on a single page in your case.
CSS snippet:
.nopagebreak {
page-break-inside: avoid;
}
HTML snippet:
<#list searchResults.valueArr as item>
<#if (item.valueArr?size lte styleObj.maxCoilsPerPage?number)>
<div class="nopagebreak">
</#if>
<table>
<tr>
<td width="70%">${item.itemName}</td>
...other table data...
</table>
<#if (item.valueArr?size lte styleObj.maxCoilsPerPage?number)>
</div>
</#if>
</#list>

How to Convert days of week into numbers for correlation calculation using R

Is there an accepted way to handle converting the days of the week from text to numeric values for calculating the correlation coefficient in R ?
Should I use dummyVars maybe using the caret package in R and treat them as categorical or is there a better way to avoid any possible dummy variable trap or data loss?
Maybe the following sample table will help the discussion (just show the code snippet and run to see a very basic table)
<table>
<tr>
<th>PurchaseDay</th>
<th>Product</th>
<th>Count</th>
<th>ReturnDay</th>
</tr>
<tr>
<td>Wednesday</td>
<td>Tractor</td>
<td>3</td>
<td>Tues</td>
</tr>
<tr>
<td>Monday</td>
<td>Bus</td>
<td>2</td>
<td>Mon</td>
</tr>
<tr>
<td>Saturday</td>
<td>Tractor</td>
<td>5</td>
<td>Tues</td>
</tr>
</table>
Is it important that Mon and Monday get the same numeric coding even though they are in different columns?
What is the standard way of representing days of the week as numbers in R so I can create a numeric representation of the data and pass it to the corr()

JSF- h:panelGrid specific style for specific column

There is h:panelGrid table with 2 columns.
It's needed,that first column to be 30% and the second one 70% of whole table width.
Is there some configuration for such case?
Looks like columnClasses attribute applied for all columns,
and it's needed specific CSS class for specific column.
Just use column-separated list of classes: columnClasses="column1Class, column2Class". By documentation the column1Class will be used for the first column and the column2Class for the second column.

Resources