Skip to content

Commit 491d9aa

Browse files
committed
w
1 parent 1ba6b51 commit 491d9aa

18 files changed

Lines changed: 1226 additions & 238 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Publish/.DS_Store

0 Bytes
Binary file not shown.

Publish/2 quarto/1 quarto intro.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,9 @@ format:
785785
<iframe width="900" height="600" src="https://quarto.org/docs/output-formats/all-formats.html"></iframe>
786786

787787

788+
:::
788789

789790

790-
:::
791791

792792

793793
# Reference

_freeze/data manipulation/1 input ouput/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

data manipulation/.DS_Store

0 Bytes
Binary file not shown.

data manipulation/1 input ouput.qmd

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ data002=(data) %>% as.data.frame()
107107
glimpse(data002)
108108
```
109109

110-
## Getting Data from Images
110+
## read Data from Images
111111

112112
```{r}
113113
library(tesseract)
@@ -144,10 +144,64 @@ glimpse(raw_tibble001)
144144
```
145145

146146

147+
## read data from RData/Rds
147148

149+
Rda is just a short name for RData.Rds stores a single R object.RData can store multiple R objects in a single file.
148150

151+
### read one data
149152

150-
# Output
153+
```{r}
154+
#| eval: false
155+
my_data <- readRDS("mtcars.rds")
156+
```
157+
158+
### read multiple data
159+
160+
```{r}
161+
#| eval: false
162+
load("my_work_space.RData")
163+
```
164+
165+
## read doxc
166+
167+
```{r}
168+
pak::pkg_install('officer')
169+
library(officer)
170+
docx=read_docx("data/example03.docx")
171+
#docx
172+
```
173+
174+
```{r}
175+
docx_dim(docx)
176+
```
177+
178+
```{r}
179+
docx_summary(docx)
180+
```
181+
182+
filter table section
183+
184+
```{r}
185+
table_cells=docx_summary(docx) %>% filter(content_type == "table cell")
186+
187+
table_data <- table_cells %>% filter(!is_header) %>% select(row_id, cell_id, text)
188+
table_data
189+
```
190+
191+
transform the table data into a data frame
192+
193+
```{r}
194+
# The content of the table is in 'long' format, but we can 're-rectangularise'
195+
table_names <- table_cells[table_cells$is_header, "text"]
196+
table_content <- table_cells[!table_cells$is_header, "text"]
197+
row_count <- nrow(table_cells) / nrow(table_cells[table_cells$is_header, ]) - 1
198+
table_mat <- as.data.frame(matrix(table_content, nrow = row_count))
199+
names(table_mat) <- table_names
200+
table_mat
201+
```
202+
203+
204+
# Output
151205

152206

153207
## write csv
@@ -205,5 +259,28 @@ its time!')
205259
write_delim(text, "text.txt")
206260
```
207261

262+
## write to RData/Rds
263+
264+
### write one data
265+
266+
```{r}
267+
# Save a single object to a file
268+
saveRDS(mtcars, "mtcars.rds")
269+
```
270+
271+
### write multiple data
272+
273+
```{r}
274+
# Save a single object to a file
275+
save(mtcars,iris, file="mtcars_and_iris.RData")
276+
```
277+
278+
279+
### write all working space data
280+
281+
```{r}
282+
# Save a single object to a file
283+
save.image(file = "my_work_space.RData")
284+
```
208285

209286

data manipulation/data/df.parquet

-5.85 KB
Binary file not shown.
-5.85 KB
Binary file not shown.
106 KB
Binary file not shown.
1 Byte
Binary file not shown.

0 commit comments

Comments
 (0)