how to open pdf file on button click in c# : Search pdf files for text programmatically Library application class asp.net html wpf ajax R%20Graphics%20Cookbook36-part1043

Discussion
The usefulness of reorder() might not be obvious from just looking at the raw output.
Figure 15-1 shows three graphs made with reorder(). In these graphs, the order in
which the items appear is determined by their values.
Figure 15-1. Left: original data; middle: reordered by the mean of each group; right: re‐
ordered by the median of each group
In the middle graph in Figure 15-1, the boxes are sorted by the mean. The horizontal
line that runs across each box represents the median of the data. Notice that these values
do not increase strictly from left to right. That’s because with this particular data set,
sorting by the mean gives a different order than sorting by the median. To make the
median lines increase from left to right, as in the graph on the right in Figure 15-1, we
used the median() function in reorder().
See Also
Reordering factor levels is also useful for controlling the order of axes and legends. See
Recipes 8.4 and 10.3 for more information.
15.10. Changing the Names of Factor Levels
Problem
You want to change the names of levels in a factor.
Solution
Use revalue() or mapvalues() from the plyr package:
sizes <- factor(c( "small""large""large""small""medium"))
sizes
small  large  large  small  medium
15.10. Changing the Names of Factor Levels  |  345
Search pdf files for text programmatically - search text inside PDF file in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Learn how to search text in PDF document and obtain text content and location information
pdf find and replace text; pdf find highlighted text
Search pdf files for text programmatically - VB.NET PDF Text Search Library: search text inside PDF file in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Learn How to Search Text in PDF Document and Obtain Text Content and Location Information in VB.NET application
how to select text in a pdf; how to select all text in pdf
Levels: large medium small
levels(sizes)
"large"  "medium" "small"
# With revalue(), pass it a named vector with the mappings
sizes1 <- revalue(sizes, c(small="S", medium="M", large="L"))
sizes1
S L L S M
Levels: L M S
# Can also use quotes -- useful if there are spaces or other strange characters
revalue(sizes, c("small"="S""medium"="M""large"="L"))
# mapvalues() lets you use two separate vectors instead of a named vector
mapvalues(sizes, c("small", "medium", "large"), c("S", "M", "L"))
Discussion
The revalue() and mapvalues() functions are convenient, but for a more traditional
(and clunky) R method for renaming factor levels, use the levels()<- function:
sizes <- factor(c( "small""large""large""small""medium"))
# Index into the levels and rename each one
levels(sizes)[levels(sizes)=="large"]  <- "L"
levels(sizes)[levels(sizes)=="medium"<- "M"
levels(sizes)[levels(sizes)=="small"]  <- "S"
sizes
S L L S M
Levels: L M S
If you are renaming all your factor levels, there is a simpler method. You can pass a list
to levels()<-:
sizes <- factor(c("small""large""large""small""medium"))
levels(sizes) <- list(S="small", M="medium", L="large")
sizes
S L L S M
Levels: L M S
With this method, all factor levels must be specified in the list; if any are missing, they
will be replaced with NA.
It’s also possible to rename factor levels by position, but this is somewhat inelegant:
# By default, levels are ordered alphabetically
sizes <- factor(c("small""large""large""small""medium"))
346  |  Chapter 15: Getting Your Data into Shape
C# PDF File Compress Library: Compress reduce PDF size in C#.net
TIFF files compression and decompression method and Image files compression and images size reducing can help to reduce PDF file size Embedded search index.
search text in multiple pdf; how to select text in pdf reader
C# Create PDF Library SDK to convert PDF from other file formats
a PDF document in C#.NET using this PDF document creating toolkit, if you need to add some text and draw Create PDF Document from Existing Files Using C#.
search a pdf file for text; search pdf files for text programmatically
small  large  large  small  medium
Levels: large medium small
levels(sizes)[1<- "L"
sizes
small  L      L      small  medium
Levels: L medium small
# Rename all levels at once
levels(sizes) <- c("L""M""S")
sizes
[1] S L L S M
Levels: L M S
It’s safer to rename factor levels by name rather than by position, since you will be less
likely to make a mistake (and mistakes here may be hard to detect). Also, if your input
data set changes to have more (or fewer) levels, the numeric positions of the existing
levels could  change,  which  could  cause  serious but nonobvious  problems for your
analysis.
See Also
If, instead of a factor, you have a character vector with items to rename, see Recipe 15.12.
15.11. Removing Unused Levels from a Factor
Problem
You want to remove unused levels from a factor.
Solution
Sometimes, after processing your data you will have a factor that contains levels that are
no longer used. Here’s an example:
sizes <- factor(c("small""large""large""small""medium"))
sizes <- sizes[1:3]
sizes
small  large  large
Levels: large medium small
To remove them, use droplevels():
15.11. Removing Unused Levels from a Factor  |  347
.NET PDF Document Viewing, Annotation, Conversion & Processing
Merge, split PDF files. Insert, delete PDF pages. Read PDF metadata. Search text content inside PDF. Edit, remove images from PDF. Add, edit, delete links.
can't select text in pdf file; how to select all text in pdf file
VB.NET PDF - Convert CSV to PDF
C#.NET rotate PDF pages, C#.NET search text in PDF to batch convert multiple RTF files to adobe PDF files. are able to convert RTF to PDF programmatically with VB
select text in pdf; search pdf documents for text
sizes <- droplevels(sizes)
sizes
small  large  large
Levels: large small
Discussion
The droplevels() function preserves the order of factor levels.
You can use the except argument to keep particular levels.
15.12. Changing the Names of Items in a Character Vector
Problem
You want to change the names of items in a character vector.
Solution
Use revalue() or mapvalues() from the plyr package:
sizes <- c("small""large""large""small""medium")
sizes
"small"  "large"  "large"  "small"  "medium"
# With revalue(), pass it a named vector with the mappings
sizes1 <- revalue(sizes, c(small="S", medium="M", large="L"))
sizes1
"S" "L" "L" "S" "M"
# Can also use quotes -- useful if there are spaces or other strange characters
revalue(sizes, c("small"="S""medium"="M""large"="L"))
# mapvalues() lets you use two separate vectors instead of a named vector
mapvalues(sizes, c("small", "medium", "large"), c("S", "M", "L"))
Discussion
A more traditional R method is to use square-bracket indexing to select the items and
rename them:
sizes <- c("small""large""large""small""medium")
sizes
"small"  "large"  "large"  "small"  "medium"
sizes[sizes=="small" <- "S"
348  |  Chapter 15: Getting Your Data into Shape
C# PowerPoint - PowerPoint Creating in C#.NET
to Create New PowerPoint File and Load PowerPoint from Other Files. searchable and can be fully populated with editable text and graphics programmatically.
pdf searchable text; find text in pdf files
C# Word - Word Creating in C#.NET
Users How to Create New Word File and Load Word from Other Files. is searchable and can be fully populated with editable text and graphics programmatically.
searching pdf files for text; find and replace text in pdf file
sizes[sizes=="medium"<- "M"
sizes[sizes=="large" <- "L"
sizes
"S" "L" "L" "S" "M"
See Also
If, instead of a character vector, you have a factor with levels to rename, see Recipe 15.10.
15.13. Recoding a Categorical Variable to Another
Categorical Variable
Problem
You want to recode a categorical variable to another variable.
Solution
For the examples here, we’ll use a subset of the PlantGrowth data set:
# Work on a subset of the PlantGrowth data set
pg <- PlantGrowth[c(1,2,11,21,22), ]
pg
weight group
4.17  ctrl
5.58  ctrl
4.81  trt1
6.31  trt2
5.12  trt2
In this example, we’ll recode the categorical variable group into another categorical
variable, treatment. If the old value was "ctrl", the new value will be "No", and if the
old value was "trt1" or "trt2", the new value will be "Yes".
This can be done with the match() function:
pg <- PlantGrowth
oldvals <- c("ctrl""trt1""trt2")
newvals <- factor(c("No",   "Yes",  "Yes"))
pg$treatment <- newvals[ match(pg$group, oldvals) ]
It can also be done (more awkwardly) by indexing in the vectors:
pg$treatment[pg$group == "ctrl"] <- "no"
pg$treatment[pg$group == "trt1"] <- "yes"
15.13. Recoding a Categorical Variable to Another Categorical Variable  |  349
C# Word - Word Create or Build in C#.NET
C#.NET using this Word document creating toolkit, if you need to add some text and draw Create Word Document from Existing Files Using C#. Create Word From PDF.
convert a scanned pdf to searchable text; find and replace text in pdf
VB.NET Create PDF Library SDK to convert PDF from other file
Create writable PDF file from text (.txt) file in VB.NET project. Load PDF from stream programmatically in VB.NET.
pdf make text searchable; text searchable pdf
pg$treatment[pg$group == "trt2"] <- "yes"
# Convert to a factor
pg$treatment <- factor(pg$treatment)
pg
weight group treatment
4.17  ctrl        no
5.58  ctrl        no
4.81  trt1       yes
6.31  trt2       yes
5.12  trt2       yes
Here, we combined two of the factor levels and put the result into a new column. If you
simply want to rename the levels of a factor, see Recipe 15.10.
Discussion
The coding criteria can also be based on values in multiple columns, by using the & and
| operators:
pg$newcol[pg$group == "ctrl"  &  pg$weight <  5<- "no_small"
pg$newcol[pg$group == "ctrl"  &  pg$weight >= 5<- "no_large"
pg$newcol[pg$group == "trt1"] <- "yes"
pg$newcol[pg$group == "trt2"] <- "yes"
pg$newcol <- factor(pg$newcol)
pg
weight group weightcat treatment   newcol
4.17  ctrl     small        no no_small
5.58  ctrl     large        no no_large
4.81  trt1     small       yes      yes
4.17  trt1     small       yes      yes
6.31  trt2     large       yes      yes
5.12  trt2     large       yes      yes
It’s also possible to combine two columns into one using the interaction() function,
which appends the values with a "." in between. This combines the weightcat and
treatment columns into a new column, weighttrt:
pg$weighttrt <- interaction(pg$weightcat, pg$treatment)
pg
weight group weightcat treatment   newcol weighttrt
4.17  ctrl     small        no no_small  small.no
5.58  ctrl     large        no no_large  large.no
4.81  trt1     small       yes      yes small.yes
4.17  trt1     small       yes      yes small.yes
6.31  trt2     large       yes      yes large.yes
5.12  trt2     large       yes      yes large.yes
350  |  Chapter 15: Getting Your Data into Shape
See Also
For more on renaming factor levels, see Recipe 15.10.
See Recipe 15.14 for recoding continuous values to categorical values.
15.14. Recoding a Continuous Variable to a
Categorical Variable
Problem
You want to recode a continuous variable to another variable.
Solution
For the examples here, we’ll use a subset of the PlantGrowth data set.
# Work on a subset of the PlantGrowth data set
pg <- PlantGrowth[c(1,2,11,21,22), ]
pg
weight group
4.17  ctrl
5.58  ctrl
4.81  trt1
6.31  trt2
5.12  trt2
In this example, we’ll recode the continuous variable weight into a categorical variable,
wtclass, using the cut() function:
pg$wtclass <- cut(pg$weight, breaks = c(0, 56, Inf))
pg
weight group wtclass
4.17  ctrl   (0,5]
5.58  ctrl   (5,6]
4.81  trt1   (0,5]
4.17  trt1   (0,5]
6.31  trt2 (6,Inf]
5.12  trt2   (5,6]
Discussion
For three categories we specify four bounds, which can include Inf and -Inf. If a data
value falls outside of the specified bounds, it’s categorized as NA. The result of cut() is
a factor, and you can see from the example that the factor levels are named after the
bounds.
15.14. Recoding a Continuous Variable to a Categorical Variable  |  351
To change the names of the levels, set the labels:
pg$wtclass <- cut(pg$weight, breaks = c(0, 56, Inf),
labels = c("small""medium""large"))
pg
weight group wtclass
4.17  ctrl   small
5.58  ctrl  medium
4.81  trt1   small
4.17  trt1   small
6.31  trt2   large
5.12  trt2  medium
As indicated by the factor levels, the bounds are by default open on the left and closed
on the right. In other words, they don’t include the lowest value, but they do include the
highest value. For the smallest category, you can have it include both the lower and upper
values by setting include.lowest=TRUE. In this example, this would result in 0 values
going into the small category; otherwise, 0 would be coded as NA.
If you want the categories to be closed on the left and open on the right, set right =
FALSE:
cut(pg$weight, breaks = c(056, Inf), right = FALSE)
See Also
To recode a categorical variable to another categorical variable, see Recipe 15.13.
15.15. Transforming Variables
Problem
You want to transform a variable in a data frame.
Solution
Reference the new column with the $ operator, and assign some values to it. For this
example, we’ll use a copy of the heightweight data set:
library(gcookbook) # For the data set
# Make a copy of the data
hw <- heightweight
hw
sex ageYear ageMonth heightIn weightLb
  11.92      143     56.3     85.0
352  |  Chapter 15: Getting Your Data into Shape
  12.92      155     62.3    105.0
...
  13.92      167     62.0    107.5
  12.58      151     59.3     87.0
This will convert heightIn to centimeters and store it in a new column, heightCm:
hw$heightCm <- hw$heightIn * 2.54
hw
sex ageYear ageMonth heightIn weightLb heightCm
  11.92      143     56.3     85.0  143.002
  12.92      155     62.3    105.0  158.242
...
  13.92      167     62.0    107.5  157.480
  12.58      151     59.3     87.0  150.622
Discussion
For slightly easier-to-read code, you can use transform() or mutate() from the plyr
package. You only need to specify the data frame once, as the first argument to the
function, meaning these provide a cleaner syntax, especially if you are transforming
multiple variables:
hw <- transform(hw, heightCm = heightIn * 2.54, weightKg = weightLb / 2.204)
library(plyr)
hw <- mutate(hw, heightCm = heightIn * 2.54, weightKg = weightLb / 2.204)
hw
sex ageYear ageMonth heightIn weightLb heightCm weightKg
  11.92      143     56.3     85.0  143.002 38.56624
  12.92      155     62.3    105.0  158.242 47.64065
...
  13.92      167     62.0    107.5  157.480 48.77495
  12.58      151     59.3     87.0  150.622 39.47368
It is also possible to calculate a new variable based on multiple variables:
# These all have the same effect:
hw <- transform(hw, bmi = weightKg / (heightCm / 100)^2)
hw <- mutate(hw, bmi = weightKg / (heightCm / 100)^2)
hw$bmi <- hw$weightKg / (hw$heightCm/100)^2
hw
sex ageYear ageMonth heightIn weightLb heightCm weightKg      bmi
  11.92      143     56.3     85.0  143.002 38.56624 18.85919
  12.92      155     62.3    105.0  158.242 47.64065 19.02542
...
  13.92      167     62.0    107.5  157.480 48.77495 19.66736
  12.58      151     59.3     87.0  150.622 39.47368 17.39926
15.15. Transforming Variables  |  353
The main  functional difference between transform() and mutate()  is  that trans
form() calculates the new columns simultaneously, while mutate() calculates the new
columns sequentially, allowing you to base one new column on another new column.
Since bmi is calculated from heightCm and weightKg, it is not possible to calculate all of
them in a single call to transform(); heightCm and weightKg must be calculated first,
and then bmi, as shown here.
With mutate(), however, we can calculate them all in one go. The following code has
the same effect as the previous separate blocks:
hw <- heightweight
hw <- mutate(hw,
heightCm = heightIn * 2.54,
weightKg = weightLb / 2.204,
bmi = weightKg / (heightCm / 100)^2)
See Also
See Recipe 15.16 for how to perform group-wise transformations on data.
15.16. Transforming Variables by Group
Problem
You want to transform variables by performing operations on groups of data, as specified
by a grouping variable.
Solution
Use ddply() from the plyr package with the transform() function, and specify the
operations:
library(MASS) # For the data set
library(plyr)
cb <- ddply(cabbages, "Cult", transform, DevWt = HeadWt - mean(HeadWt))
Cult Date HeadWt VitC       DevWt
c39  d16    2.5   51 -0.40666667
c39  d16    2.2   55 -0.70666667
...
c52  d21    1.5   66 -0.78000000
c52  d21    1.6   72 -0.68000000
354  |  Chapter 15: Getting Your Data into Shape
Documents you may be interested
Documents you may be interested