1
votes

I have a data.frame that is comprised of rows that are each URLs but format of it when I run "typeof" is a list. This creates some issues when I try to bind it to other data.frames that are character or numeric formats. I'm trying to convert this data.frame which shows a list with factor levels for each row into a standard data.frame that has each URL intact occupying each row (length unchanged).

I've tried the following:

test <- as.character(web3) - This leaves me with a vector that is just numbers and no longer resembles anything I started with

test <- lapply(web3, data.frame, stringsAsFactors = FALSE) test2 <- rbind.fill(test)

Here is a dput of a portion of it:

structure(c(35L, 35L, 34L, 33L, 33L, 33L, 32L, 32L, 32L, 32L), .Label = c("/Archives/edgar/data/0001218981/000117911016022379/0001179110-16-022379-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028590/0001179110-16-028590-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028764/0001179110-16-028764-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028975/0001179110-16-028975-index.htm", 
"/Archives/edgar/data/0001218981/000117911016029122/0001179110-16-029122-index.htm", 
"/Archives/edgar/data/0001218981/000117911016030044/0001179110-16-030044-index.htm", 
"/Archives/edgar/data/0001218981/000117911016031144/0001179110-16-031144-index.htm", 
"/Archives/edgar/data/0001218981/000117911016032519/0001179110-16-032519-index.htm", 
"/Archives/edgar/data/0001218981/000117911017003489/0001179110-17-003489-index.htm", 
"/Archives/edgar/data/0001218981/000117911017009339/0001179110-17-009339-index.htm", 
"/Archives/edgar/data/0001218981/000117911017009836/0001179110-17-009836-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011451/0001179110-17-011451-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011684/0001179110-17-011684-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011782/0001179110-17-011782-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013512/0001179110-17-013512-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013668/0001179110-17-013668-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013817/0001179110-17-013817-index.htm", 
"/Archives/edgar/data/0001218981/000117911017014024/0001179110-17-014024-index.htm", 
"/Archives/edgar/data/0001218981/000117911017014676/0001179110-17-014676-index.htm", 
"/Archives/edgar/data/0001218981/000117911017015379/0001179110-17-015379-index.htm", 
"/Archives/edgar/data/0001218981/000117911018004779/0001179110-18-004779-index.htm", 
"/Archives/edgar/data/0001218981/000117911018008826/0001179110-18-008826-index.htm", 
"/Archives/edgar/data/0001218981/000117911018009648/0001179110-18-009648-index.htm", 
"/Archives/edgar/data/0001218981/000117911018009739/0001179110-18-009739-index.htm", 
"/Archives/edgar/data/0001218981/000117911018011490/0001179110-18-011490-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004050/0001179110-19-004050-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004286/0001179110-19-004286-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004323/0001179110-19-004323-index.htm", 
"/Archives/edgar/data/0001218981/000117911019005598/0001179110-19-005598-index.htm", 
"/Archives/edgar/data/0001218981/000117911019007384/0001179110-19-007384-index.htm", 
"/Archives/edgar/data/0001218981/000117911019012669/0001179110-19-012669-index.htm", 
"/Archives/edgar/data/0001218981/000117911019013159/0001179110-19-013159-index.htm", 
"/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm", 
"/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm", 
"/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm", 
"/Archives/edgar/data/0001218981/000120919115082536/0001209191-15-082536-index.htm", 
"/Archives/edgar/data/0001218981/000120919115083517/0001209191-15-083517-index.htm", 
"/Archives/edgar/data/0001218981/000120919116095084/0001209191-16-095084-index.htm", 
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001015739", "/cgi-bin/browse-edgar?action=getcompany&CIK=0001218981&owner=include", 
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001326732", "/cgi-bin/browse-edgar?action=getcurrent", 
"/cgi-bin/own-disp?action=getissuer&CIK=0001015739", "/cgi-bin/own-disp?action=getissuer&CIK=0001326732", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=filings-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=ownership-data-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=period-of-report-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=type-of-owner-ASC", 
"/edgar/searchedgar/webusers.htm", "/index.htm", "javascript:history.back()"
), class = "factor")

Double-check dput:

structure(list(web = structure(c(35L, 35L, 34L, 33L, 33L, 33L, 
32L, 32L, 32L, 32L, 31L, 31L, 31L, 30L, 29L, 27L, 28L, 27L, 26L, 
26L, 25L, 24L, 24L, 24L, 23L, 23L, 23L, 23L, 23L, 22L, 22L, 22L, 
21L, 20L, 20L, 19L, 19L, 18L, 18L, 18L, 17L, 17L, 17L, 16L, 16L, 
16L, 15L, 15L, 15L, 14L, 14L, 13L, 13L, 13L, 12L, 12L, 11L, 10L, 
9L, 8L, 7L, 7L, 6L, 6L, 6L, 5L, 4L, 4L, 3L, 2L, 2L, 2L, 1L, 38L, 
38L, 37L, 37L, 37L, 36L, 36L), .Label = c("/Archives/edgar/data/0001218981/000117911016022379/0001179110-16-022379-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028590/0001179110-16-028590-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028764/0001179110-16-028764-index.htm", 
"/Archives/edgar/data/0001218981/000117911016028975/0001179110-16-028975-index.htm", 
"/Archives/edgar/data/0001218981/000117911016029122/0001179110-16-029122-index.htm", 
"/Archives/edgar/data/0001218981/000117911016030044/0001179110-16-030044-index.htm", 
"/Archives/edgar/data/0001218981/000117911016031144/0001179110-16-031144-index.htm", 
"/Archives/edgar/data/0001218981/000117911016032519/0001179110-16-032519-index.htm", 
"/Archives/edgar/data/0001218981/000117911017003489/0001179110-17-003489-index.htm", 
"/Archives/edgar/data/0001218981/000117911017009339/0001179110-17-009339-index.htm", 
"/Archives/edgar/data/0001218981/000117911017009836/0001179110-17-009836-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011451/0001179110-17-011451-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011684/0001179110-17-011684-index.htm", 
"/Archives/edgar/data/0001218981/000117911017011782/0001179110-17-011782-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013512/0001179110-17-013512-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013668/0001179110-17-013668-index.htm", 
"/Archives/edgar/data/0001218981/000117911017013817/0001179110-17-013817-index.htm", 
"/Archives/edgar/data/0001218981/000117911017014024/0001179110-17-014024-index.htm", 
"/Archives/edgar/data/0001218981/000117911017014676/0001179110-17-014676-index.htm", 
"/Archives/edgar/data/0001218981/000117911017015379/0001179110-17-015379-index.htm", 
"/Archives/edgar/data/0001218981/000117911018004779/0001179110-18-004779-index.htm", 
"/Archives/edgar/data/0001218981/000117911018008826/0001179110-18-008826-index.htm", 
"/Archives/edgar/data/0001218981/000117911018009648/0001179110-18-009648-index.htm", 
"/Archives/edgar/data/0001218981/000117911018009739/0001179110-18-009739-index.htm", 
"/Archives/edgar/data/0001218981/000117911018011490/0001179110-18-011490-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004050/0001179110-19-004050-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004286/0001179110-19-004286-index.htm", 
"/Archives/edgar/data/0001218981/000117911019004323/0001179110-19-004323-index.htm", 
"/Archives/edgar/data/0001218981/000117911019005598/0001179110-19-005598-index.htm", 
"/Archives/edgar/data/0001218981/000117911019007384/0001179110-19-007384-index.htm", 
"/Archives/edgar/data/0001218981/000117911019012669/0001179110-19-012669-index.htm", 
"/Archives/edgar/data/0001218981/000117911019013159/0001179110-19-013159-index.htm", 
"/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm", 
"/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm", 
"/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm", 
"/Archives/edgar/data/0001218981/000120919115082536/0001209191-15-082536-index.htm", 
"/Archives/edgar/data/0001218981/000120919115083517/0001209191-15-083517-index.htm", 
"/Archives/edgar/data/0001218981/000120919116095084/0001209191-16-095084-index.htm", 
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001015739", "/cgi-bin/browse-edgar?action=getcompany&CIK=0001218981&owner=include", 
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001326732", "/cgi-bin/browse-edgar?action=getcurrent", 
"/cgi-bin/own-disp?action=getissuer&CIK=0001015739", "/cgi-bin/own-disp?action=getissuer&CIK=0001326732", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=filings-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=ownership-data-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=period-of-report-ASC", 
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=type-of-owner-ASC", 
"/edgar/searchedgar/webusers.htm", "/index.htm", "javascript:history.back()"
), class = "factor")), row.names = c(NA, -80L), class = "data.frame")

Help is appreciated!

1
the str shows it is a vector with class factor. Not clear about what you expect as outputakrun
I'd like the output to no longer be a factor but continue to have the same textjs80
In that case it would be as.character(vec1) or as.character(test) if the dput iis from testakrun
This is the output with as.character(test): "c(35, 35, 34, 33, 33, 33, 32, 32, 32, 32, 31, 31, 31, 30, 29, 27, 28, 27, 26, 26, 25, 24, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 5, 4, 4, 3, 2, 2, 2, 1, 38, 38, 37, 37, 37, 36, 36)"js80
I am not able to reproduce that. I get as.character(test)# [1] "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm" [2] "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm"... from your dputakrun

1 Answers

0
votes

If we need to convert the column to character, just extract the column and use as.character

test2$web <- as.character(test2$web)

-checking the structure

str(test2)
#'data.frame':  80 obs. of  1 variable:
# $ web: chr  "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm" "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm" "/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm" "/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm" ...