How do I recode/convert values in a data frame from non-numeric to binary "TRUE" "FALSE", in Rstudio
How do I recode/convert values in a data frame from non-numeric to binary "TRUE" "FALSE", in Rstudio
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
How do I recode/convert values in a data frame from non-numeric to binary "TRUE" "FALSE", in Rstudio
![R RStudio
File Edit
Code View Plots
Session Build Debug Profile
Tools Help
A Go to file/function
BA - Addins -
R Project: (None) -
O Project 5 Logistic Modeling.R* *
Environment
History
Connections
Tutor aO
a A O Source on Save
9 required<-c("gtools")
Run
+ Source -
* Import Dataset -
List -
Global Environment-
10
11 installed<-installed. packages () [, 'Package']
Data
12
O wibc
699 obs. of 12 varia.m
13 for (pkg in required)
14 - {
values
if (!pkg %in% installed)
{
cat ("Installing package:", pkg, "\n")
install.packages (pkg)
}
chr [1:699] "benign" "..
chr [1:699] "benign" "..
installed chr [1:113] "asserttha.
15
A
16 -
class
17
18
pkg
required
"gtools"
"gtools"
19 -
20
cat ("Loading package", pkg, "\n")
require(pkg, character.onīy=TRUE)
21
sourcepir ""
22
23 - }
24
25
26 # load dataset
27
28 wibc<-read.csv("WI_breast_cancer.csv")
29
30
# let's see what the data look 1like
31
#3
32 head (wibc)
str (wibc)
33
34
Files
Plots
Packages
Help
Viewer
# recode categorical variables for use with glm procedure. Convert "malignant" to TRUE
# and "benign" to FALSE. Copy data frame and add new "malignancy" column.
class<-wibcsclass
class
35
36
C Refresh
37
R: The F Distribution -
Find in Topic
38
39
FDist {stats}
R Documentation
40
# ADD YOUR CODE HERE
n = 1
wibc2 = cbind (wibc,replicate(n,wibc$class))
wibc2
colnames (wibc2)<-c("x", "Id", "cl. thickness","cell.size","cell. shape","Marg. adhesion", "Epith.c.size","Bare.nuclei","B1.cromatin", "Normal.nucleoli", "Mitoses", "class", "malignancy")
41
42
The F Distribution
43
44
45
Description
46 head (wibc2)
str(wihc2)
47
Density, distribution function, quantile function
and random generation for the F distribution
with dfl and df2 degrees of freedom (and
optional non-centrality parameter ncp)
39:1
(Top Level) :
R Script :
Console
Terminal x
Jobs x
+ }
Loading package gtools
Loading required package: gtools
> wibc<-read.csv("WI_breast_cancer.csv")
# let's see what the data look 1ike
> #
> head (wibc)
Usage
df (x, df1, df2, ncp, log = FALSE)
pf (g, df1, df2, ncp,
gf (p, df1, df2, ncp,
lower.tail = T!
lower.tail = T!
rf (n, df1, df2, ncp)
Id cl.thickness cell.size cell.shape Marg. adhesion Epith.c.size Bare. nuclei B1.cromatin Normal.nucleoli Mitoses
class
Arguments
11 1000025
2 2 1002945
3 3 1015425
benign
benign
benign
benign
benign
1 malignant
10
1.
1
х, ч
vector of quantiles.
4 4 1016277
8.
8
4
1.
vector of probabilities.
5 5 1017023
6 6 1017122
> str (wibc)
'data. frame':
$ X
4
1.
1.
1.
10
10
10
number of observations. If
length (n) > 1, the length
is taken to be the number
699 obs. of 12 variables:
: int
1 2 3 4 5 6 7 8 9 10 ...
1000025 1002915 1015425 1016277 1017023 1017122 1018000 1018561
103307g
1033078](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4e2c08d3-a922-4523-864a-ebe98e79b964%2F1c89c6d7-2c89-43b2-b8bb-a92dd58957fe%2Foj3zfh_processed.png&w=3840&q=75)
Transcribed Image Text:R RStudio
File Edit
Code View Plots
Session Build Debug Profile
Tools Help
A Go to file/function
BA - Addins -
R Project: (None) -
O Project 5 Logistic Modeling.R* *
Environment
History
Connections
Tutor aO
a A O Source on Save
9 required<-c("gtools")
Run
+ Source -
* Import Dataset -
List -
Global Environment-
10
11 installed<-installed. packages () [, 'Package']
Data
12
O wibc
699 obs. of 12 varia.m
13 for (pkg in required)
14 - {
values
if (!pkg %in% installed)
{
cat ("Installing package:", pkg, "\n")
install.packages (pkg)
}
chr [1:699] "benign" "..
chr [1:699] "benign" "..
installed chr [1:113] "asserttha.
15
A
16 -
class
17
18
pkg
required
"gtools"
"gtools"
19 -
20
cat ("Loading package", pkg, "\n")
require(pkg, character.onīy=TRUE)
21
sourcepir ""
22
23 - }
24
25
26 # load dataset
27
28 wibc<-read.csv("WI_breast_cancer.csv")
29
30
# let's see what the data look 1like
31
#3
32 head (wibc)
str (wibc)
33
34
Files
Plots
Packages
Help
Viewer
# recode categorical variables for use with glm procedure. Convert "malignant" to TRUE
# and "benign" to FALSE. Copy data frame and add new "malignancy" column.
class<-wibcsclass
class
35
36
C Refresh
37
R: The F Distribution -
Find in Topic
38
39
FDist {stats}
R Documentation
40
# ADD YOUR CODE HERE
n = 1
wibc2 = cbind (wibc,replicate(n,wibc$class))
wibc2
colnames (wibc2)<-c("x", "Id", "cl. thickness","cell.size","cell. shape","Marg. adhesion", "Epith.c.size","Bare.nuclei","B1.cromatin", "Normal.nucleoli", "Mitoses", "class", "malignancy")
41
42
The F Distribution
43
44
45
Description
46 head (wibc2)
str(wihc2)
47
Density, distribution function, quantile function
and random generation for the F distribution
with dfl and df2 degrees of freedom (and
optional non-centrality parameter ncp)
39:1
(Top Level) :
R Script :
Console
Terminal x
Jobs x
+ }
Loading package gtools
Loading required package: gtools
> wibc<-read.csv("WI_breast_cancer.csv")
# let's see what the data look 1ike
> #
> head (wibc)
Usage
df (x, df1, df2, ncp, log = FALSE)
pf (g, df1, df2, ncp,
gf (p, df1, df2, ncp,
lower.tail = T!
lower.tail = T!
rf (n, df1, df2, ncp)
Id cl.thickness cell.size cell.shape Marg. adhesion Epith.c.size Bare. nuclei B1.cromatin Normal.nucleoli Mitoses
class
Arguments
11 1000025
2 2 1002945
3 3 1015425
benign
benign
benign
benign
benign
1 malignant
10
1.
1
х, ч
vector of quantiles.
4 4 1016277
8.
8
4
1.
vector of probabilities.
5 5 1017023
6 6 1017122
> str (wibc)
'data. frame':
$ X
4
1.
1.
1.
10
10
10
number of observations. If
length (n) > 1, the length
is taken to be the number
699 obs. of 12 variables:
: int
1 2 3 4 5 6 7 8 9 10 ...
1000025 1002915 1015425 1016277 1017023 1017122 1018000 1018561
103307g
1033078
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education