Skip to content

Commit df67739

Browse files
committed
added
0 parents  commit df67739

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+12444
-0
lines changed

.RData

9.48 KB
Binary file not shown.

.Rhistory

+510
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"debugBreakpointsState": {
3+
"breakpoints": []
4+
}
5+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"sortOrder": [
3+
{
4+
"columnIndex": 2,
5+
"ascending": true
6+
}
7+
],
8+
"path": "D:/R/Code"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"installOptions": {
3+
"installFromRepository": true,
4+
"libraryPath": "C:/Users/WT/AppData/Local/R/win-library/4.4",
5+
"installDependencies": true
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"activeTab": -1
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"left": {
3+
"splitterpos": 389,
4+
"topwindowstate": "HIDE",
5+
"panelheight": 633,
6+
"windowheight": 671
7+
},
8+
"right": {
9+
"splitterpos": 340,
10+
"topwindowstate": "NORMAL",
11+
"panelheight": 633,
12+
"windowheight": 671
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"TabSet1": 1,
3+
"TabSet2": 0,
4+
"TabZoom": {}
5+
}

.Rproj.user/640EDE58/persistent-state

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build-last-errors="[]"
2+
build-last-errors-base-dir=""
3+
build-last-outputs="[]"
4+
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
5+
files.monitored-path=""
6+
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
7+
imageDirtyState="1"
8+
saveActionState="-1"

.Rproj.user/640EDE58/rmd-outputs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
4+
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"active_set":"","sets":[]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "24,0",
5+
"scrollLine": "10"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "13,1",
5+
"scrollLine": "4"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "24,0",
5+
"scrollLine": "11"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "2,0",
5+
"scrollLine": "0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "1,94",
5+
"scrollLine": "0"
6+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "3,3",
5+
"scrollLine": "0",
6+
"rmdVisualMode": "false",
7+
"rmdVisualCollapsedChunks": "",
8+
"rmdVisualModeLocation": "45:0",
9+
"rmdVisualWrapConfigured": "true",
10+
"docOutlineVisible": "1"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "0,0",
5+
"scrollLine": "0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "13,1",
5+
"scrollLine": "4"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "11,0",
5+
"scrollLine": "0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "5,0",
5+
"scrollLine": "0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "75,9",
5+
"scrollLine": "62"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "11,0",
5+
"scrollLine": "11"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "65,0",
5+
"scrollLine": "58"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "12,0",
5+
"scrollLine": "0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"source_window_id": "",
3+
"Source": "Source",
4+
"cursorPosition": "2,0",
5+
"scrollLine": "0"
6+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
D%3A%2F%2FR%2F1Day%2Fhello.r="39738C78"
2+
D%3A%2F%2FR%2FCode%2FUntitled.Rmd="613164F1"
3+
D%3A%2F%2FR%2FCode%2Fcalculator.R="839D1939"
4+
D%3A%2F%2FR%2FCode%2Fdata_import.R="DC877B83"
5+
D%3A%2F%2FR%2FCode%2Fggplot2.R="86F390D5"
6+
D%3A%2F%2FR%2FCode%2Flibrary_install.R="20BA4671"
7+
D%3A%2F%2FR%2FData%2Ftest.csv="93481DE9"
8+
D%3A%2F%2FR%2Felec_data.csv="2193434A"
9+
D%3A%2F%2FR%2Fmain.R="94BD3D00"
10+
D%3A%2F%2FR%2Fp_df2.csv="EA1C7EB5"
11+
D%3A%2F%2FR%2Fp_table.csv="06DEECA7"
12+
D%3A%2FR%2F1Day%2Fhello.r="EE035FAB"
13+
D%3A%2FR%2FCode%2FUntitled.Rmd="4A0C61A8"
14+
D%3A%2FR%2FCode%2Fcalculator.R="164CAE06"
15+
D%3A%2FR%2FCode%2Fdata_import.R="B8685F0D"
16+
D%3A%2FR%2FCode%2Fggplot2.R="ED67FFE8"
17+
D%3A%2FR%2FCode%2Flibrary_install.R="0692A80B"
18+
D%3A%2FR%2FData%2Ftest.csv="47CB8473"
19+
D%3A%2FR%2Felec_data.csv="7A424F44"
20+
D%3A%2FR%2Fmain.R="BCF1CE5F"
21+
D%3A%2FR%2Fp_df2.csv="1A25DCE8"
22+
D%3A%2FR%2Fp_table.csv="C0EAAA87"

.Rproj.user/640EDE58/sources/session-8dff567f/3C093566-contents

Whitespace-only changes.

.Rproj.user/640EDE58/sources/session-8dff567f/lock_file

Whitespace-only changes.

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

Whitespace-only changes.

.Rproj.user/shared/notebooks/paths

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
D://R/Code/calculator.R="A1CE5347"
2+
D://R/Code/data_import.R="EC957BDE"
3+
D://R/Code/ggplot2.R="3899E611"
4+
D://R/Code/library_install.R="2B2938A8"
5+
D://R/Data/test.csv="8E6E3D06"
6+
D://R/main.R="12742FCF"
7+
D://R/p_table.csv="2FE7C9C1"
8+
D:/R/Code/calculator.R="AD8EC9D8"
9+
D:/R/Code/data_import.R="FF399313"
10+
D:/R/Code/ggplot2.R="CCBD1586"
11+
D:/R/Code/library_install.R="B00CD5C7"
12+
D:/R/Data/test.csv="5792D8FD"
13+
D:/R/elec_data.csv="3D682595"
14+
D:/R/main.R="F868DBDD"
15+
D:/R/p_table.csv="D0FC05AD"

Code/calculator.R

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
a <- as.numeric(readline(prompt = "Enter First Number: "))
2+
b <- as.numeric(readline(prompt = "Enter Second Number: "))
3+
cat("What do you want?\n")
4+
cat("1. Sum\n")
5+
cat("2. Subtract\n")
6+
cat("3. Divide\n")
7+
p <- as.numeric(readline(prompt = "Choose one (1, 2, 3): "))
8+
9+
result <- switch(p,
10+
`1` = a + b,
11+
`2` = a - b,
12+
`3` = ifelse(b != 0, a / b, "Error: Division by zero"),
13+
"Invalid choice"
14+
)
15+
16+
if (is.numeric(result)) {
17+
cat("The result is:", result, "\n")
18+
} else {
19+
cat(result, "\n")
20+
}

Code/data_import.R

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#to check current working directory
2+
getwd()
3+
4+
#Set working directory for path setup
5+
6+
setwd("D:/R/Data")
7+
8+
#check again
9+
getwd()
10+
11+
12+
#read csv file
13+
p_data <- read.csv('p_table.csv')
14+
15+
# create data frame
16+
p_df <- data.frame(p_data)
17+
18+
19+
# view Data frame
20+
View(p_df)
21+
22+
# print top 6 data
23+
head(p_df)
24+
25+
# print bottom 6 data
26+
tail(p_df)
27+
28+
29+
#just use in rstudio for changing value
30+
fix(p_df)
31+
32+
# summarize data
33+
summary(p_df)
34+
35+
# headers
36+
names(p_df)
37+
38+
str(p_df)
39+
40+
41+
nrow(p_df)
42+
43+
ncol(p_df)
44+
45+
length(p_df)
46+
47+
dim(p_df) #shows the dimensions of the data frame
48+
49+
colnames(p_df) #shows the name of each column in the data
50+
51+
p_df2<- p_df [c(1:4,15,5:14)] #filter data
52+
53+
names(p_df2)
54+
55+
p_df2<- p_df [c(1:10),c(1:4)] #10 rows 4 cols
56+
57+
names(p_df2)
58+
59+
# to filter data
60+
test <- subset(p_df, p_df$Symbol=='B' )
61+
View(test)
62+
63+
64+
# to save
65+
write.csv(test, "test.csv", row.names = TRUE)
66+
67+
68+
69+
library("dplyr") #for manipulate data
70+
71+
72+
# Using the mtcars data set
73+
mtcars %>%
74+
filter(mpg > 20) %>% # Filter rows where mpg is greater than 20
75+
select(mpg, hp) %>% # Select only mpg and hp columns
76+
arrange(desc(mpg)) # Arrange the rows in descending order of mpg
77+
78+
# in R, %>% is the "pipe" operator, it helps to create pipe structure of function

Code/ggplot2.R

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# install.packages("ggplot2")
2+
3+
#import
4+
library(ggplot2)
5+
6+
# Create a simple scatter plot
7+
ggplot(mtcars, aes(x=mpg, y=hp)) +
8+
geom_point() +
9+
labs(title="Scatter Plot of mpg vs hp", x="Miles per Gallon", y="Horsepower") +
10+
geom_line()+
11+
geom_smooth(method = 'loess')
12+

0 commit comments

Comments
 (0)