Skip to content

Commit 9017391

Browse files
committed
R Code
1 parent 1699a3a commit 9017391

File tree

9 files changed

+82
-0
lines changed

9 files changed

+82
-0
lines changed

.Rproj.user/DED8A758/build_options

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
auto_roxygenize_for_build_and_reload="0"
2+
auto_roxygenize_for_build_package="1"
3+
auto_roxygenize_for_check="1"
4+
live_preview_website="0"
5+
makefile_args=""
6+
preview_website="1"
7+
website_output_format="all"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "7,23",
5+
"scrollLine": "0"
6+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C%3A%2FUsers%2FHP%2FDownloads%2FAssignment-AffinityAnswers%2FAssignment-AffinityAnswers.R="E8A88EF3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"id": "67AE2135",
3+
"path": "C:/Users/HP/Downloads/Assignment-AffinityAnswers/Assignment-AffinityAnswers.R",
4+
"project_path": "Assignment-AffinityAnswers.R",
5+
"type": "r_source",
6+
"hash": "3772126400",
7+
"contents": "",
8+
"dirty": false,
9+
"created": 1676480702806.0,
10+
"source_on_save": false,
11+
"relative_order": 2,
12+
"properties": {
13+
"source_window_id": "",
14+
"Source": "Source",
15+
"cursorPosition": "7,23",
16+
"scrollLine": "0"
17+
},
18+
"folds": "",
19+
"lastKnownWriteTime": 1676481412,
20+
"encoding": "UTF-8",
21+
"collab_server": "",
22+
"source_window": "",
23+
"last_content_update": 1676481412087,
24+
"read_only": false,
25+
"read_only_alternatives": []
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Read in the file of racial slurs
2+
slurs <- readLines("slurs.txt")
3+
4+
# Read in the file of tweets
5+
tweets <- readLines("tweets.txt")
6+
7+
# Loop through each tweet and calculate the degree of profanity
8+
for (tweet in tweets) {
9+
# Split the tweet into individual words
10+
words <- strsplit(tweet, "\\s")[[1]]
11+
12+
# Count the number of racial slurs in the tweet
13+
num_slurs <- sum(words %in% slurs)
14+
15+
# Calculate the degree of profanity as a percentage of the total words
16+
profanity <- num_slurs / length(words) * 100
17+
18+
# Print the result
19+
cat("Tweet:", tweet, "\n")
20+
cat("Degree of Profanity:", round(profanity, 2), "%\n\n")
21+
}

.Rproj.user/DED8A758/sources/s-315DC4E1/CA421393-contents

Whitespace-only changes.

.Rproj.user/DED8A758/sources/s-315DC4E1/lock_file

Whitespace-only changes.

.Rproj.user/shared/notebooks/patch-chunk-names

Whitespace-only changes.

Assignment-AffinityAnswers.R

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Read in the file of racial slurs
2+
slurs <- readLines("slurs.txt")
3+
4+
# Read in the file of tweets
5+
tweets <- readLines("tweets.txt")
6+
7+
# Loop through each tweet and calculate the degree of profanity
8+
for (tweet in tweets) {
9+
# Split the tweet into individual words
10+
words <- strsplit(tweet, "\\s")[[1]]
11+
12+
# Count the number of racial slurs in the tweet
13+
num_slurs <- sum(words %in% slurs)
14+
15+
# Calculate the degree of profanity as a percentage of the total words
16+
profanity <- num_slurs / length(words) * 100
17+
18+
# Print the result
19+
cat("Tweet:", tweet, "\n")
20+
cat("Degree of Profanity:", round(profanity, 2), "%\n\n")
21+
}

0 commit comments

Comments
 (0)